b2fb54484097381df15ee4ef9a9ce9054f370b67
[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 _0xbcc2=['catch','hasOwnProperty','hook','exports','FaxInteraction','../../mysqldb','FaxMessage','setMaxListeners','update','getUsers','then','setDataValue','Users','findAll','emit'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xbcc2,0x1c6));var _0x2bcc=function(_0x50c0b4,_0x157db4){_0x50c0b4=_0x50c0b4-0x0;var _0x4a588e=_0xbcc2[_0x50c0b4];return _0x4a588e;};'use strict';var EventEmitter=require('events');var FaxInteraction=require('../../mysqldb')['db'][_0x2bcc('0x0')];var FaxMessage=require(_0x2bcc('0x1'))['db'][_0x2bcc('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0x2bcc('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x2bcc('0x4'),'afterDestroy':'remove'};function emitEvent(_0x2c3003){return function(_0x5e607a,_0x556cfe,_0x118011){_0x5e607a[_0x2bcc('0x5')]({'attributes':['id'],'raw':!![]})[_0x2bcc('0x6')](function(_0x204465){_0x5e607a[_0x2bcc('0x7')](_0x2bcc('0x8'),_0x204465['map'](function(_0x5cc4f6){return{'id':_0x5cc4f6['id']};}));return FaxMessage[_0x2bcc('0x9')]({'where':{'FaxInteractionId':_0x5e607a['id'],'direction':'in','read':![]},'raw':!![]});})[_0x2bcc('0x6')](function(_0x52a614){_0x5e607a[_0x2bcc('0x7')]('unreadMessages',_0x52a614['length']);FaxInteractionEvents[_0x2bcc('0xa')](_0x2c3003+':'+_0x5e607a['id'],_0x5e607a);FaxInteractionEvents[_0x2bcc('0xa')](_0x2c3003,_0x5e607a);_0x118011(null);})[_0x2bcc('0xb')](_0x118011(null));};}for(var e in events){if(events[_0x2bcc('0xc')](e)){var event=events[e];FaxInteraction[_0x2bcc('0xd')](e,emitEvent(event));}}module[_0x2bcc('0xe')]=FaxInteractionEvents;