Built motion from commit (unavailable).|2.5.30
[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 _0x842c=['ChatMessage','setMaxListeners','update','remove','then','setDataValue','Users','findAll','unreadMessages','length','emit','catch','exports','events','../../mysqldb'];(function(_0x1b0c8c,_0x486222){var _0x2e67c9=function(_0x4f27c6){while(--_0x4f27c6){_0x1b0c8c['push'](_0x1b0c8c['shift']());}};_0x2e67c9(++_0x486222);}(_0x842c,0x1de));var _0xc842=function(_0x364948,_0x229290){_0x364948=_0x364948-0x0;var _0x250e07=_0x842c[_0x364948];return _0x250e07;};'use strict';var EventEmitter=require(_0xc842('0x0'));var ChatInteraction=require(_0xc842('0x1'))['db']['ChatInteraction'];var ChatMessage=require(_0xc842('0x1'))['db'][_0xc842('0x2')];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents[_0xc842('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0xc842('0x4'),'afterDestroy':_0xc842('0x5')};function emitEvent(_0x2df58d){return function(_0x3fa4ca,_0x4ba8f8,_0x2b24da){_0x3fa4ca['getUsers']({'attributes':['id'],'raw':!![]})[_0xc842('0x6')](function(_0x18502e){_0x3fa4ca[_0xc842('0x7')](_0xc842('0x8'),_0x18502e['map'](function(_0x5a87e5){return{'id':_0x5a87e5['id']};}));return ChatMessage[_0xc842('0x9')]({'where':{'ChatInteractionId':_0x3fa4ca['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x3b2f1b){_0x3fa4ca[_0xc842('0x7')](_0xc842('0xa'),_0x3b2f1b[_0xc842('0xb')]);ChatInteractionEvents[_0xc842('0xc')](_0x2df58d+':'+_0x3fa4ca['id'],_0x3fa4ca);ChatInteractionEvents[_0xc842('0xc')](_0x2df58d,_0x3fa4ca);_0x2b24da(null);})[_0xc842('0xd')](_0x2b24da(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];ChatInteraction['hook'](e,emitEvent(event));}}module[_0xc842('0xe')]=ChatInteractionEvents;