Built motion from commit (unavailable).|2.5.18
[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 _0xa04c=['findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','../../mysqldb','MailInteraction','MailMessage','setMaxListeners','save','remove','getUsers','then','setDataValue','Users'];(function(_0x4e6818,_0x2c5d9a){var _0x346c4b=function(_0x31f2c8){while(--_0x31f2c8){_0x4e6818['push'](_0x4e6818['shift']());}};_0x346c4b(++_0x2c5d9a);}(_0xa04c,0x19f));var _0xca04=function(_0x44dd33,_0x599038){_0x44dd33=_0x44dd33-0x0;var _0x300118=_0xa04c[_0x44dd33];return _0x300118;};'use strict';var EventEmitter=require('events');var MailInteraction=require(_0xca04('0x0'))['db'][_0xca04('0x1')];var MailMessage=require(_0xca04('0x0'))['db'][_0xca04('0x2')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0xca04('0x3')](0x0);var events={'afterCreate':_0xca04('0x4'),'afterUpdate':'update','afterDestroy':_0xca04('0x5')};function emitEvent(_0x2937de){return function(_0x5d9b20,_0x278bdb,_0x9e8364){_0x5d9b20[_0xca04('0x6')]({'attributes':['id'],'raw':!![]})[_0xca04('0x7')](function(_0x43a83a){_0x5d9b20[_0xca04('0x8')](_0xca04('0x9'),_0x43a83a['map'](function(_0x3e066f){return{'id':_0x3e066f['id']};}));return MailMessage[_0xca04('0xa')]({'where':{'MailInteractionId':_0x5d9b20['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x51d001){_0x5d9b20['setDataValue'](_0xca04('0xb'),_0x51d001[_0xca04('0xc')]);MailInteractionEvents['emit'](_0x2937de+':'+_0x5d9b20['id'],_0x5d9b20);MailInteractionEvents[_0xca04('0xd')](_0x2937de,_0x5d9b20);_0x9e8364(null);})[_0xca04('0xe')](_0x9e8364(null));};}for(var e in events){if(events[_0xca04('0xf')](e)){var event=events[e];MailInteraction[_0xca04('0x10')](e,emitEvent(event));}}module['exports']=MailInteractionEvents;