bf681eab5217bd22a58c9ed8083eb2bdba5a97de
[motion2.git] / server / api / mailInteraction / mailInteraction.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 _0xd88b=['setDataValue','Users','findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','../../mysqldb','MailInteraction','MailMessage','save','remove','getUsers','then'];(function(_0x2242c1,_0x43e73){var _0x227732=function(_0x135910){while(--_0x135910){_0x2242c1['push'](_0x2242c1['shift']());}};_0x227732(++_0x43e73);}(_0xd88b,0xd9));var _0xbd88=function(_0x34f710,_0xa5da93){_0x34f710=_0x34f710-0x0;var _0x5a3bc2=_0xd88b[_0x34f710];return _0x5a3bc2;};'use strict';var EventEmitter=require('events');var MailInteraction=require(_0xbd88('0x0'))['db'][_0xbd88('0x1')];var MailMessage=require(_0xbd88('0x0'))['db'][_0xbd88('0x2')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xbd88('0x3'),'afterUpdate':'update','afterDestroy':_0xbd88('0x4')};function emitEvent(_0x581b7c){return function(_0x1fc478,_0x5a0fc3,_0x4afab6){_0x1fc478[_0xbd88('0x5')]({'attributes':['id'],'raw':!![]})[_0xbd88('0x6')](function(_0x36b6b3){_0x1fc478[_0xbd88('0x7')](_0xbd88('0x8'),_0x36b6b3['map'](function(_0x3d4963){return{'id':_0x3d4963['id']};}));return MailMessage[_0xbd88('0x9')]({'where':{'MailInteractionId':_0x1fc478['id'],'direction':'in','read':![]},'raw':!![]});})[_0xbd88('0x6')](function(_0x1158f2){_0x1fc478[_0xbd88('0x7')](_0xbd88('0xa'),_0x1158f2[_0xbd88('0xb')]);MailInteractionEvents[_0xbd88('0xc')](_0x581b7c+':'+_0x1fc478['id'],_0x1fc478);MailInteractionEvents[_0xbd88('0xc')](_0x581b7c,_0x1fc478);_0x4afab6(null);})[_0xbd88('0xd')](_0x4afab6(null));};}for(var e in events){if(events[_0xbd88('0xe')](e)){var event=events[e];MailInteraction[_0xbd88('0xf')](e,emitEvent(event));}}module['exports']=MailInteractionEvents;