Built motion from commit 9d1906d1.|2.5.40
[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 _0xd11e=['hasOwnProperty','hook','exports','../../mysqldb','FaxInteraction','FaxMessage','setMaxListeners','remove','getUsers','then','setDataValue','map','findAll','length','emit'];(function(_0x284181,_0x1a6e29){var _0x2d96cf=function(_0x3202e5){while(--_0x3202e5){_0x284181['push'](_0x284181['shift']());}};_0x2d96cf(++_0x1a6e29);}(_0xd11e,0x111));var _0xed11=function(_0x51a85c,_0x2660a3){_0x51a85c=_0x51a85c-0x0;var _0x55001f=_0xd11e[_0x51a85c];return _0x55001f;};'use strict';var EventEmitter=require('events');var FaxInteraction=require(_0xed11('0x0'))['db'][_0xed11('0x1')];var FaxMessage=require(_0xed11('0x0'))['db'][_0xed11('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xed11('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':_0xed11('0x4')};function emitEvent(_0x4f8b23){return function(_0x45a5db,_0x183cc3,_0x37cf4c){_0x45a5db[_0xed11('0x5')]({'attributes':['id'],'raw':!![]})[_0xed11('0x6')](function(_0x47921c){_0x45a5db[_0xed11('0x7')]('Users',_0x47921c[_0xed11('0x8')](function(_0x340223){return{'id':_0x340223['id']};}));return FaxMessage[_0xed11('0x9')]({'where':{'FaxInteractionId':_0x45a5db['id'],'direction':'in','read':![]},'raw':!![]});})[_0xed11('0x6')](function(_0x1df916){_0x45a5db['setDataValue']('unreadMessages',_0x1df916[_0xed11('0xa')]);FaxInteractionEvents[_0xed11('0xb')](_0x4f8b23+':'+_0x45a5db['id'],_0x45a5db);FaxInteractionEvents[_0xed11('0xb')](_0x4f8b23,_0x45a5db);_0x37cf4c(null);})['catch'](_0x37cf4c(null));};}for(var e in events){if(events[_0xed11('0xc')](e)){var event=events[e];FaxInteraction[_0xed11('0xd')](e,emitEvent(event));}}module[_0xed11('0xe')]=FaxInteractionEvents;