Built motion from commit 459747fdfe53bbf13fbede61eeaffea1f1438f86. Version 3.0.0...
[motion-next.git] / server / api / chatInteraction / chatInteraction.events.js
1 const a67_0xa364=['map','getUsers','remove','setMaxListeners','../../mysqldb','addHook','update','catch','unreadMessages','emit','Users','setDataValue','undefined','length','ChatMessage','then'];(function(_0x348134,_0xa364ac){const _0x18fe44=function(_0x5851ac){while(--_0x5851ac){_0x348134['push'](_0x348134['shift']());}};_0x18fe44(++_0xa364ac);}(a67_0xa364,0xff));const a67_0x18fe=function(_0x348134,_0xa364ac){_0x348134=_0x348134-0x0;let _0x18fe44=a67_0xa364[_0x348134];return _0x18fe44;};const _0x438d75=a67_0x18fe;'use strict';const EventEmitter=require('events'),ChatInteraction=require(_0x438d75('0x5'))['db']['ChatInteraction'],ChatMessage=require(_0x438d75('0x5'))['db'][_0x438d75('0xf')],ChatInteractionEvents=new EventEmitter();ChatInteractionEvents[_0x438d75('0x4')](0x0);const events={'afterCreate':'save','afterUpdate':_0x438d75('0x7'),'afterDestroy':_0x438d75('0x3')};function emitEvent(_0x5851ac){return function(_0x13fbe7){const _0x5a89c0=a67_0x18fe;_0x13fbe7[_0x5a89c0('0x2')]({'attributes':['id'],'raw':!![]})[_0x5a89c0('0x0')](function(_0x584d52){const _0x33c34f=_0x5a89c0;return _0x13fbe7[_0x33c34f('0xc')](_0x33c34f('0xb'),_0x584d52[_0x33c34f('0x1')](function(_0x2aa944){return{'id':_0x2aa944['id']};})),ChatMessage['findAll']({'where':{'ChatInteractionId':_0x13fbe7['id'],'direction':'in','read':![]},'raw':!![]});})[_0x5a89c0('0x0')](function(_0x299d92){const _0x46761e=_0x5a89c0;_0x13fbe7[_0x46761e('0xc')](_0x46761e('0x9'),_0x299d92[_0x46761e('0xe')]),ChatInteractionEvents[_0x46761e('0xa')](_0x5851ac+':'+_0x13fbe7['id'],_0x13fbe7),ChatInteractionEvents['emit'](_0x5851ac,_0x13fbe7);})[_0x5a89c0('0x8')](()=>{});};}for(const e in events){if(typeof events[e]!==_0x438d75('0xd')){const event=events[e];ChatInteraction[_0x438d75('0x6')](e,emitEvent(event));}}module['exports']=ChatInteractionEvents;