Built motion from commit 4c281f94.|2.6.31
[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 _0x2f0e=['save','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','../../mysqldb','MailInteraction','setMaxListeners'];(function(_0x183fbc,_0x22707d){var _0x43f528=function(_0x21870c){while(--_0x21870c){_0x183fbc['push'](_0x183fbc['shift']());}};_0x43f528(++_0x22707d);}(_0x2f0e,0x165));var _0xe2f0=function(_0x1fdb0e,_0x3bc470){_0x1fdb0e=_0x1fdb0e-0x0;var _0x3404b7=_0x2f0e[_0x1fdb0e];return _0x3404b7;};'use strict';var EventEmitter=require('events');var MailInteraction=require(_0xe2f0('0x0'))['db'][_0xe2f0('0x1')];var MailMessage=require('../../mysqldb')['db']['MailMessage'];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0xe2f0('0x2')](0x0);var events={'afterCreate':_0xe2f0('0x3'),'afterUpdate':'update','afterDestroy':_0xe2f0('0x4')};function emitEvent(_0x4176cb){return function(_0x10b32e,_0x305bf6,_0x14ad33){_0x10b32e[_0xe2f0('0x5')]({'attributes':['id'],'raw':!![]})[_0xe2f0('0x6')](function(_0x143030){_0x10b32e[_0xe2f0('0x7')](_0xe2f0('0x8'),_0x143030[_0xe2f0('0x9')](function(_0x584faa){return{'id':_0x584faa['id']};}));return MailMessage[_0xe2f0('0xa')]({'where':{'MailInteractionId':_0x10b32e['id'],'direction':'in','read':![]},'raw':!![]});})[_0xe2f0('0x6')](function(_0x68172a){_0x10b32e[_0xe2f0('0x7')](_0xe2f0('0xb'),_0x68172a[_0xe2f0('0xc')]);MailInteractionEvents[_0xe2f0('0xd')](_0x4176cb+':'+_0x10b32e['id'],_0x10b32e);MailInteractionEvents[_0xe2f0('0xd')](_0x4176cb,_0x10b32e);_0x14ad33(null);})[_0xe2f0('0xe')](_0x14ad33(null));};}for(var e in events){if(events[_0xe2f0('0xf')](e)){var event=events[e];MailInteraction[_0xe2f0('0x10')](e,emitEvent(event));}}module[_0xe2f0('0x11')]=MailInteractionEvents;