c71234096b2dcee50eb5597958b776160635d33e
[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 _0x40d2=['save','update','remove','getUsers','then','map','findAll','setDataValue','unreadMessages','emit','hasOwnProperty','hook','exports','events','../../mysqldb','MailMessage'];(function(_0xbd3a05,_0xe6c6b7){var _0x101f90=function(_0x34fbcb){while(--_0x34fbcb){_0xbd3a05['push'](_0xbd3a05['shift']());}};_0x101f90(++_0xe6c6b7);}(_0x40d2,0x13d));var _0x240d=function(_0xab840,_0x48ed14){_0xab840=_0xab840-0x0;var _0x2e6dbc=_0x40d2[_0xab840];return _0x2e6dbc;};'use strict';var EventEmitter=require(_0x240d('0x0'));var MailInteraction=require(_0x240d('0x1'))['db']['MailInteraction'];var MailMessage=require('../../mysqldb')['db'][_0x240d('0x2')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x240d('0x3'),'afterUpdate':_0x240d('0x4'),'afterDestroy':_0x240d('0x5')};function emitEvent(_0x59571c){return function(_0x54f6b8,_0xca7df,_0x100a32){_0x54f6b8[_0x240d('0x6')]({'attributes':['id'],'raw':!![]})[_0x240d('0x7')](function(_0x5a0193){_0x54f6b8['setDataValue']('Users',_0x5a0193[_0x240d('0x8')](function(_0x4ae350){return{'id':_0x4ae350['id']};}));return MailMessage[_0x240d('0x9')]({'where':{'MailInteractionId':_0x54f6b8['id'],'direction':'in','read':![]},'raw':!![]});})[_0x240d('0x7')](function(_0x4542a6){_0x54f6b8[_0x240d('0xa')](_0x240d('0xb'),_0x4542a6['length']);MailInteractionEvents[_0x240d('0xc')](_0x59571c+':'+_0x54f6b8['id'],_0x54f6b8);MailInteractionEvents['emit'](_0x59571c,_0x54f6b8);_0x100a32(null);})['catch'](_0x100a32(null));};}for(var e in events){if(events[_0x240d('0xd')](e)){var event=events[e];MailInteraction[_0x240d('0xe')](e,emitEvent(event));}}module[_0x240d('0xf')]=MailInteractionEvents;