Built motion from commit 14588770.|2.5.38
[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 _0x24c5=['then','setDataValue','Users','unreadMessages','length','emit','catch','hasOwnProperty','exports','events','../../mysqldb','MailInteraction','MailMessage','setMaxListeners','save','remove','getUsers'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x24c5,0xf7));var _0x524c=function(_0x3f6f2f,_0xa6b126){_0x3f6f2f=_0x3f6f2f-0x0;var _0x35b6f6=_0x24c5[_0x3f6f2f];return _0x35b6f6;};'use strict';var EventEmitter=require(_0x524c('0x0'));var MailInteraction=require(_0x524c('0x1'))['db'][_0x524c('0x2')];var MailMessage=require(_0x524c('0x1'))['db'][_0x524c('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0x524c('0x4')](0x0);var events={'afterCreate':_0x524c('0x5'),'afterUpdate':'update','afterDestroy':_0x524c('0x6')};function emitEvent(_0x1bf9d7){return function(_0x2dd7e0,_0x4797ca,_0x11edae){_0x2dd7e0[_0x524c('0x7')]({'attributes':['id'],'raw':!![]})[_0x524c('0x8')](function(_0x3e834f){_0x2dd7e0[_0x524c('0x9')](_0x524c('0xa'),_0x3e834f['map'](function(_0x2948f7){return{'id':_0x2948f7['id']};}));return MailMessage['findAll']({'where':{'MailInteractionId':_0x2dd7e0['id'],'direction':'in','read':![]},'raw':!![]});})[_0x524c('0x8')](function(_0x14b93f){_0x2dd7e0[_0x524c('0x9')](_0x524c('0xb'),_0x14b93f[_0x524c('0xc')]);MailInteractionEvents[_0x524c('0xd')](_0x1bf9d7+':'+_0x2dd7e0['id'],_0x2dd7e0);MailInteractionEvents[_0x524c('0xd')](_0x1bf9d7,_0x2dd7e0);_0x11edae(null);})[_0x524c('0xe')](_0x11edae(null));};}for(var e in events){if(events[_0x524c('0xf')](e)){var event=events[e];MailInteraction['hook'](e,emitEvent(event));}}module[_0x524c('0x10')]=MailInteractionEvents;