1a4d8e2cad351e7e53b0a6d99acbb7f78120a4b9
[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 _0xfc76=['exports','../../mysqldb','SmsInteraction','SmsMessage','setMaxListeners','update','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hook'];(function(_0x215e65,_0x183f97){var _0xa85842=function(_0x43bf45){while(--_0x43bf45){_0x215e65['push'](_0x215e65['shift']());}};_0xa85842(++_0x183f97);}(_0xfc76,0xb5));var _0x6fc7=function(_0x45b138,_0x1b2d4b){_0x45b138=_0x45b138-0x0;var _0x1f3dd2=_0xfc76[_0x45b138];return _0x1f3dd2;};'use strict';var EventEmitter=require('events');var SmsInteraction=require(_0x6fc7('0x0'))['db'][_0x6fc7('0x1')];var SmsMessage=require(_0x6fc7('0x0'))['db'][_0x6fc7('0x2')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x6fc7('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x6fc7('0x4'),'afterDestroy':_0x6fc7('0x5')};function emitEvent(_0x51280c){return function(_0x13f682,_0x51cb40,_0xe8177b){_0x13f682[_0x6fc7('0x6')]({'attributes':['id'],'raw':!![]})[_0x6fc7('0x7')](function(_0x4da7c3){_0x13f682[_0x6fc7('0x8')](_0x6fc7('0x9'),_0x4da7c3[_0x6fc7('0xa')](function(_0x1d4fee){return{'id':_0x1d4fee['id']};}));return SmsMessage[_0x6fc7('0xb')]({'where':{'SmsInteractionId':_0x13f682['id'],'direction':'in','read':![]},'raw':!![]});})[_0x6fc7('0x7')](function(_0x4de75e){_0x13f682[_0x6fc7('0x8')](_0x6fc7('0xc'),_0x4de75e[_0x6fc7('0xd')]);SmsInteractionEvents[_0x6fc7('0xe')](_0x51280c+':'+_0x13f682['id'],_0x13f682);SmsInteractionEvents[_0x6fc7('0xe')](_0x51280c,_0x13f682);_0xe8177b(null);})[_0x6fc7('0xf')](_0xe8177b(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];SmsInteraction[_0x6fc7('0x10')](e,emitEvent(event));}}module[_0x6fc7('0x11')]=SmsInteractionEvents;