Built motion from commit f7863d46.|2.5.41
[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 _0x2929=['FaxMessage','setMaxListeners','update','remove','getUsers','Users','map','findAll','unreadMessages','length','catch','hasOwnProperty','hook','exports','../../mysqldb','FaxInteraction'];(function(_0x376b45,_0x5964fb){var _0x2341b3=function(_0x5a7f01){while(--_0x5a7f01){_0x376b45['push'](_0x376b45['shift']());}};_0x2341b3(++_0x5964fb);}(_0x2929,0x11e));var _0x9292=function(_0x3fed23,_0x1cb22c){_0x3fed23=_0x3fed23-0x0;var _0x4e6646=_0x2929[_0x3fed23];return _0x4e6646;};'use strict';var EventEmitter=require('events');var FaxInteraction=require(_0x9292('0x0'))['db'][_0x9292('0x1')];var FaxMessage=require(_0x9292('0x0'))['db'][_0x9292('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x9292('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x9292('0x4'),'afterDestroy':_0x9292('0x5')};function emitEvent(_0x1a93d1){return function(_0x42b281,_0x16fff7,_0x3ae6b1){_0x42b281[_0x9292('0x6')]({'attributes':['id'],'raw':!![]})['then'](function(_0x37c3c){_0x42b281['setDataValue'](_0x9292('0x7'),_0x37c3c[_0x9292('0x8')](function(_0xbea0cd){return{'id':_0xbea0cd['id']};}));return FaxMessage[_0x9292('0x9')]({'where':{'FaxInteractionId':_0x42b281['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x232c20){_0x42b281['setDataValue'](_0x9292('0xa'),_0x232c20[_0x9292('0xb')]);FaxInteractionEvents['emit'](_0x1a93d1+':'+_0x42b281['id'],_0x42b281);FaxInteractionEvents['emit'](_0x1a93d1,_0x42b281);_0x3ae6b1(null);})[_0x9292('0xc')](_0x3ae6b1(null));};}for(var e in events){if(events[_0x9292('0xd')](e)){var event=events[e];FaxInteraction[_0x9292('0xe')](e,emitEvent(event));}}module[_0x9292('0xf')]=FaxInteractionEvents;