Built motion from commit 97153652.|2.6.26
[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 _0x174b=['findAll','unreadMessages','emit','catch','hasOwnProperty','hook','exports','../../mysqldb','FaxInteraction','setMaxListeners','update','remove','getUsers','then','setDataValue','map'];(function(_0x2d1bea,_0xc06ab9){var _0x29060d=function(_0x23a8df){while(--_0x23a8df){_0x2d1bea['push'](_0x2d1bea['shift']());}};_0x29060d(++_0xc06ab9);}(_0x174b,0xa7));var _0xb174=function(_0x5d0fa8,_0x1931b4){_0x5d0fa8=_0x5d0fa8-0x0;var _0x3c9292=_0x174b[_0x5d0fa8];return _0x3c9292;};'use strict';var EventEmitter=require('events');var FaxInteraction=require(_0xb174('0x0'))['db'][_0xb174('0x1')];var FaxMessage=require(_0xb174('0x0'))['db']['FaxMessage'];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xb174('0x2')](0x0);var events={'afterCreate':'save','afterUpdate':_0xb174('0x3'),'afterDestroy':_0xb174('0x4')};function emitEvent(_0x3f1e6c){return function(_0x4b2040,_0x474334,_0x31af2c){_0x4b2040[_0xb174('0x5')]({'attributes':['id'],'raw':!![]})[_0xb174('0x6')](function(_0x5b01ef){_0x4b2040[_0xb174('0x7')]('Users',_0x5b01ef[_0xb174('0x8')](function(_0x19d1e9){return{'id':_0x19d1e9['id']};}));return FaxMessage[_0xb174('0x9')]({'where':{'FaxInteractionId':_0x4b2040['id'],'direction':'in','read':![]},'raw':!![]});})[_0xb174('0x6')](function(_0x21da46){_0x4b2040[_0xb174('0x7')](_0xb174('0xa'),_0x21da46['length']);FaxInteractionEvents[_0xb174('0xb')](_0x3f1e6c+':'+_0x4b2040['id'],_0x4b2040);FaxInteractionEvents['emit'](_0x3f1e6c,_0x4b2040);_0x31af2c(null);})[_0xb174('0xc')](_0x31af2c(null));};}for(var e in events){if(events[_0xb174('0xd')](e)){var event=events[e];FaxInteraction[_0xb174('0xe')](e,emitEvent(event));}}module[_0xb174('0xf')]=FaxInteractionEvents;