Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / chatInteraction / chatInteraction.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 _0x2431=['save','update','remove','getUsers','then','setDataValue','Users','map','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','ChatMessage'];(function(_0x41e8c4,_0x30d9ff){var _0x54ffbe=function(_0x4131af){while(--_0x4131af){_0x41e8c4['push'](_0x41e8c4['shift']());}};_0x54ffbe(++_0x30d9ff);}(_0x2431,0xc9));var _0x1243=function(_0x59ee6f,_0x450239){_0x59ee6f=_0x59ee6f-0x0;var _0x4c0979=_0x2431[_0x59ee6f];return _0x4c0979;};'use strict';var EventEmitter=require(_0x1243('0x0'));var ChatInteraction=require(_0x1243('0x1'))['db']['ChatInteraction'];var ChatMessage=require(_0x1243('0x1'))['db'][_0x1243('0x2')];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x1243('0x3'),'afterUpdate':_0x1243('0x4'),'afterDestroy':_0x1243('0x5')};function emitEvent(_0x1ce471){return function(_0x4007fd,_0x378af7,_0x1a2686){_0x4007fd[_0x1243('0x6')]({'attributes':['id'],'raw':!![]})[_0x1243('0x7')](function(_0x406bad){_0x4007fd[_0x1243('0x8')](_0x1243('0x9'),_0x406bad[_0x1243('0xa')](function(_0x3e42d1){return{'id':_0x3e42d1['id']};}));return ChatMessage['findAll']({'where':{'ChatInteractionId':_0x4007fd['id'],'direction':'in','read':![]},'raw':!![]});})[_0x1243('0x7')](function(_0x35095d){_0x4007fd[_0x1243('0x8')]('unreadMessages',_0x35095d[_0x1243('0xb')]);ChatInteractionEvents[_0x1243('0xc')](_0x1ce471+':'+_0x4007fd['id'],_0x4007fd);ChatInteractionEvents[_0x1243('0xc')](_0x1ce471,_0x4007fd);_0x1a2686(null);})[_0x1243('0xd')](_0x1a2686(null));};}for(var e in events){if(events[_0x1243('0xe')](e)){var event=events[e];ChatInteraction[_0x1243('0xf')](e,emitEvent(event));}}module[_0x1243('0x10')]=ChatInteractionEvents;