Built motion from commit da617fac.|2.6.6
[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 _0xfb3b=['save','remove','getUsers','Users','map','findAll','then','setDataValue','unreadMessages','emit','catch','hasOwnProperty','hook','events','../../mysqldb','MailInteraction','MailMessage','setMaxListeners'];(function(_0x5be892,_0x68238a){var _0x53fc35=function(_0x8626ac){while(--_0x8626ac){_0x5be892['push'](_0x5be892['shift']());}};_0x53fc35(++_0x68238a);}(_0xfb3b,0x109));var _0xbfb3=function(_0x2b5c66,_0x121174){_0x2b5c66=_0x2b5c66-0x0;var _0x15705a=_0xfb3b[_0x2b5c66];return _0x15705a;};'use strict';var EventEmitter=require(_0xbfb3('0x0'));var MailInteraction=require(_0xbfb3('0x1'))['db'][_0xbfb3('0x2')];var MailMessage=require(_0xbfb3('0x1'))['db'][_0xbfb3('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0xbfb3('0x4')](0x0);var events={'afterCreate':_0xbfb3('0x5'),'afterUpdate':'update','afterDestroy':_0xbfb3('0x6')};function emitEvent(_0xb7d4a4){return function(_0x54426f,_0x36bd53,_0x4ddf3b){_0x54426f[_0xbfb3('0x7')]({'attributes':['id'],'raw':!![]})['then'](function(_0x5f5cea){_0x54426f['setDataValue'](_0xbfb3('0x8'),_0x5f5cea[_0xbfb3('0x9')](function(_0x4c8c5f){return{'id':_0x4c8c5f['id']};}));return MailMessage[_0xbfb3('0xa')]({'where':{'MailInteractionId':_0x54426f['id'],'direction':'in','read':![]},'raw':!![]});})[_0xbfb3('0xb')](function(_0x5dc685){_0x54426f[_0xbfb3('0xc')](_0xbfb3('0xd'),_0x5dc685['length']);MailInteractionEvents['emit'](_0xb7d4a4+':'+_0x54426f['id'],_0x54426f);MailInteractionEvents[_0xbfb3('0xe')](_0xb7d4a4,_0x54426f);_0x4ddf3b(null);})[_0xbfb3('0xf')](_0x4ddf3b(null));};}for(var e in events){if(events[_0xbfb3('0x10')](e)){var event=events[e];MailInteraction[_0xbfb3('0x11')](e,emitEvent(event));}}module['exports']=MailInteractionEvents;