1 // *************************************************************************
3 // * xCALLY Motion - The Omnichannel Contact Center *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved *
6 // *************************************************************************
8 // * Email: info@xcally.com *
9 // * Website: https://www.xcally.com *
11 // *************************************************************************
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. *
17 // *************************************************************************
18 var _0x6a67=['events','MailInteraction','../../mysqldb','MailMessage','setMaxListeners','save','remove','getUsers','then','setDataValue','Users','findAll','length','emit','hook','exports'];(function(_0x29b609,_0x19d388){var _0x54c952=function(_0xb3c38d){while(--_0xb3c38d){_0x29b609['push'](_0x29b609['shift']());}};_0x54c952(++_0x19d388);}(_0x6a67,0x90));var _0x76a6=function(_0x324661,_0x3fb798){_0x324661=_0x324661-0x0;var _0x135bed=_0x6a67[_0x324661];return _0x135bed;};'use strict';var EventEmitter=require(_0x76a6('0x0'));var MailInteraction=require('../../mysqldb')['db'][_0x76a6('0x1')];var MailMessage=require(_0x76a6('0x2'))['db'][_0x76a6('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0x76a6('0x4')](0x0);var events={'afterCreate':_0x76a6('0x5'),'afterUpdate':'update','afterDestroy':_0x76a6('0x6')};function emitEvent(_0x2408e5){return function(_0x2ca1bd,_0x39f815,_0x57a0fb){_0x2ca1bd[_0x76a6('0x7')]({'attributes':['id'],'raw':!![]})[_0x76a6('0x8')](function(_0x20b1e3){_0x2ca1bd[_0x76a6('0x9')](_0x76a6('0xa'),_0x20b1e3['map'](function(_0x2a9e73){return{'id':_0x2a9e73['id']};}));return MailMessage[_0x76a6('0xb')]({'where':{'MailInteractionId':_0x2ca1bd['id'],'direction':'in','read':![]},'raw':!![]});})[_0x76a6('0x8')](function(_0x1c272c){_0x2ca1bd['setDataValue']('unreadMessages',_0x1c272c[_0x76a6('0xc')]);MailInteractionEvents[_0x76a6('0xd')](_0x2408e5+':'+_0x2ca1bd['id'],_0x2ca1bd);MailInteractionEvents[_0x76a6('0xd')](_0x2408e5,_0x2ca1bd);_0x57a0fb(null);})['catch'](_0x57a0fb(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];MailInteraction[_0x76a6('0xe')](e,emitEvent(event));}}module[_0x76a6('0xf')]=MailInteractionEvents;