Built motion from commit 953226e6.|2.6.32
[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 _0x9eaf=['catch','hasOwnProperty','exports','ChatInteraction','../../mysqldb','ChatMessage','save','remove','getUsers','then','Users','map','setDataValue','unreadMessages','emit'];(function(_0x538dff,_0x4859cf){var _0x16c060=function(_0x2acef9){while(--_0x2acef9){_0x538dff['push'](_0x538dff['shift']());}};_0x16c060(++_0x4859cf);}(_0x9eaf,0x7b));var _0xf9ea=function(_0x12bf8a,_0x3c5eb5){_0x12bf8a=_0x12bf8a-0x0;var _0x152415=_0x9eaf[_0x12bf8a];return _0x152415;};'use strict';var EventEmitter=require('events');var ChatInteraction=require('../../mysqldb')['db'][_0xf9ea('0x0')];var ChatMessage=require(_0xf9ea('0x1'))['db'][_0xf9ea('0x2')];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xf9ea('0x3'),'afterUpdate':'update','afterDestroy':_0xf9ea('0x4')};function emitEvent(_0x2e9f08){return function(_0x319f1f,_0x138e8b,_0x4b0faf){_0x319f1f[_0xf9ea('0x5')]({'attributes':['id'],'raw':!![]})[_0xf9ea('0x6')](function(_0x2589dc){_0x319f1f['setDataValue'](_0xf9ea('0x7'),_0x2589dc[_0xf9ea('0x8')](function(_0x2ff86f){return{'id':_0x2ff86f['id']};}));return ChatMessage['findAll']({'where':{'ChatInteractionId':_0x319f1f['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf9ea('0x6')](function(_0x37f668){_0x319f1f[_0xf9ea('0x9')](_0xf9ea('0xa'),_0x37f668['length']);ChatInteractionEvents[_0xf9ea('0xb')](_0x2e9f08+':'+_0x319f1f['id'],_0x319f1f);ChatInteractionEvents[_0xf9ea('0xb')](_0x2e9f08,_0x319f1f);_0x4b0faf(null);})[_0xf9ea('0xc')](_0x4b0faf(null));};}for(var e in events){if(events[_0xf9ea('0xd')](e)){var event=events[e];ChatInteraction['hook'](e,emitEvent(event));}}module[_0xf9ea('0xe')]=ChatInteractionEvents;