f4cabb8db22507e50f89e2c0375e430c8b635d61
[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 _0xf7f4=['getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','events','../../mysqldb','MailInteraction','MailMessage','remove'];(function(_0x4c5c97,_0x4f85bf){var _0xd5d2cb=function(_0x1e6100){while(--_0x1e6100){_0x4c5c97['push'](_0x4c5c97['shift']());}};_0xd5d2cb(++_0x4f85bf);}(_0xf7f4,0x94));var _0x4f7f=function(_0x491612,_0x38c4da){_0x491612=_0x491612-0x0;var _0x3c6d4a=_0xf7f4[_0x491612];return _0x3c6d4a;};'use strict';var EventEmitter=require(_0x4f7f('0x0'));var MailInteraction=require(_0x4f7f('0x1'))['db'][_0x4f7f('0x2')];var MailMessage=require(_0x4f7f('0x1'))['db'][_0x4f7f('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':_0x4f7f('0x4')};function emitEvent(_0x43d6d2){return function(_0x2d72e9,_0x3b71c5,_0x9fa02c){_0x2d72e9[_0x4f7f('0x5')]({'attributes':['id'],'raw':!![]})[_0x4f7f('0x6')](function(_0x4c2480){_0x2d72e9[_0x4f7f('0x7')](_0x4f7f('0x8'),_0x4c2480[_0x4f7f('0x9')](function(_0x519884){return{'id':_0x519884['id']};}));return MailMessage[_0x4f7f('0xa')]({'where':{'MailInteractionId':_0x2d72e9['id'],'direction':'in','read':![]},'raw':!![]});})[_0x4f7f('0x6')](function(_0x1fc3a0){_0x2d72e9[_0x4f7f('0x7')](_0x4f7f('0xb'),_0x1fc3a0[_0x4f7f('0xc')]);MailInteractionEvents['emit'](_0x43d6d2+':'+_0x2d72e9['id'],_0x2d72e9);MailInteractionEvents[_0x4f7f('0xd')](_0x43d6d2,_0x2d72e9);_0x9fa02c(null);})[_0x4f7f('0xe')](_0x9fa02c(null));};}for(var e in events){if(events[_0x4f7f('0xf')](e)){var event=events[e];MailInteraction[_0x4f7f('0x10')](e,emitEvent(event));}}module['exports']=MailInteractionEvents;