Built motion from commit (unavailable).|2.4.18
[motion2.git] / server / api / smsInteraction / smsInteraction.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 _0x7f42=['hook','events','SmsInteraction','../../mysqldb','setMaxListeners','update','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hasOwnProperty'];(function(_0x4799e,_0x1a8e02){var _0x562a32=function(_0x4c02ad){while(--_0x4c02ad){_0x4799e['push'](_0x4799e['shift']());}};_0x562a32(++_0x1a8e02);}(_0x7f42,0x1dd));var _0x27f4=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x7f42[_0x122ef9];return _0x42fba0;};'use strict';var EventEmitter=require(_0x27f4('0x0'));var SmsInteraction=require('../../mysqldb')['db'][_0x27f4('0x1')];var SmsMessage=require(_0x27f4('0x2'))['db']['SmsMessage'];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x27f4('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x27f4('0x4'),'afterDestroy':'remove'};function emitEvent(_0x2ca4b0){return function(_0x55ed40,_0xe8eabe,_0x5c9286){_0x55ed40[_0x27f4('0x5')]({'attributes':['id'],'raw':!![]})[_0x27f4('0x6')](function(_0xd283e2){_0x55ed40[_0x27f4('0x7')](_0x27f4('0x8'),_0xd283e2[_0x27f4('0x9')](function(_0x458687){return{'id':_0x458687['id']};}));return SmsMessage[_0x27f4('0xa')]({'where':{'SmsInteractionId':_0x55ed40['id'],'direction':'in','read':![]},'raw':!![]});})[_0x27f4('0x6')](function(_0x453565){_0x55ed40[_0x27f4('0x7')](_0x27f4('0xb'),_0x453565[_0x27f4('0xc')]);SmsInteractionEvents[_0x27f4('0xd')](_0x2ca4b0+':'+_0x55ed40['id'],_0x55ed40);SmsInteractionEvents[_0x27f4('0xd')](_0x2ca4b0,_0x55ed40);_0x5c9286(null);})[_0x27f4('0xe')](_0x5c9286(null));};}for(var e in events){if(events[_0x27f4('0xf')](e)){var event=events[e];SmsInteraction[_0x27f4('0x10')](e,emitEvent(event));}}module['exports']=SmsInteractionEvents;