Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / whatsappInteraction / whatsappInteraction.events.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xeec4=['hook','exports','events','../../mysqldb','setMaxListeners','save','update','getUsers','Users','findAll','then','setDataValue','unreadMessages','length','emit','catch','hasOwnProperty'];(function(_0x93c226,_0x47dba1){var _0x209dac=function(_0x2a9ff0){while(--_0x2a9ff0){_0x93c226['push'](_0x93c226['shift']());}};_0x209dac(++_0x47dba1);}(_0xeec4,0x189));var _0x4eec=function(_0x330723,_0x8de382){_0x330723=_0x330723-0x0;var _0x60c546=_0xeec4[_0x330723];return _0x60c546;};'use strict';var EventEmitter=require(_0x4eec('0x0'));var WhatsappInteraction=require(_0x4eec('0x1'))['db']['WhatsappInteraction'];var WhatsappMessage=require(_0x4eec('0x1'))['db']['WhatsappMessage'];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0x4eec('0x2')](0x0);var events={'afterCreate':_0x4eec('0x3'),'afterUpdate':_0x4eec('0x4'),'afterDestroy':'remove'};function emitEvent(_0x5e8906){return function(_0x18e290,_0x225b7f,_0x3e08ac){_0x18e290[_0x4eec('0x5')]({'attributes':['id'],'raw':!![]})['then'](function(_0x2a6ae2){_0x18e290['setDataValue'](_0x4eec('0x6'),_0x2a6ae2['map'](function(_0x2a6e1e){return{'id':_0x2a6e1e['id']};}));return WhatsappMessage[_0x4eec('0x7')]({'where':{'WhatsappInteractionId':_0x18e290['id'],'direction':'in','read':![]},'raw':!![]});})[_0x4eec('0x8')](function(_0x431a10){_0x18e290[_0x4eec('0x9')](_0x4eec('0xa'),_0x431a10[_0x4eec('0xb')]);WhatsappInteractionEvents[_0x4eec('0xc')](_0x5e8906+':'+_0x18e290['id'],_0x18e290);WhatsappInteractionEvents[_0x4eec('0xc')](_0x5e8906,_0x18e290);_0x3e08ac(null);})[_0x4eec('0xd')](_0x3e08ac(null));};}for(var e in events){if(events[_0x4eec('0xe')](e)){var event=events[e];WhatsappInteraction[_0x4eec('0xf')](e,emitEvent(event));}}module[_0x4eec('0x10')]=WhatsappInteractionEvents;