1c6a0bf22ca52f3f18de2395a52717b05addf84c
[motion-next.git] / server / api / openchannelInteraction / openchannelInteraction.events.js
1 const a481_0x3733=['../../mysqldb','length','OpenchannelMessage','remove','exports','update','emit','getUsers','findAll','Users','undefined','then','catch','setMaxListeners','OpenchannelInteraction','setDataValue','map','addHook','events'];(function(_0x454695,_0x37339d){const _0x383840=function(_0x1c2a82){while(--_0x1c2a82){_0x454695['push'](_0x454695['shift']());}};_0x383840(++_0x37339d);}(a481_0x3733,0x13f));const a481_0x3838=function(_0x454695,_0x37339d){_0x454695=_0x454695-0x0;let _0x383840=a481_0x3733[_0x454695];return _0x383840;};const _0x528a18=a481_0x3838;'use strict';const EventEmitter=require(_0x528a18('0x3')),OpenchannelInteraction=require(_0x528a18('0x4'))['db'][_0x528a18('0x12')],OpenchannelMessage=require('../../mysqldb')['db'][_0x528a18('0x6')],OpenchannelInteractionEvents=new EventEmitter();OpenchannelInteractionEvents[_0x528a18('0x11')](0x0);const events={'afterCreate':'save','afterUpdate':_0x528a18('0x9'),'afterDestroy':_0x528a18('0x7')};function emitEvent(_0x1c2a82){return function(_0x1e1fce){const _0xa48287=a481_0x3838;_0x1e1fce[_0xa48287('0xb')]({'attributes':['id'],'raw':!![]})[_0xa48287('0xf')](function(_0x41d1de){const _0x36f810=_0xa48287;return _0x1e1fce[_0x36f810('0x0')](_0x36f810('0xd'),_0x41d1de[_0x36f810('0x1')](function(_0x40aafb){return{'id':_0x40aafb['id']};})),OpenchannelMessage[_0x36f810('0xc')]({'where':{'OpenchannelInteractionId':_0x1e1fce['id'],'direction':'in','read':![]},'raw':!![]});})[_0xa48287('0xf')](function(_0x436a28){const _0x2dcbd0=_0xa48287;_0x1e1fce[_0x2dcbd0('0x0')]('unreadMessages',_0x436a28[_0x2dcbd0('0x5')]),OpenchannelInteractionEvents['emit'](_0x1c2a82+':'+_0x1e1fce['id'],_0x1e1fce),OpenchannelInteractionEvents[_0x2dcbd0('0xa')](_0x1c2a82,_0x1e1fce);})[_0xa48287('0x10')](()=>{});};}for(const e in events){if(typeof events[e]!==_0x528a18('0xe')){const event=events[e];OpenchannelInteraction[_0x528a18('0x2')](e,emitEvent(event));}}module[_0x528a18('0x8')]=OpenchannelInteractionEvents;