Built motion from commit (unavailable).|2.5.30
[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 _0xcd2f=['setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','../../mysqldb','WhatsappMessage','setMaxListeners','save','update','remove','getUsers','then'];(function(_0x3ab51d,_0x2fa01d){var _0x29a04e=function(_0x7807b0){while(--_0x7807b0){_0x3ab51d['push'](_0x3ab51d['shift']());}};_0x29a04e(++_0x2fa01d);}(_0xcd2f,0xf8));var _0xfcd2=function(_0x16d10f,_0x2ba2d5){_0x16d10f=_0x16d10f-0x0;var _0x50c823=_0xcd2f[_0x16d10f];return _0x50c823;};'use strict';var EventEmitter=require('events');var WhatsappInteraction=require('../../mysqldb')['db']['WhatsappInteraction'];var WhatsappMessage=require(_0xfcd2('0x0'))['db'][_0xfcd2('0x1')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xfcd2('0x2')](0x0);var events={'afterCreate':_0xfcd2('0x3'),'afterUpdate':_0xfcd2('0x4'),'afterDestroy':_0xfcd2('0x5')};function emitEvent(_0x8a26c){return function(_0x11562c,_0x4efae2,_0x108480){_0x11562c[_0xfcd2('0x6')]({'attributes':['id'],'raw':!![]})[_0xfcd2('0x7')](function(_0x20ac59){_0x11562c[_0xfcd2('0x8')](_0xfcd2('0x9'),_0x20ac59[_0xfcd2('0xa')](function(_0x46c99b){return{'id':_0x46c99b['id']};}));return WhatsappMessage[_0xfcd2('0xb')]({'where':{'WhatsappInteractionId':_0x11562c['id'],'direction':'in','read':![]},'raw':!![]});})[_0xfcd2('0x7')](function(_0x3c4880){_0x11562c['setDataValue'](_0xfcd2('0xc'),_0x3c4880[_0xfcd2('0xd')]);WhatsappInteractionEvents[_0xfcd2('0xe')](_0x8a26c+':'+_0x11562c['id'],_0x11562c);WhatsappInteractionEvents[_0xfcd2('0xe')](_0x8a26c,_0x11562c);_0x108480(null);})[_0xfcd2('0xf')](_0x108480(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module['exports']=WhatsappInteractionEvents;