Built motion from commit 953226e6.|2.6.32
[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 _0x453b=['../../mysqldb','WhatsappInteraction','WhatsappMessage','setMaxListeners','save','update','remove','getUsers','then','Users','map','findAll','setDataValue','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events'];(function(_0x28b686,_0x212267){var _0xb43315=function(_0x19633f){while(--_0x19633f){_0x28b686['push'](_0x28b686['shift']());}};_0xb43315(++_0x212267);}(_0x453b,0x164));var _0xb453=function(_0x2d4661,_0x2da65c){_0x2d4661=_0x2d4661-0x0;var _0x42ed1e=_0x453b[_0x2d4661];return _0x42ed1e;};'use strict';var EventEmitter=require(_0xb453('0x0'));var WhatsappInteraction=require(_0xb453('0x1'))['db'][_0xb453('0x2')];var WhatsappMessage=require(_0xb453('0x1'))['db'][_0xb453('0x3')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xb453('0x4')](0x0);var events={'afterCreate':_0xb453('0x5'),'afterUpdate':_0xb453('0x6'),'afterDestroy':_0xb453('0x7')};function emitEvent(_0x1314f4){return function(_0x6ee7a0,_0x3cfd60,_0x434695){_0x6ee7a0[_0xb453('0x8')]({'attributes':['id'],'raw':!![]})[_0xb453('0x9')](function(_0x2436a7){_0x6ee7a0['setDataValue'](_0xb453('0xa'),_0x2436a7[_0xb453('0xb')](function(_0x55b2fa){return{'id':_0x55b2fa['id']};}));return WhatsappMessage[_0xb453('0xc')]({'where':{'WhatsappInteractionId':_0x6ee7a0['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x894303){_0x6ee7a0[_0xb453('0xd')](_0xb453('0xe'),_0x894303[_0xb453('0xf')]);WhatsappInteractionEvents['emit'](_0x1314f4+':'+_0x6ee7a0['id'],_0x6ee7a0);WhatsappInteractionEvents[_0xb453('0x10')](_0x1314f4,_0x6ee7a0);_0x434695(null);})[_0xb453('0x11')](_0x434695(null));};}for(var e in events){if(events[_0xb453('0x12')](e)){var event=events[e];WhatsappInteraction[_0xb453('0x13')](e,emitEvent(event));}}module[_0xb453('0x14')]=WhatsappInteractionEvents;