Built motion from commit (unavailable).|2.5.21
[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 _0x24f3=['map','findAll','unreadMessages','emit','catch','hasOwnProperty','exports','events','../../mysqldb','MailInteraction','MailMessage','setMaxListeners','update','remove','getUsers','then','setDataValue','Users'];(function(_0x57975f,_0x388556){var _0x4793b8=function(_0x652c05){while(--_0x652c05){_0x57975f['push'](_0x57975f['shift']());}};_0x4793b8(++_0x388556);}(_0x24f3,0x15d));var _0x324f=function(_0xec55e1,_0xc4d37e){_0xec55e1=_0xec55e1-0x0;var _0x2960db=_0x24f3[_0xec55e1];return _0x2960db;};'use strict';var EventEmitter=require(_0x324f('0x0'));var MailInteraction=require(_0x324f('0x1'))['db'][_0x324f('0x2')];var MailMessage=require(_0x324f('0x1'))['db'][_0x324f('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0x324f('0x4')](0x0);var events={'afterCreate':'save','afterUpdate':_0x324f('0x5'),'afterDestroy':_0x324f('0x6')};function emitEvent(_0x402798){return function(_0x1164d5,_0x10a551,_0x4180c8){_0x1164d5[_0x324f('0x7')]({'attributes':['id'],'raw':!![]})[_0x324f('0x8')](function(_0x2f1891){_0x1164d5[_0x324f('0x9')](_0x324f('0xa'),_0x2f1891[_0x324f('0xb')](function(_0x48c482){return{'id':_0x48c482['id']};}));return MailMessage[_0x324f('0xc')]({'where':{'MailInteractionId':_0x1164d5['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x3eedd9){_0x1164d5[_0x324f('0x9')](_0x324f('0xd'),_0x3eedd9['length']);MailInteractionEvents[_0x324f('0xe')](_0x402798+':'+_0x1164d5['id'],_0x1164d5);MailInteractionEvents[_0x324f('0xe')](_0x402798,_0x1164d5);_0x4180c8(null);})[_0x324f('0xf')](_0x4180c8(null));};}for(var e in events){if(events[_0x324f('0x10')](e)){var event=events[e];MailInteraction['hook'](e,emitEvent(event));}}module[_0x324f('0x11')]=MailInteractionEvents;