Built motion from commit (unavailable).|2.5.29
[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 _0xd9f5=['unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','WhatsappInteraction','setMaxListeners','update','remove','getUsers','setDataValue','Users','map','findAll','then'];(function(_0x2f5ac5,_0x1ee939){var _0x37c9a8=function(_0x15031f){while(--_0x15031f){_0x2f5ac5['push'](_0x2f5ac5['shift']());}};_0x37c9a8(++_0x1ee939);}(_0xd9f5,0x9f));var _0x5d9f=function(_0x280dd8,_0x5c8eb8){_0x280dd8=_0x280dd8-0x0;var _0x2a6aa6=_0xd9f5[_0x280dd8];return _0x2a6aa6;};'use strict';var EventEmitter=require(_0x5d9f('0x0'));var WhatsappInteraction=require(_0x5d9f('0x1'))['db'][_0x5d9f('0x2')];var WhatsappMessage=require('../../mysqldb')['db']['WhatsappMessage'];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0x5d9f('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x5d9f('0x4'),'afterDestroy':_0x5d9f('0x5')};function emitEvent(_0x3c55c8){return function(_0x54d441,_0x557603,_0x202369){_0x54d441[_0x5d9f('0x6')]({'attributes':['id'],'raw':!![]})['then'](function(_0x4fea70){_0x54d441[_0x5d9f('0x7')](_0x5d9f('0x8'),_0x4fea70[_0x5d9f('0x9')](function(_0x224ad0){return{'id':_0x224ad0['id']};}));return WhatsappMessage[_0x5d9f('0xa')]({'where':{'WhatsappInteractionId':_0x54d441['id'],'direction':'in','read':![]},'raw':!![]});})[_0x5d9f('0xb')](function(_0x24ba10){_0x54d441[_0x5d9f('0x7')](_0x5d9f('0xc'),_0x24ba10[_0x5d9f('0xd')]);WhatsappInteractionEvents[_0x5d9f('0xe')](_0x3c55c8+':'+_0x54d441['id'],_0x54d441);WhatsappInteractionEvents['emit'](_0x3c55c8,_0x54d441);_0x202369(null);})[_0x5d9f('0xf')](_0x202369(null));};}for(var e in events){if(events[_0x5d9f('0x10')](e)){var event=events[e];WhatsappInteraction[_0x5d9f('0x11')](e,emitEvent(event));}}module[_0x5d9f('0x12')]=WhatsappInteractionEvents;