Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / faxInteraction / faxInteraction.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 _0xa486=['length','emit','catch','exports','events','../../mysqldb','FaxInteraction','FaxMessage','save','update','remove','getUsers','setDataValue','map','then','unreadMessages'];(function(_0x5982d8,_0x5688bd){var _0x41ded4=function(_0x6c79cc){while(--_0x6c79cc){_0x5982d8['push'](_0x5982d8['shift']());}};_0x41ded4(++_0x5688bd);}(_0xa486,0xc4));var _0x6a48=function(_0x28210a,_0x35774a){_0x28210a=_0x28210a-0x0;var _0xdd05a8=_0xa486[_0x28210a];return _0xdd05a8;};'use strict';var EventEmitter=require(_0x6a48('0x0'));var FaxInteraction=require(_0x6a48('0x1'))['db'][_0x6a48('0x2')];var FaxMessage=require(_0x6a48('0x1'))['db'][_0x6a48('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x6a48('0x4'),'afterUpdate':_0x6a48('0x5'),'afterDestroy':_0x6a48('0x6')};function emitEvent(_0xf3678d){return function(_0x49841c,_0x3f9e4a,_0x1e2d58){_0x49841c[_0x6a48('0x7')]({'attributes':['id'],'raw':!![]})['then'](function(_0x9edc29){_0x49841c[_0x6a48('0x8')]('Users',_0x9edc29[_0x6a48('0x9')](function(_0x48824a){return{'id':_0x48824a['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0x49841c['id'],'direction':'in','read':![]},'raw':!![]});})[_0x6a48('0xa')](function(_0x381d45){_0x49841c[_0x6a48('0x8')](_0x6a48('0xb'),_0x381d45[_0x6a48('0xc')]);FaxInteractionEvents['emit'](_0xf3678d+':'+_0x49841c['id'],_0x49841c);FaxInteractionEvents[_0x6a48('0xd')](_0xf3678d,_0x49841c);_0x1e2d58(null);})[_0x6a48('0xe')](_0x1e2d58(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];FaxInteraction['hook'](e,emitEvent(event));}}module[_0x6a48('0xf')]=FaxInteractionEvents;