daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (!lawArea) return context;
  2.  
  3.   context.app
  4.     .service('base/lawyers')
  5.     .find({
  6.       query: { areas: lawArea },
  7.     })
  8.     .then(lawyers => {
  9.       let elements = lawyers.data;
  10.       let lawyersByArea = [];
  11.       elements.map(element => {
  12.         context.app
  13.           .service('base/users')
  14.           .get(element.user)
  15.           .then(user => {
  16.             if (user) lawyersByArea.push(user.device_id);
  17.           });
  18.       });
  19.  
  20.       console.log("enviar");
  21.  
  22.       let area = Area.get(lawArea).then(ts => {
  23.         const pushData = {
  24.           app_id: '2c00f0d5-54da-4c20-be9b-ee3709005c78',
  25.           headings: { en: `Novo cadastro em ${area.title}` },
  26.           contents: {
  27.             en: 'Um novo usuário relatou um problema em uma de suas areas de atuação. Acesse o aplicativo para conferir!',
  28.           },
  29.           include_player_ids: lawyersByArea,
  30.         };
  31.  
  32.         // axios
  33.         //   .post(onesignalApi, pushData, pushHeader)
  34.         //   .then(res => {
  35.         //     console.log('RESPONSE RECEIVED: ', res);
  36.         //   })
  37.         //   .catch(err => {
  38.         //     console.log('AXIOS ERROR: ', err);
  39.         //   });
  40.       });
  41.     });
  42.  
  43.   return context;
  44. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top