Built motion from commit (unavailable).|2.5.26
[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 _0xe0c3=['findAll','emit','catch','hasOwnProperty','hook','exports','events','SmsInteraction','../../mysqldb','SmsMessage','setMaxListeners','save','update','remove','getUsers','then','setDataValue','Users','map'];(function(_0x6e2052,_0x10b0f9){var _0x2197f2=function(_0x329893){while(--_0x329893){_0x6e2052['push'](_0x6e2052['shift']());}};_0x2197f2(++_0x10b0f9);}(_0xe0c3,0xea));var _0x3e0c=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xe0c3[_0x321bb2];return _0x9c12ed;};'use strict';var EventEmitter=require(_0x3e0c('0x0'));var SmsInteraction=require('../../mysqldb')['db'][_0x3e0c('0x1')];var SmsMessage=require(_0x3e0c('0x2'))['db'][_0x3e0c('0x3')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x3e0c('0x4')](0x0);var events={'afterCreate':_0x3e0c('0x5'),'afterUpdate':_0x3e0c('0x6'),'afterDestroy':_0x3e0c('0x7')};function emitEvent(_0x26c964){return function(_0x1a026f,_0x511cfa,_0x530ebf){_0x1a026f[_0x3e0c('0x8')]({'attributes':['id'],'raw':!![]})[_0x3e0c('0x9')](function(_0x3f6607){_0x1a026f[_0x3e0c('0xa')](_0x3e0c('0xb'),_0x3f6607[_0x3e0c('0xc')](function(_0x1dbe0f){return{'id':_0x1dbe0f['id']};}));return SmsMessage[_0x3e0c('0xd')]({'where':{'SmsInteractionId':_0x1a026f['id'],'direction':'in','read':![]},'raw':!![]});})[_0x3e0c('0x9')](function(_0x35d56f){_0x1a026f[_0x3e0c('0xa')]('unreadMessages',_0x35d56f['length']);SmsInteractionEvents[_0x3e0c('0xe')](_0x26c964+':'+_0x1a026f['id'],_0x1a026f);SmsInteractionEvents[_0x3e0c('0xe')](_0x26c964,_0x1a026f);_0x530ebf(null);})[_0x3e0c('0xf')](_0x530ebf(null));};}for(var e in events){if(events[_0x3e0c('0x10')](e)){var event=events[e];SmsInteraction[_0x3e0c('0x11')](e,emitEvent(event));}}module[_0x3e0c('0x12')]=SmsInteractionEvents;