Built motion from commit (unavailable).|2.5.16
[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 _0x0dfe=['exports','events','../../mysqldb','WhatsappInteraction','WhatsappMessage','save','update','remove','getUsers','then','setDataValue','map','findAll','unreadMessages','emit','hasOwnProperty'];(function(_0x16068b,_0x3c2737){var _0x55fa62=function(_0x15bdc5){while(--_0x15bdc5){_0x16068b['push'](_0x16068b['shift']());}};_0x55fa62(++_0x3c2737);}(_0x0dfe,0x1e1));var _0xe0df=function(_0x24d59b,_0x2f3117){_0x24d59b=_0x24d59b-0x0;var _0x390aa8=_0x0dfe[_0x24d59b];return _0x390aa8;};'use strict';var EventEmitter=require(_0xe0df('0x0'));var WhatsappInteraction=require(_0xe0df('0x1'))['db'][_0xe0df('0x2')];var WhatsappMessage=require('../../mysqldb')['db'][_0xe0df('0x3')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xe0df('0x4'),'afterUpdate':_0xe0df('0x5'),'afterDestroy':_0xe0df('0x6')};function emitEvent(_0x1d124e){return function(_0x9e3a7,_0x92b565,_0x22583b){_0x9e3a7[_0xe0df('0x7')]({'attributes':['id'],'raw':!![]})[_0xe0df('0x8')](function(_0x50c300){_0x9e3a7[_0xe0df('0x9')]('Users',_0x50c300[_0xe0df('0xa')](function(_0x4540b9){return{'id':_0x4540b9['id']};}));return WhatsappMessage[_0xe0df('0xb')]({'where':{'WhatsappInteractionId':_0x9e3a7['id'],'direction':'in','read':![]},'raw':!![]});})[_0xe0df('0x8')](function(_0x38d44b){_0x9e3a7[_0xe0df('0x9')](_0xe0df('0xc'),_0x38d44b['length']);WhatsappInteractionEvents[_0xe0df('0xd')](_0x1d124e+':'+_0x9e3a7['id'],_0x9e3a7);WhatsappInteractionEvents[_0xe0df('0xd')](_0x1d124e,_0x9e3a7);_0x22583b(null);})['catch'](_0x22583b(null));};}for(var e in events){if(events[_0xe0df('0xe')](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module[_0xe0df('0xf')]=WhatsappInteractionEvents;