Built motion from commit (unavailable).|2.5.9
[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 _0x2dcc=['MailMessage','setMaxListeners','save','update','Users','findAll','unreadMessages','emit','hasOwnProperty','hook','exports','events','../../mysqldb','MailInteraction'];(function(_0x468293,_0x1b605e){var _0x5eee53=function(_0x18e48e){while(--_0x18e48e){_0x468293['push'](_0x468293['shift']());}};_0x5eee53(++_0x1b605e);}(_0x2dcc,0x185));var _0xc2dc=function(_0x933dd4,_0x1a7d58){_0x933dd4=_0x933dd4-0x0;var _0xa98c20=_0x2dcc[_0x933dd4];return _0xa98c20;};'use strict';var EventEmitter=require(_0xc2dc('0x0'));var MailInteraction=require(_0xc2dc('0x1'))['db'][_0xc2dc('0x2')];var MailMessage=require(_0xc2dc('0x1'))['db'][_0xc2dc('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0xc2dc('0x4')](0x0);var events={'afterCreate':_0xc2dc('0x5'),'afterUpdate':_0xc2dc('0x6'),'afterDestroy':'remove'};function emitEvent(_0xdb4122){return function(_0x31430f,_0x10341b,_0x42208c){_0x31430f['getUsers']({'attributes':['id'],'raw':!![]})['then'](function(_0x26c36b){_0x31430f['setDataValue'](_0xc2dc('0x7'),_0x26c36b['map'](function(_0x427a8a){return{'id':_0x427a8a['id']};}));return MailMessage[_0xc2dc('0x8')]({'where':{'MailInteractionId':_0x31430f['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x27cd4a){_0x31430f['setDataValue'](_0xc2dc('0x9'),_0x27cd4a['length']);MailInteractionEvents[_0xc2dc('0xa')](_0xdb4122+':'+_0x31430f['id'],_0x31430f);MailInteractionEvents['emit'](_0xdb4122,_0x31430f);_0x42208c(null);})['catch'](_0x42208c(null));};}for(var e in events){if(events[_0xc2dc('0xb')](e)){var event=events[e];MailInteraction[_0xc2dc('0xc')](e,emitEvent(event));}}module[_0xc2dc('0xd')]=MailInteractionEvents;