Built motion from commit fe909640.|2.6.8
[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 _0xf3cf=['then','setDataValue','Users','map','findAll','emit','catch','hasOwnProperty','exports','events','../../mysqldb','FaxMessage','save','update','getUsers'];(function(_0x155581,_0x1e443e){var _0x552a91=function(_0x37b9d2){while(--_0x37b9d2){_0x155581['push'](_0x155581['shift']());}};_0x552a91(++_0x1e443e);}(_0xf3cf,0x81));var _0xff3c=function(_0x257642,_0x270a80){_0x257642=_0x257642-0x0;var _0x3d813b=_0xf3cf[_0x257642];return _0x3d813b;};'use strict';var EventEmitter=require(_0xff3c('0x0'));var FaxInteraction=require(_0xff3c('0x1'))['db']['FaxInteraction'];var FaxMessage=require('../../mysqldb')['db'][_0xff3c('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xff3c('0x3'),'afterUpdate':_0xff3c('0x4'),'afterDestroy':'remove'};function emitEvent(_0x3f82ef){return function(_0x5f4fa3,_0x4fb1ed,_0xe95c76){_0x5f4fa3[_0xff3c('0x5')]({'attributes':['id'],'raw':!![]})[_0xff3c('0x6')](function(_0x42ffdd){_0x5f4fa3[_0xff3c('0x7')](_0xff3c('0x8'),_0x42ffdd[_0xff3c('0x9')](function(_0x2c0977){return{'id':_0x2c0977['id']};}));return FaxMessage[_0xff3c('0xa')]({'where':{'FaxInteractionId':_0x5f4fa3['id'],'direction':'in','read':![]},'raw':!![]});})[_0xff3c('0x6')](function(_0x1b87d1){_0x5f4fa3[_0xff3c('0x7')]('unreadMessages',_0x1b87d1['length']);FaxInteractionEvents[_0xff3c('0xb')](_0x3f82ef+':'+_0x5f4fa3['id'],_0x5f4fa3);FaxInteractionEvents[_0xff3c('0xb')](_0x3f82ef,_0x5f4fa3);_0xe95c76(null);})[_0xff3c('0xc')](_0xe95c76(null));};}for(var e in events){if(events[_0xff3c('0xd')](e)){var event=events[e];FaxInteraction['hook'](e,emitEvent(event));}}module[_0xff3c('0xe')]=FaxInteractionEvents;