Built motion from commit (unavailable).|2.5.15
[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 _0x88f0=['length','emit','catch','hook','exports','events','../../mysqldb','MailInteraction','MailMessage','setMaxListeners','getUsers','then','setDataValue','Users','map','findAll','unreadMessages'];(function(_0x4857c4,_0x3368ea){var _0x53fdf4=function(_0x5b5b88){while(--_0x5b5b88){_0x4857c4['push'](_0x4857c4['shift']());}};_0x53fdf4(++_0x3368ea);}(_0x88f0,0x8d));var _0x088f=function(_0x58a1ef,_0x4938cd){_0x58a1ef=_0x58a1ef-0x0;var _0x384e65=_0x88f0[_0x58a1ef];return _0x384e65;};'use strict';var EventEmitter=require(_0x088f('0x0'));var MailInteraction=require(_0x088f('0x1'))['db'][_0x088f('0x2')];var MailMessage=require(_0x088f('0x1'))['db'][_0x088f('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0x088f('0x4')](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':'remove'};function emitEvent(_0x4cec7d){return function(_0x30ba4d,_0x4c1e84,_0x2abad3){_0x30ba4d[_0x088f('0x5')]({'attributes':['id'],'raw':!![]})[_0x088f('0x6')](function(_0x23c214){_0x30ba4d[_0x088f('0x7')](_0x088f('0x8'),_0x23c214[_0x088f('0x9')](function(_0x4342e7){return{'id':_0x4342e7['id']};}));return MailMessage[_0x088f('0xa')]({'where':{'MailInteractionId':_0x30ba4d['id'],'direction':'in','read':![]},'raw':!![]});})[_0x088f('0x6')](function(_0x5dbbca){_0x30ba4d['setDataValue'](_0x088f('0xb'),_0x5dbbca[_0x088f('0xc')]);MailInteractionEvents[_0x088f('0xd')](_0x4cec7d+':'+_0x30ba4d['id'],_0x30ba4d);MailInteractionEvents[_0x088f('0xd')](_0x4cec7d,_0x30ba4d);_0x2abad3(null);})[_0x088f('0xe')](_0x2abad3(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];MailInteraction[_0x088f('0xf')](e,emitEvent(event));}}module[_0x088f('0x10')]=MailInteractionEvents;