Built motion from commit da617fac.|2.6.6
[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 _0xf996=['length','emit','catch','hook','events','../../mysqldb','WhatsappInteraction','WhatsappMessage','update','remove','getUsers','then','setDataValue','map','findAll','unreadMessages'];(function(_0x43653d,_0x290468){var _0x2e6c7c=function(_0x36ed02){while(--_0x36ed02){_0x43653d['push'](_0x43653d['shift']());}};_0x2e6c7c(++_0x290468);}(_0xf996,0x74));var _0x6f99=function(_0xc0213d,_0x4a3b1d){_0xc0213d=_0xc0213d-0x0;var _0x1a93c4=_0xf996[_0xc0213d];return _0x1a93c4;};'use strict';var EventEmitter=require(_0x6f99('0x0'));var WhatsappInteraction=require(_0x6f99('0x1'))['db'][_0x6f99('0x2')];var WhatsappMessage=require('../../mysqldb')['db'][_0x6f99('0x3')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':_0x6f99('0x4'),'afterDestroy':_0x6f99('0x5')};function emitEvent(_0x274f12){return function(_0x3de6be,_0x3ab5e2,_0xf2b5ee){_0x3de6be[_0x6f99('0x6')]({'attributes':['id'],'raw':!![]})[_0x6f99('0x7')](function(_0x123215){_0x3de6be[_0x6f99('0x8')]('Users',_0x123215[_0x6f99('0x9')](function(_0x52e063){return{'id':_0x52e063['id']};}));return WhatsappMessage[_0x6f99('0xa')]({'where':{'WhatsappInteractionId':_0x3de6be['id'],'direction':'in','read':![]},'raw':!![]});})[_0x6f99('0x7')](function(_0x41f436){_0x3de6be[_0x6f99('0x8')](_0x6f99('0xb'),_0x41f436[_0x6f99('0xc')]);WhatsappInteractionEvents[_0x6f99('0xd')](_0x274f12+':'+_0x3de6be['id'],_0x3de6be);WhatsappInteractionEvents[_0x6f99('0xd')](_0x274f12,_0x3de6be);_0xf2b5ee(null);})[_0x6f99('0xe')](_0xf2b5ee(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];WhatsappInteraction[_0x6f99('0xf')](e,emitEvent(event));}}module['exports']=WhatsappInteractionEvents;