Built motion from commit (unavailable).|2.5.0
[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 _0x689f=['../../mysqldb','MailInteraction','MailMessage','save','update','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','emit','catch','hasOwnProperty','hook','exports','events'];(function(_0x100e36,_0x4da225){var _0x1df0c9=function(_0xe4b84f){while(--_0xe4b84f){_0x100e36['push'](_0x100e36['shift']());}};_0x1df0c9(++_0x4da225);}(_0x689f,0x18e));var _0xf689=function(_0x3c9bc6,_0x36f624){_0x3c9bc6=_0x3c9bc6-0x0;var _0x8e1377=_0x689f[_0x3c9bc6];return _0x8e1377;};'use strict';var EventEmitter=require(_0xf689('0x0'));var MailInteraction=require(_0xf689('0x1'))['db'][_0xf689('0x2')];var MailMessage=require(_0xf689('0x1'))['db'][_0xf689('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xf689('0x4'),'afterUpdate':_0xf689('0x5'),'afterDestroy':_0xf689('0x6')};function emitEvent(_0x1989ee){return function(_0x3e4c9b,_0x8850e8,_0x59912a){_0x3e4c9b[_0xf689('0x7')]({'attributes':['id'],'raw':!![]})[_0xf689('0x8')](function(_0x8e3e06){_0x3e4c9b[_0xf689('0x9')](_0xf689('0xa'),_0x8e3e06[_0xf689('0xb')](function(_0xdb14b0){return{'id':_0xdb14b0['id']};}));return MailMessage[_0xf689('0xc')]({'where':{'MailInteractionId':_0x3e4c9b['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf689('0x8')](function(_0x164143){_0x3e4c9b[_0xf689('0x9')](_0xf689('0xd'),_0x164143['length']);MailInteractionEvents['emit'](_0x1989ee+':'+_0x3e4c9b['id'],_0x3e4c9b);MailInteractionEvents[_0xf689('0xe')](_0x1989ee,_0x3e4c9b);_0x59912a(null);})[_0xf689('0xf')](_0x59912a(null));};}for(var e in events){if(events[_0xf689('0x10')](e)){var event=events[e];MailInteraction[_0xf689('0x11')](e,emitEvent(event));}}module[_0xf689('0x12')]=MailInteractionEvents;