Built motion from commit 775e2a94.|2.6.3
[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 _0xc091=['save','update','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hook','exports','events','../../mysqldb','MailInteraction','MailMessage','setMaxListeners'];(function(_0x5987e5,_0x5ebbc5){var _0x5c99fe=function(_0x320b33){while(--_0x320b33){_0x5987e5['push'](_0x5987e5['shift']());}};_0x5c99fe(++_0x5ebbc5);}(_0xc091,0x1b3));var _0x1c09=function(_0x31ad68,_0x20968a){_0x31ad68=_0x31ad68-0x0;var _0x5270c5=_0xc091[_0x31ad68];return _0x5270c5;};'use strict';var EventEmitter=require(_0x1c09('0x0'));var MailInteraction=require(_0x1c09('0x1'))['db'][_0x1c09('0x2')];var MailMessage=require(_0x1c09('0x1'))['db'][_0x1c09('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0x1c09('0x4')](0x0);var events={'afterCreate':_0x1c09('0x5'),'afterUpdate':_0x1c09('0x6'),'afterDestroy':_0x1c09('0x7')};function emitEvent(_0xb13de3){return function(_0x420047,_0xb79c75,_0x23669e){_0x420047[_0x1c09('0x8')]({'attributes':['id'],'raw':!![]})[_0x1c09('0x9')](function(_0x21aa9e){_0x420047[_0x1c09('0xa')](_0x1c09('0xb'),_0x21aa9e[_0x1c09('0xc')](function(_0x2e47bb){return{'id':_0x2e47bb['id']};}));return MailMessage[_0x1c09('0xd')]({'where':{'MailInteractionId':_0x420047['id'],'direction':'in','read':![]},'raw':!![]});})[_0x1c09('0x9')](function(_0x1d55c6){_0x420047[_0x1c09('0xa')](_0x1c09('0xe'),_0x1d55c6[_0x1c09('0xf')]);MailInteractionEvents[_0x1c09('0x10')](_0xb13de3+':'+_0x420047['id'],_0x420047);MailInteractionEvents[_0x1c09('0x10')](_0xb13de3,_0x420047);_0x23669e(null);})[_0x1c09('0x11')](_0x23669e(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];MailInteraction[_0x1c09('0x12')](e,emitEvent(event));}}module[_0x1c09('0x13')]=MailInteractionEvents;