Built motion from commit (unavailable).|2.5.21
[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 _0x5d3b=['../../mysqldb','WhatsappInteraction','WhatsappMessage','setMaxListeners','save','update','remove','getUsers','then','setDataValue','Users','map','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events'];(function(_0x48e49b,_0x3759d3){var _0xc4b149=function(_0x3c3c19){while(--_0x3c3c19){_0x48e49b['push'](_0x48e49b['shift']());}};_0xc4b149(++_0x3759d3);}(_0x5d3b,0x12b));var _0xb5d3=function(_0x7a3f4,_0x1926c7){_0x7a3f4=_0x7a3f4-0x0;var _0x377f7b=_0x5d3b[_0x7a3f4];return _0x377f7b;};'use strict';var EventEmitter=require(_0xb5d3('0x0'));var WhatsappInteraction=require(_0xb5d3('0x1'))['db'][_0xb5d3('0x2')];var WhatsappMessage=require('../../mysqldb')['db'][_0xb5d3('0x3')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0xb5d3('0x4')](0x0);var events={'afterCreate':_0xb5d3('0x5'),'afterUpdate':_0xb5d3('0x6'),'afterDestroy':_0xb5d3('0x7')};function emitEvent(_0x5c3057){return function(_0x5ec093,_0x204a79,_0x45de5e){_0x5ec093[_0xb5d3('0x8')]({'attributes':['id'],'raw':!![]})[_0xb5d3('0x9')](function(_0x225724){_0x5ec093[_0xb5d3('0xa')](_0xb5d3('0xb'),_0x225724[_0xb5d3('0xc')](function(_0x187af5){return{'id':_0x187af5['id']};}));return WhatsappMessage['findAll']({'where':{'WhatsappInteractionId':_0x5ec093['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x2bd177){_0x5ec093[_0xb5d3('0xa')](_0xb5d3('0xd'),_0x2bd177[_0xb5d3('0xe')]);WhatsappInteractionEvents['emit'](_0x5c3057+':'+_0x5ec093['id'],_0x5ec093);WhatsappInteractionEvents[_0xb5d3('0xf')](_0x5c3057,_0x5ec093);_0x45de5e(null);})[_0xb5d3('0x10')](_0x45de5e(null));};}for(var e in events){if(events[_0xb5d3('0x11')](e)){var event=events[e];WhatsappInteraction[_0xb5d3('0x12')](e,emitEvent(event));}}module[_0xb5d3('0x13')]=WhatsappInteractionEvents;