72ade57f45ee0f60f263f84f11ec65b726bb74b6
[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 _0xc556=['emit','hasOwnProperty','hook','FaxInteraction','FaxMessage','save','remove','getUsers','setDataValue','map','findAll','then','length'];(function(_0x41068f,_0x350e6f){var _0xff0dd6=function(_0xb5ca81){while(--_0xb5ca81){_0x41068f['push'](_0x41068f['shift']());}};_0xff0dd6(++_0x350e6f);}(_0xc556,0x148));var _0x6c55=function(_0x2726ed,_0x2a146a){_0x2726ed=_0x2726ed-0x0;var _0x40c673=_0xc556[_0x2726ed];return _0x40c673;};'use strict';var EventEmitter=require('events');var FaxInteraction=require('../../mysqldb')['db'][_0x6c55('0x0')];var FaxMessage=require('../../mysqldb')['db'][_0x6c55('0x1')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x6c55('0x2'),'afterUpdate':'update','afterDestroy':_0x6c55('0x3')};function emitEvent(_0x150977){return function(_0x570c06,_0x45486b,_0x1d2123){_0x570c06[_0x6c55('0x4')]({'attributes':['id'],'raw':!![]})['then'](function(_0x41fe1c){_0x570c06[_0x6c55('0x5')]('Users',_0x41fe1c[_0x6c55('0x6')](function(_0x6cf97c){return{'id':_0x6cf97c['id']};}));return FaxMessage[_0x6c55('0x7')]({'where':{'FaxInteractionId':_0x570c06['id'],'direction':'in','read':![]},'raw':!![]});})[_0x6c55('0x8')](function(_0x5b4242){_0x570c06[_0x6c55('0x5')]('unreadMessages',_0x5b4242[_0x6c55('0x9')]);FaxInteractionEvents['emit'](_0x150977+':'+_0x570c06['id'],_0x570c06);FaxInteractionEvents[_0x6c55('0xa')](_0x150977,_0x570c06);_0x1d2123(null);})['catch'](_0x1d2123(null));};}for(var e in events){if(events[_0x6c55('0xb')](e)){var event=events[e];FaxInteraction[_0x6c55('0xc')](e,emitEvent(event));}}module['exports']=FaxInteractionEvents;