Built motion from commit (unavailable).|2.5.22
[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 _0x106f=['hook','exports','events','../../mysqldb','SmsMessage','save','remove','getUsers','then','setDataValue','Users','unreadMessages','length','emit','catch','hasOwnProperty'];(function(_0x3ccf60,_0x34d01d){var _0x46c4e3=function(_0x2cd6d2){while(--_0x2cd6d2){_0x3ccf60['push'](_0x3ccf60['shift']());}};_0x46c4e3(++_0x34d01d);}(_0x106f,0x162));var _0xf106=function(_0x5108bd,_0x201ae2){_0x5108bd=_0x5108bd-0x0;var _0x1ec98a=_0x106f[_0x5108bd];return _0x1ec98a;};'use strict';var EventEmitter=require(_0xf106('0x0'));var SmsInteraction=require(_0xf106('0x1'))['db']['SmsInteraction'];var SmsMessage=require(_0xf106('0x1'))['db'][_0xf106('0x2')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xf106('0x3'),'afterUpdate':'update','afterDestroy':_0xf106('0x4')};function emitEvent(_0x370f6a){return function(_0x1f2919,_0x318376,_0x253f6d){_0x1f2919[_0xf106('0x5')]({'attributes':['id'],'raw':!![]})[_0xf106('0x6')](function(_0x546acc){_0x1f2919[_0xf106('0x7')](_0xf106('0x8'),_0x546acc['map'](function(_0x4a35bc){return{'id':_0x4a35bc['id']};}));return SmsMessage['findAll']({'where':{'SmsInteractionId':_0x1f2919['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x52befe){_0x1f2919[_0xf106('0x7')](_0xf106('0x9'),_0x52befe[_0xf106('0xa')]);SmsInteractionEvents[_0xf106('0xb')](_0x370f6a+':'+_0x1f2919['id'],_0x1f2919);SmsInteractionEvents[_0xf106('0xb')](_0x370f6a,_0x1f2919);_0x253f6d(null);})[_0xf106('0xc')](_0x253f6d(null));};}for(var e in events){if(events[_0xf106('0xd')](e)){var event=events[e];SmsInteraction[_0xf106('0xe')](e,emitEvent(event));}}module[_0xf106('0xf')]=SmsInteractionEvents;