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 _0x82cb=['length','emit','catch','hook','exports','events','../../mysqldb','update','remove','then','Users','map','unreadMessages'];(function(_0x4bacb6,_0x2b299d){var _0x58c029=function(_0x2faaf5){while(--_0x2faaf5){_0x4bacb6['push'](_0x4bacb6['shift']());}};_0x58c029(++_0x2b299d);}(_0x82cb,0x17e));var _0xb82c=function(_0x1e7524,_0x8c137){_0x1e7524=_0x1e7524-0x0;var _0xe6a184=_0x82cb[_0x1e7524];return _0xe6a184;};'use strict';var EventEmitter=require(_0xb82c('0x0'));var MailInteraction=require(_0xb82c('0x1'))['db']['MailInteraction'];var MailMessage=require('../../mysqldb')['db']['MailMessage'];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':_0xb82c('0x2'),'afterDestroy':_0xb82c('0x3')};function emitEvent(_0x3a0f5b){return function(_0x478906,_0x30bf9d,_0x5c2848){_0x478906['getUsers']({'attributes':['id'],'raw':!![]})[_0xb82c('0x4')](function(_0x5a5296){_0x478906['setDataValue'](_0xb82c('0x5'),_0x5a5296[_0xb82c('0x6')](function(_0x3fdd55){return{'id':_0x3fdd55['id']};}));return MailMessage['findAll']({'where':{'MailInteractionId':_0x478906['id'],'direction':'in','read':![]},'raw':!![]});})[_0xb82c('0x4')](function(_0x161863){_0x478906['setDataValue'](_0xb82c('0x7'),_0x161863[_0xb82c('0x8')]);MailInteractionEvents[_0xb82c('0x9')](_0x3a0f5b+':'+_0x478906['id'],_0x478906);MailInteractionEvents[_0xb82c('0x9')](_0x3a0f5b,_0x478906);_0x5c2848(null);})[_0xb82c('0xa')](_0x5c2848(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];MailInteraction[_0xb82c('0xb')](e,emitEvent(event));}}module[_0xb82c('0xc')]=MailInteractionEvents;