Built motion from commit 6a09e18b.|2.6.11
[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 _0xc2cd=['findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','MailInteraction','MailMessage','save','update','remove','getUsers','then','setDataValue','Users','map'];(function(_0x3ba924,_0x3b99f0){var _0x4cc1df=function(_0x15bf28){while(--_0x15bf28){_0x3ba924['push'](_0x3ba924['shift']());}};_0x4cc1df(++_0x3b99f0);}(_0xc2cd,0xbc));var _0xdc2c=function(_0x21d21a,_0x46e269){_0x21d21a=_0x21d21a-0x0;var _0x52387d=_0xc2cd[_0x21d21a];return _0x52387d;};'use strict';var EventEmitter=require(_0xdc2c('0x0'));var MailInteraction=require(_0xdc2c('0x1'))['db'][_0xdc2c('0x2')];var MailMessage=require(_0xdc2c('0x1'))['db'][_0xdc2c('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xdc2c('0x4'),'afterUpdate':_0xdc2c('0x5'),'afterDestroy':_0xdc2c('0x6')};function emitEvent(_0x456b69){return function(_0x3e6abf,_0x352aaa,_0x39f1d2){_0x3e6abf[_0xdc2c('0x7')]({'attributes':['id'],'raw':!![]})[_0xdc2c('0x8')](function(_0x52910c){_0x3e6abf[_0xdc2c('0x9')](_0xdc2c('0xa'),_0x52910c[_0xdc2c('0xb')](function(_0x59f17e){return{'id':_0x59f17e['id']};}));return MailMessage[_0xdc2c('0xc')]({'where':{'MailInteractionId':_0x3e6abf['id'],'direction':'in','read':![]},'raw':!![]});})[_0xdc2c('0x8')](function(_0x537831){_0x3e6abf[_0xdc2c('0x9')](_0xdc2c('0xd'),_0x537831[_0xdc2c('0xe')]);MailInteractionEvents[_0xdc2c('0xf')](_0x456b69+':'+_0x3e6abf['id'],_0x3e6abf);MailInteractionEvents[_0xdc2c('0xf')](_0x456b69,_0x3e6abf);_0x39f1d2(null);})[_0xdc2c('0x10')](_0x39f1d2(null));};}for(var e in events){if(events[_0xdc2c('0x11')](e)){var event=events[e];MailInteraction[_0xdc2c('0x12')](e,emitEvent(event));}}module[_0xdc2c('0x13')]=MailInteractionEvents;