Built motion from commit 0900f080.|2.5.45
[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 _0x971f=['hasOwnProperty','hook','exports','events','../../mysqldb','MailMessage','setMaxListeners','remove','getUsers','then','setDataValue','Users','findAll','unreadMessages','length','catch'];(function(_0x53d8c1,_0xc0e94a){var _0x351e4a=function(_0x1abe09){while(--_0x1abe09){_0x53d8c1['push'](_0x53d8c1['shift']());}};_0x351e4a(++_0xc0e94a);}(_0x971f,0xf3));var _0xf971=function(_0x28d508,_0x5bc1e7){_0x28d508=_0x28d508-0x0;var _0x3d6f24=_0x971f[_0x28d508];return _0x3d6f24;};'use strict';var EventEmitter=require(_0xf971('0x0'));var MailInteraction=require(_0xf971('0x1'))['db']['MailInteraction'];var MailMessage=require('../../mysqldb')['db'][_0xf971('0x2')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0xf971('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':_0xf971('0x4')};function emitEvent(_0xad4f3a){return function(_0x336144,_0x48a6c7,_0x3c3b9f){_0x336144[_0xf971('0x5')]({'attributes':['id'],'raw':!![]})[_0xf971('0x6')](function(_0x4acbdd){_0x336144[_0xf971('0x7')](_0xf971('0x8'),_0x4acbdd['map'](function(_0x1efe94){return{'id':_0x1efe94['id']};}));return MailMessage[_0xf971('0x9')]({'where':{'MailInteractionId':_0x336144['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf971('0x6')](function(_0x175831){_0x336144[_0xf971('0x7')](_0xf971('0xa'),_0x175831[_0xf971('0xb')]);MailInteractionEvents['emit'](_0xad4f3a+':'+_0x336144['id'],_0x336144);MailInteractionEvents['emit'](_0xad4f3a,_0x336144);_0x3c3b9f(null);})[_0xf971('0xc')](_0x3c3b9f(null));};}for(var e in events){if(events[_0xf971('0xd')](e)){var event=events[e];MailInteraction[_0xf971('0xe')](e,emitEvent(event));}}module[_0xf971('0xf')]=MailInteractionEvents;