Built motion from commit (unavailable).|2.5.6
[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 _0xf2cb=['getUsers','then','setDataValue','map','length','emit','catch','hasOwnProperty','hook','exports','../../mysqldb','setMaxListeners','update','remove'];(function(_0x23e7c1,_0x35110c){var _0x1add43=function(_0x238918){while(--_0x238918){_0x23e7c1['push'](_0x23e7c1['shift']());}};_0x1add43(++_0x35110c);}(_0xf2cb,0x130));var _0xbf2c=function(_0x1c6f70,_0x412b77){_0x1c6f70=_0x1c6f70-0x0;var _0x10fcb8=_0xf2cb[_0x1c6f70];return _0x10fcb8;};'use strict';var EventEmitter=require('events');var SmsInteraction=require(_0xbf2c('0x0'))['db']['SmsInteraction'];var SmsMessage=require(_0xbf2c('0x0'))['db']['SmsMessage'];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0xbf2c('0x1')](0x0);var events={'afterCreate':'save','afterUpdate':_0xbf2c('0x2'),'afterDestroy':_0xbf2c('0x3')};function emitEvent(_0x5abeb3){return function(_0x52cc1a,_0x14b5e4,_0x46d282){_0x52cc1a[_0xbf2c('0x4')]({'attributes':['id'],'raw':!![]})[_0xbf2c('0x5')](function(_0x516715){_0x52cc1a[_0xbf2c('0x6')]('Users',_0x516715[_0xbf2c('0x7')](function(_0x5e070d){return{'id':_0x5e070d['id']};}));return SmsMessage['findAll']({'where':{'SmsInteractionId':_0x52cc1a['id'],'direction':'in','read':![]},'raw':!![]});})[_0xbf2c('0x5')](function(_0x16c303){_0x52cc1a[_0xbf2c('0x6')]('unreadMessages',_0x16c303[_0xbf2c('0x8')]);SmsInteractionEvents[_0xbf2c('0x9')](_0x5abeb3+':'+_0x52cc1a['id'],_0x52cc1a);SmsInteractionEvents[_0xbf2c('0x9')](_0x5abeb3,_0x52cc1a);_0x46d282(null);})[_0xbf2c('0xa')](_0x46d282(null));};}for(var e in events){if(events[_0xbf2c('0xb')](e)){var event=events[e];SmsInteraction[_0xbf2c('0xc')](e,emitEvent(event));}}module[_0xbf2c('0xd')]=SmsInteractionEvents;