Built motion from commit (unavailable).|2.5.22
[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 _0x7d1a=['catch','hasOwnProperty','hook','events','WhatsappMessage','setMaxListeners','save','update','remove','getUsers','then','Users','map','setDataValue','unreadMessages','length','emit'];(function(_0x2160a9,_0x3cbd9e){var _0xa88cf7=function(_0x51ab6f){while(--_0x51ab6f){_0x2160a9['push'](_0x2160a9['shift']());}};_0xa88cf7(++_0x3cbd9e);}(_0x7d1a,0x7a));var _0xa7d1=function(_0x4e1953,_0x5cf205){_0x4e1953=_0x4e1953-0x0;var _0x524406=_0x7d1a[_0x4e1953];return _0x524406;};'use strict';var EventEmitter=require(_0xa7d1('0x0'));var WhatsappInteraction=require('../../mysqldb')['db']['WhatsappInteraction'];var WhatsappMessage=require('../../mysqldb')['db'][_0xa7d1('0x1')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xa7d1('0x2')](0x0);var events={'afterCreate':_0xa7d1('0x3'),'afterUpdate':_0xa7d1('0x4'),'afterDestroy':_0xa7d1('0x5')};function emitEvent(_0x1dab9c){return function(_0x43e687,_0x3308d4,_0x2579c2){_0x43e687[_0xa7d1('0x6')]({'attributes':['id'],'raw':!![]})[_0xa7d1('0x7')](function(_0x3cb8e9){_0x43e687['setDataValue'](_0xa7d1('0x8'),_0x3cb8e9[_0xa7d1('0x9')](function(_0x282682){return{'id':_0x282682['id']};}));return WhatsappMessage['findAll']({'where':{'WhatsappInteractionId':_0x43e687['id'],'direction':'in','read':![]},'raw':!![]});})[_0xa7d1('0x7')](function(_0x556dca){_0x43e687[_0xa7d1('0xa')](_0xa7d1('0xb'),_0x556dca[_0xa7d1('0xc')]);WhatsappInteractionEvents[_0xa7d1('0xd')](_0x1dab9c+':'+_0x43e687['id'],_0x43e687);WhatsappInteractionEvents[_0xa7d1('0xd')](_0x1dab9c,_0x43e687);_0x2579c2(null);})[_0xa7d1('0xe')](_0x2579c2(null));};}for(var e in events){if(events[_0xa7d1('0xf')](e)){var event=events[e];WhatsappInteraction[_0xa7d1('0x10')](e,emitEvent(event));}}module['exports']=WhatsappInteractionEvents;