Built motion from commit d1eab355.|2.6.28
[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 _0xd353=['getUsers','then','Users','map','findAll','setDataValue','unreadMessages','length','catch','events','../../mysqldb','WhatsappMessage','update'];(function(_0xf37011,_0x3d4f48){var _0x409cc0=function(_0x11336){while(--_0x11336){_0xf37011['push'](_0xf37011['shift']());}};_0x409cc0(++_0x3d4f48);}(_0xd353,0x7e));var _0x3d35=function(_0x13b1a1,_0x524bb1){_0x13b1a1=_0x13b1a1-0x0;var _0x401614=_0xd353[_0x13b1a1];return _0x401614;};'use strict';var EventEmitter=require(_0x3d35('0x0'));var WhatsappInteraction=require(_0x3d35('0x1'))['db']['WhatsappInteraction'];var WhatsappMessage=require(_0x3d35('0x1'))['db'][_0x3d35('0x2')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':_0x3d35('0x3'),'afterDestroy':'remove'};function emitEvent(_0x3bc47e){return function(_0x23d65e,_0x2287bd,_0xb43971){_0x23d65e[_0x3d35('0x4')]({'attributes':['id'],'raw':!![]})[_0x3d35('0x5')](function(_0x1cf467){_0x23d65e['setDataValue'](_0x3d35('0x6'),_0x1cf467[_0x3d35('0x7')](function(_0x19126c){return{'id':_0x19126c['id']};}));return WhatsappMessage[_0x3d35('0x8')]({'where':{'WhatsappInteractionId':_0x23d65e['id'],'direction':'in','read':![]},'raw':!![]});})[_0x3d35('0x5')](function(_0x3539f9){_0x23d65e[_0x3d35('0x9')](_0x3d35('0xa'),_0x3539f9[_0x3d35('0xb')]);WhatsappInteractionEvents['emit'](_0x3bc47e+':'+_0x23d65e['id'],_0x23d65e);WhatsappInteractionEvents['emit'](_0x3bc47e,_0x23d65e);_0xb43971(null);})[_0x3d35('0xc')](_0xb43971(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module['exports']=WhatsappInteractionEvents;