Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / api / chatGroup / chatGroup.controller.js
index cbbb84a..6c91299 100644 (file)
@@ -1 +1 @@
-const a59_0xe008=['options','body','moment','getMessages','User','ids','filters','send','like','filter','addMembers','sequelize','create','where','set','api','findOne','name','register','offset','catch','../../components/parsers/qs','format','end','merge','nolimit','length','findAll','omit','update','getMembers','count','then','error','undefined','YYYY-MM-DD\x20HH:mm:ss','key','params','split','lodash','map','getUnread','order','$gte','removeMembers','../../mysqldb','status','../../rediscache','intersection','keys','gte','type','describe','stack','Content-Range','toInteger','destroy','fieldName','pick','ChatInternalMessage','addMessage','fields','sendStatus','user','ChatGroup','rows','query','sort','limit','attributes','rawAttributes','model'];(function(_0x28a198,_0xe00858){const _0x15a0fc=function(_0x554b0a){while(--_0x554b0a){_0x28a198['push'](_0x28a198['shift']());}};_0x15a0fc(++_0xe00858);}(a59_0xe008,0x191));const a59_0x15a0=function(_0x28a198,_0xe00858){_0x28a198=_0x28a198-0x0;let _0x15a0fc=a59_0xe008[_0x28a198];return _0x15a0fc;};const _0x3a7c16=a59_0x15a0;'use strict';const moment=require(_0x3a7c16('0x21')),_=require(_0x3a7c16('0x46')),{getSocket}=require(_0x3a7c16('0x6')),qs=require(_0x3a7c16('0x34')),logger=require('../../config/logger')(_0x3a7c16('0x2e')),db=require(_0x3a7c16('0x4'))['db'],{Op}=require(_0x3a7c16('0x2a')),socket=getSocket();require('./chatGroup.socket')[_0x3a7c16('0x31')](socket);function respondWithStatusCode(_0x554b0a,_0x3e6f1c){return _0x3e6f1c=_0x3e6f1c||0xcc,function(_0x37dcce){const _0x51c8c9=a59_0x15a0;if(_0x37dcce)return _0x554b0a[_0x51c8c9('0x15')](_0x3e6f1c);return _0x554b0a[_0x51c8c9('0x5')](_0x3e6f1c)[_0x51c8c9('0x36')]();};}function respondWithResult(_0x2d6281,_0xb3c06f){return _0xb3c06f=_0xb3c06f||0xc8,function(_0x3f6d6b){if(_0x3f6d6b)return _0x2d6281['status'](_0xb3c06f)['json'](_0x3f6d6b);};}function respondWithFilteredResult(_0xcbdbe5,_0x4e86b8){return function(_0x4f4941){const _0xf4fa9f=a59_0x15a0;if(_0x4f4941){const _0x53b26e=_0x4f4941[_0xf4fa9f('0x3e')],_0x45e57a=_0x4e86b8[_0xf4fa9f('0x32')];let _0x4467c3=_0x4e86b8['offset']+_0x4e86b8['limit'],_0x3b65af;return _0x4467c3>=_0x53b26e?(_0x4467c3=_0x53b26e,_0x3b65af=0xc8):_0x3b65af=0xce,_0xcbdbe5[_0xf4fa9f('0x5')](_0x3b65af),_0xcbdbe5[_0xf4fa9f('0x2d')](_0xf4fa9f('0xd'),_0x45e57a+'-'+_0x4467c3+'/'+_0x53b26e)['json'](_0x4f4941);}return null;};}function saveUpdates(_0x1fc544){return function(_0x58d2b6){const _0x1be97e=a59_0x15a0;if(_0x58d2b6)return _0x58d2b6[_0x1be97e('0x3c')](_0x1fc544)[_0x1be97e('0x3f')](function(_0x4e8b3f){return _0x4e8b3f;});return null;};}function removeEntity(_0x199366){return function(_0x486012){const _0x544bb8=a59_0x15a0;if(_0x486012)return _0x486012['destroy']()[_0x544bb8('0x3f')](function(){const _0x87d44b=_0x544bb8;_0x199366[_0x87d44b('0x5')](0xcc)['end']();});};}function handleEntityNotFound(_0x505bb9){return function(_0x4ca757){const _0x5b659a=a59_0x15a0;return!_0x4ca757&&_0x505bb9[_0x5b659a('0x15')](0x194),_0x4ca757;};}function handleError(_0x44f1bd,_0x5810aa){return _0x5810aa=_0x5810aa||0x1f4,function(_0x4760b3){const _0x121525=a59_0x15a0;logger[_0x121525('0x40')](_0x4760b3[_0x121525('0xc')]),_0x4760b3[_0x121525('0x30')]&&delete _0x4760b3[_0x121525('0x30')],_0x44f1bd[_0x121525('0x5')](_0x5810aa)[_0x121525('0x26')](_0x4760b3);};}exports['index']=function(_0x1ad841,_0x401522){const _0x1fb90e=_0x3a7c16;let _0x8d3981={};const _0x2248c6={},_0x5684bf={'count':0x0,'rows':[]},_0x5a324d=_[_0x1fb90e('0x47')](db[_0x1fb90e('0x17')]['rawAttributes'],function(_0x1051e3){const _0x26420a=_0x1fb90e;return{'name':_0x1051e3[_0x26420a('0x10')],'type':_0x1051e3['type'][_0x26420a('0x43')]};});_0x2248c6[_0x1fb90e('0x1e')]=_[_0x1fb90e('0x47')](_0x5a324d,'name'),_0x2248c6[_0x1fb90e('0x19')]=_[_0x1fb90e('0x8')](_0x1ad841[_0x1fb90e('0x19')]),_0x2248c6['filters']=_[_0x1fb90e('0x7')](_0x2248c6[_0x1fb90e('0x1e')],_0x2248c6[_0x1fb90e('0x19')]),_0x8d3981[_0x1fb90e('0x1c')]=_[_0x1fb90e('0x7')](_0x2248c6[_0x1fb90e('0x1e')],qs['fields'](_0x1ad841[_0x1fb90e('0x19')][_0x1fb90e('0x14')])),_0x8d3981[_0x1fb90e('0x1c')]=_0x8d3981[_0x1fb90e('0x1c')][_0x1fb90e('0x39')]?_0x8d3981[_0x1fb90e('0x1c')]:_0x2248c6[_0x1fb90e('0x1e')];typeof _0x1ad841['query']['nolimit']==='undefined'&&(_0x8d3981[_0x1fb90e('0x1b')]=qs['limit'](_0x1ad841['query']['limit']),_0x8d3981[_0x1fb90e('0x32')]=qs[_0x1fb90e('0x32')](_0x1ad841[_0x1fb90e('0x19')][_0x1fb90e('0x32')]));_0x8d3981[_0x1fb90e('0x1')]=qs['sort'](_0x1ad841['query']['sort']),_0x8d3981['where']=qs[_0x1fb90e('0x25')](_[_0x1fb90e('0x11')](_0x1ad841[_0x1fb90e('0x19')],_0x2248c6[_0x1fb90e('0x25')]),_0x5a324d);_0x1ad841[_0x1fb90e('0x19')][_0x1fb90e('0x28')]&&(_0x8d3981['where']=_[_0x1fb90e('0x37')](_0x8d3981[_0x1fb90e('0x2c')],{[Op['or']]:_[_0x1fb90e('0x47')](_0x5a324d,function(_0x4fcf69){const _0xdbe10e=_0x1fb90e;if(_0x4fcf69[_0xdbe10e('0xa')]!=='VIRTUAL'){const _0x3adce4={};return _0x3adce4[_0x4fcf69[_0xdbe10e('0x30')]]={[Op['like']]:'%'+_0x1ad841[_0xdbe10e('0x19')][_0xdbe10e('0x28')]+'%'},_0x3adce4;}})}));_0x8d3981=_[_0x1fb90e('0x37')]({},_0x8d3981,_0x1ad841['options']);const _0x2e33a8={'where':_0x8d3981[_0x1fb90e('0x2c')]};return db[_0x1fb90e('0x17')][_0x1fb90e('0x3e')](_0x2e33a8)[_0x1fb90e('0x3f')](function(_0x1b92c0){const _0x271eca=_0x1fb90e;return _0x5684bf[_0x271eca('0x3e')]=_0x1b92c0,_0x1ad841[_0x271eca('0x19')]['includeAll']&&(_0x8d3981['include']=[{'all':!![]}]),db[_0x271eca('0x17')][_0x271eca('0x3a')](_0x8d3981);})['then'](function(_0x445f42){const _0x17807c=_0x1fb90e;return _0x5684bf[_0x17807c('0x18')]=_0x445f42,_0x5684bf;})[_0x1fb90e('0x3f')](respondWithFilteredResult(_0x401522,_0x8d3981))[_0x1fb90e('0x33')](handleError(_0x401522,null));},exports['show']=function(_0x1b5b88,_0x5462fa){const _0xd468c6=_0x3a7c16;let _0x5a7861={'raw':!![],'where':{'id':_0x1b5b88['params']['id']}};const _0x5ec68d={};return _0x5ec68d['model']=_[_0xd468c6('0x8')](db[_0xd468c6('0x17')]['rawAttributes']),_0x5ec68d[_0xd468c6('0x19')]=_['keys'](_0x1b5b88['query']),_0x5ec68d[_0xd468c6('0x25')]=_[_0xd468c6('0x7')](_0x5ec68d[_0xd468c6('0x1e')],_0x5ec68d[_0xd468c6('0x19')]),_0x5a7861['attributes']=_[_0xd468c6('0x7')](_0x5ec68d[_0xd468c6('0x1e')],qs['fields'](_0x1b5b88['query'][_0xd468c6('0x14')])),_0x5a7861[_0xd468c6('0x1c')]=_0x5a7861[_0xd468c6('0x1c')][_0xd468c6('0x39')]?_0x5a7861['attributes']:_0x5ec68d[_0xd468c6('0x1e')],_0x1b5b88[_0xd468c6('0x19')]['includeAll']&&(_0x5a7861['include']=[{'all':!![]}]),_0x5a7861=_[_0xd468c6('0x37')]({},_0x5a7861,_0x1b5b88[_0xd468c6('0x1f')]),db['ChatGroup']['findOne'](_0x5a7861)[_0xd468c6('0x3f')](handleEntityNotFound(_0x5462fa,null))[_0xd468c6('0x3f')](respondWithResult(_0x5462fa,null))['catch'](handleError(_0x5462fa,null));},exports[_0x3a7c16('0x2b')]=function(_0x24d24e,_0x3dda50){const _0x3a1bdd=_0x3a7c16;return db['ChatGroup']['create'](_0x24d24e[_0x3a1bdd('0x20')],{})[_0x3a1bdd('0x3f')](respondWithResult(_0x3dda50,0xc9))[_0x3a1bdd('0x33')](handleError(_0x3dda50,null));},exports[_0x3a7c16('0x3c')]=function(_0x4b4c6c,_0xe039b4){const _0x1692a2=_0x3a7c16;return _0x4b4c6c[_0x1692a2('0x20')]['id']&&delete _0x4b4c6c[_0x1692a2('0x20')]['id'],db[_0x1692a2('0x17')][_0x1692a2('0x2f')]({'where':{'id':_0x4b4c6c[_0x1692a2('0x44')]['id']}})[_0x1692a2('0x3f')](handleEntityNotFound(_0xe039b4,null))['then'](saveUpdates(_0x4b4c6c[_0x1692a2('0x20')],null))['then'](respondWithResult(_0xe039b4,null))[_0x1692a2('0x33')](handleError(_0xe039b4,null));},exports[_0x3a7c16('0xf')]=function(_0x44f214,_0x2875bb){const _0x1fef2e=_0x3a7c16;return db[_0x1fef2e('0x17')]['findOne']({'where':{'id':_0x44f214['params']['id']}})['then'](handleEntityNotFound(_0x2875bb,null))[_0x1fef2e('0x3f')](removeEntity(_0x2875bb,null))[_0x1fef2e('0x33')](handleError(_0x2875bb,null));},exports[_0x3a7c16('0xb')]=function(_0x2a5135,_0x103212){const _0x54b344=_0x3a7c16;return db['ChatGroup'][_0x54b344('0xb')]()[_0x54b344('0x3f')](respondWithResult(_0x103212,null))[_0x54b344('0x33')](handleError(_0x103212,null));},exports[_0x3a7c16('0x0')]=function(_0xefb3fd,_0x46d9d5){const _0x42e66c=_0x3a7c16;return db['ChatInternalMessage'][_0x42e66c('0x3e')]({'where':{'ChatGroupId':_0xefb3fd[_0x42e66c('0x44')]['id'],'ToId':_0xefb3fd[_0x42e66c('0x16')]['id'],'read':![]}})[_0x42e66c('0x3f')](function(_0x5025e5){const _0x1fbda5=_0x42e66c;return{'id':_[_0x1fbda5('0xe')](_0xefb3fd[_0x1fbda5('0x44')]['id']),'count':_0x5025e5};})[_0x42e66c('0x3f')](respondWithResult(_0x46d9d5,null))[_0x42e66c('0x33')](handleError(_0x46d9d5,null));},exports['addMembers']=function(_0x197cbb,_0x1544d6){const _0x36d46a=_0x3a7c16;return db[_0x36d46a('0x17')][_0x36d46a('0x2f')]({'where':{'id':_0x197cbb[_0x36d46a('0x44')]['id']}})[_0x36d46a('0x3f')](function(_0x23c8cd){const _0x2b4325=_0x36d46a;if(_0x23c8cd)return _0x23c8cd[_0x2b4325('0x29')](_0x197cbb['body'][_0x2b4325('0x24')],{'through':_[_0x2b4325('0x3b')](_0x197cbb[_0x2b4325('0x20')],[_0x2b4325('0x24'),'id'])});})['then'](respondWithResult(_0x1544d6,null))[_0x36d46a('0x33')](handleError(_0x1544d6,null));},exports[_0x3a7c16('0x3d')]=function(_0x2d45cc,_0x2f01e4){const _0x4ed285=_0x3a7c16;let _0x1a84ce={};const _0x19f4d8={};let _0x42abc4,_0x121c28;return db['ChatGroup'][_0x4ed285('0x2f')]({'where':{'id':_0x2d45cc[_0x4ed285('0x44')]['id']}})['then'](handleEntityNotFound(_0x2f01e4,null))[_0x4ed285('0x3f')](function(_0x2a663c){const _0x3dd9a0=_0x4ed285;if(_0x2a663c)return _0x42abc4=_0x2a663c,_0x19f4d8[_0x3dd9a0('0x1e')]=_['keys'](db[_0x3dd9a0('0x23')]['rawAttributes']),_0x19f4d8[_0x3dd9a0('0x19')]=_[_0x3dd9a0('0x8')](_0x2d45cc['query']),_0x19f4d8[_0x3dd9a0('0x25')]=_[_0x3dd9a0('0x7')](_0x19f4d8[_0x3dd9a0('0x1e')],_0x19f4d8[_0x3dd9a0('0x19')]),_0x1a84ce[_0x3dd9a0('0x1c')]=_[_0x3dd9a0('0x7')](_0x19f4d8[_0x3dd9a0('0x1e')],qs['fields'](_0x2d45cc[_0x3dd9a0('0x19')][_0x3dd9a0('0x14')])),_0x1a84ce[_0x3dd9a0('0x1c')]=_0x1a84ce[_0x3dd9a0('0x1c')][_0x3dd9a0('0x39')]?_0x1a84ce[_0x3dd9a0('0x1c')]:_0x19f4d8['model'],_0x1a84ce['order']=qs['sort'](_0x2d45cc['query']['sort']),_0x1a84ce[_0x3dd9a0('0x2c')]=qs['filters'](_[_0x3dd9a0('0x11')](_0x2d45cc[_0x3dd9a0('0x19')],_0x19f4d8[_0x3dd9a0('0x25')])),_0x2d45cc[_0x3dd9a0('0x19')][_0x3dd9a0('0x28')]&&(_0x1a84ce[_0x3dd9a0('0x2c')]=_[_0x3dd9a0('0x37')](_0x1a84ce[_0x3dd9a0('0x2c')],{[Op['or']]:_['map'](_0x1a84ce[_0x3dd9a0('0x1c')],function(_0x27e9f5){const _0x7ae816=_0x3dd9a0,_0x33642a={};return _0x33642a[_0x27e9f5]={[Op[_0x7ae816('0x27')]]:'%'+_0x2d45cc[_0x7ae816('0x19')][_0x7ae816('0x28')]+'%'},_0x33642a;})})),_0x1a84ce=_[_0x3dd9a0('0x37')]({},_0x1a84ce,_0x2d45cc['options']),_0x42abc4[_0x3dd9a0('0x3d')](_0x1a84ce);})[_0x4ed285('0x3f')](function(_0x6ec70a){const _0x469f7e=_0x4ed285;if(_0x6ec70a)return _0x121c28=_0x6ec70a['length'],typeof _0x2d45cc[_0x469f7e('0x19')]['nolimit']===_0x469f7e('0x41')&&(_0x1a84ce['limit']=qs[_0x469f7e('0x1b')](_0x2d45cc[_0x469f7e('0x19')][_0x469f7e('0x1b')]),_0x1a84ce[_0x469f7e('0x32')]=qs[_0x469f7e('0x32')](_0x2d45cc['query'][_0x469f7e('0x32')])),_0x42abc4[_0x469f7e('0x3d')](_0x1a84ce);})['then'](function(_0xe8b3ce){if(_0xe8b3ce)return _0xe8b3ce?{'count':_0x121c28,'rows':_0xe8b3ce}:null;})[_0x4ed285('0x3f')](respondWithResult(_0x2f01e4,null))['catch'](handleError(_0x2f01e4,null));},exports[_0x3a7c16('0x3')]=function(_0x2ee1fb,_0x2913e7){const _0x1dca6a=_0x3a7c16;return db[_0x1dca6a('0x17')][_0x1dca6a('0x2f')]({'where':{'id':_0x2ee1fb[_0x1dca6a('0x44')]['id']}})[_0x1dca6a('0x3f')](handleEntityNotFound(_0x2913e7,null))['then'](function(_0x298b07){const _0x498c7d=_0x1dca6a;if(_0x298b07)return _0x298b07[_0x498c7d('0x3')](_0x2ee1fb[_0x498c7d('0x19')][_0x498c7d('0x24')]);})[_0x1dca6a('0x3f')](respondWithStatusCode(_0x2913e7,null))[_0x1dca6a('0x33')](handleError(_0x2913e7,null));},exports[_0x3a7c16('0x13')]=function(_0x2bb265,_0x5489cf){const _0x83723f=_0x3a7c16;return _0x2bb265['body']['id']&&delete _0x2bb265['body']['id'],db[_0x83723f('0x17')][_0x83723f('0x2f')]({'where':{'id':_0x2bb265[_0x83723f('0x44')]['id']}})[_0x83723f('0x3f')](handleEntityNotFound(_0x5489cf,null))[_0x83723f('0x3f')](function(_0x358ad7){const _0x40af19=_0x83723f;if(_0x358ad7)return _0x2bb265[_0x40af19('0x20')]['ChatGroupId']=_0x358ad7['id'],db['ChatInternalMessage']['create'](_0x2bb265['body']);})[_0x83723f('0x3f')](respondWithResult(_0x5489cf,null))[_0x83723f('0x33')](handleError(_0x5489cf,null));},exports[_0x3a7c16('0x22')]=function(_0x13eade,_0x18d553){const _0x1a01d3=_0x3a7c16;let _0x25052d={};const _0x239ed5={};let _0x42f9d8,_0x4068d1;return db[_0x1a01d3('0x17')][_0x1a01d3('0x2f')]({'where':{'id':_0x13eade[_0x1a01d3('0x44')]['id']}})[_0x1a01d3('0x3f')](handleEntityNotFound(_0x18d553,null))[_0x1a01d3('0x3f')](function(_0x50c300){const _0x10ed5a=_0x1a01d3;if(_0x50c300){_0x42f9d8=_0x50c300,_0x239ed5[_0x10ed5a('0x1e')]=_[_0x10ed5a('0x8')](db[_0x10ed5a('0x12')][_0x10ed5a('0x1d')]),_0x239ed5['query']=_[_0x10ed5a('0x8')](_0x13eade[_0x10ed5a('0x19')]),_0x239ed5['filters']=_[_0x10ed5a('0x7')](_0x239ed5['model'],_0x239ed5['query']),_0x25052d[_0x10ed5a('0x1c')]=_[_0x10ed5a('0x7')](_0x239ed5[_0x10ed5a('0x1e')],qs[_0x10ed5a('0x14')](_0x13eade['query'][_0x10ed5a('0x14')])),_0x25052d['attributes']=_0x25052d['attributes'][_0x10ed5a('0x39')]?_0x25052d[_0x10ed5a('0x1c')]:_0x239ed5[_0x10ed5a('0x1e')],_0x25052d[_0x10ed5a('0x1')]=qs['sort'](_0x13eade[_0x10ed5a('0x19')][_0x10ed5a('0x1a')]),_0x25052d[_0x10ed5a('0x2c')]=qs[_0x10ed5a('0x25')](_[_0x10ed5a('0x11')](_0x13eade['query'],_0x239ed5[_0x10ed5a('0x25')]));_0x13eade[_0x10ed5a('0x19')][_0x10ed5a('0x28')]&&(_0x25052d[_0x10ed5a('0x2c')]=_[_0x10ed5a('0x37')](_0x25052d['where'],{[Op['or']]:_['map'](_0x25052d[_0x10ed5a('0x1c')],function(_0x540c02){const _0x2cda32=_0x10ed5a,_0x260e00={};return _0x260e00[_0x540c02]={[Op[_0x2cda32('0x27')]]:'%'+_0x13eade['query'][_0x2cda32('0x28')]+'%'},_0x260e00;})}));if(_0x13eade[_0x10ed5a('0x19')][_0x10ed5a('0x2')]){const _0x3650a4=_0x13eade[_0x10ed5a('0x19')][_0x10ed5a('0x2')][_0x10ed5a('0x45')](','),_0xb510a1={};_0xb510a1[_0x3650a4[0x0]]={[Op[_0x10ed5a('0x9')]]:moment(_0x3650a4[0x1])[_0x10ed5a('0x35')](_0x10ed5a('0x42'))},_0x25052d['where']=_[_0x10ed5a('0x37')](_0x25052d[_0x10ed5a('0x2c')],_0xb510a1);}return _0x25052d=_[_0x10ed5a('0x37')]({},_0x25052d,_0x13eade[_0x10ed5a('0x1f')]),_0x42f9d8[_0x10ed5a('0x22')](_0x25052d);}})[_0x1a01d3('0x3f')](function(_0x19476d){const _0x49dd83=_0x1a01d3;if(_0x19476d)return _0x4068d1=_0x19476d[_0x49dd83('0x39')],typeof _0x13eade[_0x49dd83('0x19')][_0x49dd83('0x38')]===_0x49dd83('0x41')&&(_0x25052d['limit']=qs['limit'](_0x13eade[_0x49dd83('0x19')][_0x49dd83('0x1b')]),_0x25052d[_0x49dd83('0x32')]=qs[_0x49dd83('0x32')](_0x13eade['query'][_0x49dd83('0x32')])),_0x42f9d8[_0x49dd83('0x22')](_0x25052d);})[_0x1a01d3('0x3f')](function(_0x3f432d){if(_0x3f432d)return _0x3f432d?{'count':_0x4068d1,'rows':_0x3f432d}:null;})[_0x1a01d3('0x3f')](respondWithResult(_0x18d553,null))[_0x1a01d3('0x33')](handleError(_0x18d553,null));};
\ No newline at end of file
+const a59_0x36f5=['rows','format','offset','$gte','type','map','body','api','like','getUnread','lodash','undefined','model','attributes','ChatGroup','describe','options','sequelize','length','where','catch','then','rawAttributes','ChatInternalMessage','pick','error','key','show','user','../../mysqldb','findAll','filters','merge','getMessages','addMembers','../../components/parsers/qs','findOne','stack','include','VIRTUAL','query','params','moment','send','destroy','order','getMembers','keys','sendStatus','removeMembers','status','User','../../rediscache','limit','ids','index','update','sort','intersection','gte','includeAll','create','filter','split','Content-Range','../../config/logger','fieldName','name','end','count','fields'];(function(_0xb35e84,_0x36f5b8){const _0x2eedb7=function(_0x271199){while(--_0x271199){_0xb35e84['push'](_0xb35e84['shift']());}};_0x2eedb7(++_0x36f5b8);}(a59_0x36f5,0x181));const a59_0x2eed=function(_0xb35e84,_0x36f5b8){_0xb35e84=_0xb35e84-0x0;let _0x2eedb7=a59_0x36f5[_0xb35e84];return _0x2eedb7;};const _0x49075d=a59_0x2eed;'use strict';const moment=require(_0x49075d('0xc')),_=require(_0x49075d('0x33')),{getSocket}=require(_0x49075d('0x16')),qs=require(_0x49075d('0x5')),logger=require(_0x49075d('0x23'))(_0x49075d('0x30')),db=require(_0x49075d('0x46'))['db'],{Op}=require(_0x49075d('0x3a')),socket=getSocket();require('./chatGroup.socket')['register'](socket);function respondWithStatusCode(_0x271199,_0x36a584){return _0x36a584=_0x36a584||0xcc,function(_0x192ab2){const _0x4dfe45=a59_0x2eed;if(_0x192ab2)return _0x271199[_0x4dfe45('0x12')](_0x36a584);return _0x271199['status'](_0x36a584)[_0x4dfe45('0x26')]();};}function respondWithResult(_0x50b583,_0x458e93){return _0x458e93=_0x458e93||0xc8,function(_0x10132d){if(_0x10132d)return _0x50b583['status'](_0x458e93)['json'](_0x10132d);};}function respondWithFilteredResult(_0x5bcaf0,_0x50163b){return function(_0xfea1df){const _0x51de24=a59_0x2eed;if(_0xfea1df){const _0x3bf1ad=_0xfea1df[_0x51de24('0x27')],_0x6c4cf6=_0x50163b[_0x51de24('0x2b')];let _0x8ceaa0=_0x50163b[_0x51de24('0x2b')]+_0x50163b[_0x51de24('0x17')],_0x3ff4d5;return _0x8ceaa0>=_0x3bf1ad?(_0x8ceaa0=_0x3bf1ad,_0x3ff4d5=0xc8):_0x3ff4d5=0xce,_0x5bcaf0[_0x51de24('0x14')](_0x3ff4d5),_0x5bcaf0['set'](_0x51de24('0x22'),_0x6c4cf6+'-'+_0x8ceaa0+'/'+_0x3bf1ad)['json'](_0xfea1df);}return null;};}function saveUpdates(_0x24b909){return function(_0x5444e1){const _0x46f716=a59_0x2eed;if(_0x5444e1)return _0x5444e1[_0x46f716('0x1a')](_0x24b909)['then'](function(_0xa2001e){return _0xa2001e;});return null;};}function removeEntity(_0x5e99f5){return function(_0xd318f7){const _0x1b6f14=a59_0x2eed;if(_0xd318f7)return _0xd318f7[_0x1b6f14('0xe')]()[_0x1b6f14('0x3e')](function(){const _0x5e2fe4=_0x1b6f14;_0x5e99f5[_0x5e2fe4('0x14')](0xcc)[_0x5e2fe4('0x26')]();});};}function handleEntityNotFound(_0x2f7fec){return function(_0x594305){const _0x5dd2d7=a59_0x2eed;return!_0x594305&&_0x2f7fec[_0x5dd2d7('0x12')](0x194),_0x594305;};}function handleError(_0xf3f4ba,_0x54a685){return _0x54a685=_0x54a685||0x1f4,function(_0x55e43f){const _0x1d67ea=a59_0x2eed;logger[_0x1d67ea('0x42')](_0x55e43f[_0x1d67ea('0x7')]),_0x55e43f[_0x1d67ea('0x25')]&&delete _0x55e43f[_0x1d67ea('0x25')],_0xf3f4ba['status'](_0x54a685)[_0x1d67ea('0xd')](_0x55e43f);};}exports[_0x49075d('0x19')]=function(_0x761660,_0x59bf93){const _0x178717=_0x49075d;let _0x311389={};const _0x39293b={},_0x5e2686={'count':0x0,'rows':[]},_0x63d704=_[_0x178717('0x2e')](db[_0x178717('0x37')][_0x178717('0x3f')],function(_0x2f40d8){const _0x83b1b6=_0x178717;return{'name':_0x2f40d8[_0x83b1b6('0x24')],'type':_0x2f40d8[_0x83b1b6('0x2d')][_0x83b1b6('0x43')]};});_0x39293b['model']=_[_0x178717('0x2e')](_0x63d704,'name'),_0x39293b[_0x178717('0xa')]=_[_0x178717('0x11')](_0x761660['query']),_0x39293b['filters']=_[_0x178717('0x1c')](_0x39293b[_0x178717('0x35')],_0x39293b[_0x178717('0xa')]),_0x311389[_0x178717('0x36')]=_[_0x178717('0x1c')](_0x39293b[_0x178717('0x35')],qs[_0x178717('0x28')](_0x761660[_0x178717('0xa')][_0x178717('0x28')])),_0x311389['attributes']=_0x311389[_0x178717('0x36')]['length']?_0x311389['attributes']:_0x39293b[_0x178717('0x35')];typeof _0x761660[_0x178717('0xa')]['nolimit']===_0x178717('0x34')&&(_0x311389[_0x178717('0x17')]=qs[_0x178717('0x17')](_0x761660['query'][_0x178717('0x17')]),_0x311389[_0x178717('0x2b')]=qs['offset'](_0x761660[_0x178717('0xa')][_0x178717('0x2b')]));_0x311389[_0x178717('0xf')]=qs[_0x178717('0x1b')](_0x761660[_0x178717('0xa')][_0x178717('0x1b')]),_0x311389[_0x178717('0x3c')]=qs[_0x178717('0x1')](_[_0x178717('0x41')](_0x761660[_0x178717('0xa')],_0x39293b[_0x178717('0x1')]),_0x63d704);_0x761660[_0x178717('0xa')][_0x178717('0x20')]&&(_0x311389[_0x178717('0x3c')]=_['merge'](_0x311389[_0x178717('0x3c')],{[Op['or']]:_[_0x178717('0x2e')](_0x63d704,function(_0x5c323c){const _0x3d1d0a=_0x178717;if(_0x5c323c[_0x3d1d0a('0x2d')]!==_0x3d1d0a('0x9')){const _0x3e9b82={};return _0x3e9b82[_0x5c323c[_0x3d1d0a('0x25')]]={[Op[_0x3d1d0a('0x31')]]:'%'+_0x761660[_0x3d1d0a('0xa')][_0x3d1d0a('0x20')]+'%'},_0x3e9b82;}})}));_0x311389=_[_0x178717('0x2')]({},_0x311389,_0x761660[_0x178717('0x39')]);const _0x4a5c49={'where':_0x311389['where']};return db[_0x178717('0x37')][_0x178717('0x27')](_0x4a5c49)[_0x178717('0x3e')](function(_0x35cefb){const _0x3e12e1=_0x178717;return _0x5e2686[_0x3e12e1('0x27')]=_0x35cefb,_0x761660[_0x3e12e1('0xa')][_0x3e12e1('0x1e')]&&(_0x311389[_0x3e12e1('0x8')]=[{'all':!![]}]),db['ChatGroup'][_0x3e12e1('0x0')](_0x311389);})[_0x178717('0x3e')](function(_0x2fd924){const _0x7e20dc=_0x178717;return _0x5e2686[_0x7e20dc('0x29')]=_0x2fd924,_0x5e2686;})[_0x178717('0x3e')](respondWithFilteredResult(_0x59bf93,_0x311389))['catch'](handleError(_0x59bf93,null));},exports[_0x49075d('0x44')]=function(_0x14a2e7,_0xd79c04){const _0x317c74=_0x49075d;let _0x562008={'raw':!![],'where':{'id':_0x14a2e7[_0x317c74('0xb')]['id']}};const _0x51f82f={};return _0x51f82f[_0x317c74('0x35')]=_[_0x317c74('0x11')](db[_0x317c74('0x37')][_0x317c74('0x3f')]),_0x51f82f[_0x317c74('0xa')]=_[_0x317c74('0x11')](_0x14a2e7[_0x317c74('0xa')]),_0x51f82f[_0x317c74('0x1')]=_['intersection'](_0x51f82f[_0x317c74('0x35')],_0x51f82f[_0x317c74('0xa')]),_0x562008[_0x317c74('0x36')]=_[_0x317c74('0x1c')](_0x51f82f[_0x317c74('0x35')],qs[_0x317c74('0x28')](_0x14a2e7['query'][_0x317c74('0x28')])),_0x562008[_0x317c74('0x36')]=_0x562008[_0x317c74('0x36')][_0x317c74('0x3b')]?_0x562008['attributes']:_0x51f82f['model'],_0x14a2e7[_0x317c74('0xa')][_0x317c74('0x1e')]&&(_0x562008[_0x317c74('0x8')]=[{'all':!![]}]),_0x562008=_[_0x317c74('0x2')]({},_0x562008,_0x14a2e7[_0x317c74('0x39')]),db[_0x317c74('0x37')][_0x317c74('0x6')](_0x562008)[_0x317c74('0x3e')](handleEntityNotFound(_0xd79c04,null))[_0x317c74('0x3e')](respondWithResult(_0xd79c04,null))[_0x317c74('0x3d')](handleError(_0xd79c04,null));},exports[_0x49075d('0x1f')]=function(_0x10cc93,_0x437f13){const _0x39948b=_0x49075d;return db[_0x39948b('0x37')]['create'](_0x10cc93[_0x39948b('0x2f')],{})[_0x39948b('0x3e')](respondWithResult(_0x437f13,0xc9))[_0x39948b('0x3d')](handleError(_0x437f13,null));},exports[_0x49075d('0x1a')]=function(_0x36c236,_0xcc215b){const _0x329b74=_0x49075d;return _0x36c236[_0x329b74('0x2f')]['id']&&delete _0x36c236[_0x329b74('0x2f')]['id'],db['ChatGroup'][_0x329b74('0x6')]({'where':{'id':_0x36c236[_0x329b74('0xb')]['id']}})[_0x329b74('0x3e')](handleEntityNotFound(_0xcc215b,null))[_0x329b74('0x3e')](saveUpdates(_0x36c236[_0x329b74('0x2f')],null))[_0x329b74('0x3e')](respondWithResult(_0xcc215b,null))[_0x329b74('0x3d')](handleError(_0xcc215b,null));},exports[_0x49075d('0xe')]=function(_0x4cacf1,_0x1478fe){const _0x1c485e=_0x49075d;return db[_0x1c485e('0x37')][_0x1c485e('0x6')]({'where':{'id':_0x4cacf1['params']['id']}})[_0x1c485e('0x3e')](handleEntityNotFound(_0x1478fe,null))[_0x1c485e('0x3e')](removeEntity(_0x1478fe,null))[_0x1c485e('0x3d')](handleError(_0x1478fe,null));},exports[_0x49075d('0x38')]=function(_0x53b8ac,_0x14888e){const _0x1ec5fd=_0x49075d;return db['ChatGroup'][_0x1ec5fd('0x38')]()[_0x1ec5fd('0x3e')](respondWithResult(_0x14888e,null))[_0x1ec5fd('0x3d')](handleError(_0x14888e,null));},exports[_0x49075d('0x32')]=function(_0x27f149,_0x181667){const _0x38759d=_0x49075d;return db[_0x38759d('0x40')][_0x38759d('0x27')]({'where':{'ChatGroupId':_0x27f149['params']['id'],'ToId':_0x27f149[_0x38759d('0x45')]['id'],'read':![]}})[_0x38759d('0x3e')](function(_0x2b6509){const _0x13448c=_0x38759d;return{'id':_['toInteger'](_0x27f149[_0x13448c('0xb')]['id']),'count':_0x2b6509};})[_0x38759d('0x3e')](respondWithResult(_0x181667,null))['catch'](handleError(_0x181667,null));},exports[_0x49075d('0x4')]=function(_0x3277c5,_0x1d4f48){const _0x59f68a=_0x49075d;return db[_0x59f68a('0x37')]['findOne']({'where':{'id':_0x3277c5[_0x59f68a('0xb')]['id']}})['then'](function(_0x2cacad){const _0x3a15b3=_0x59f68a;if(_0x2cacad)return _0x2cacad[_0x3a15b3('0x4')](_0x3277c5[_0x3a15b3('0x2f')][_0x3a15b3('0x18')],{'through':_['omit'](_0x3277c5[_0x3a15b3('0x2f')],[_0x3a15b3('0x18'),'id'])});})[_0x59f68a('0x3e')](respondWithResult(_0x1d4f48,null))[_0x59f68a('0x3d')](handleError(_0x1d4f48,null));},exports[_0x49075d('0x10')]=function(_0x2677ef,_0x43c442){const _0x48299c=_0x49075d;let _0x126179={};const _0x24a6a8={};let _0x5abe24,_0x301a22;return db[_0x48299c('0x37')]['findOne']({'where':{'id':_0x2677ef[_0x48299c('0xb')]['id']}})[_0x48299c('0x3e')](handleEntityNotFound(_0x43c442,null))[_0x48299c('0x3e')](function(_0x125d0b){const _0x3568b8=_0x48299c;if(_0x125d0b)return _0x5abe24=_0x125d0b,_0x24a6a8[_0x3568b8('0x35')]=_[_0x3568b8('0x11')](db[_0x3568b8('0x15')][_0x3568b8('0x3f')]),_0x24a6a8[_0x3568b8('0xa')]=_[_0x3568b8('0x11')](_0x2677ef[_0x3568b8('0xa')]),_0x24a6a8[_0x3568b8('0x1')]=_[_0x3568b8('0x1c')](_0x24a6a8[_0x3568b8('0x35')],_0x24a6a8['query']),_0x126179[_0x3568b8('0x36')]=_['intersection'](_0x24a6a8[_0x3568b8('0x35')],qs[_0x3568b8('0x28')](_0x2677ef[_0x3568b8('0xa')]['fields'])),_0x126179[_0x3568b8('0x36')]=_0x126179[_0x3568b8('0x36')]['length']?_0x126179[_0x3568b8('0x36')]:_0x24a6a8[_0x3568b8('0x35')],_0x126179['order']=qs[_0x3568b8('0x1b')](_0x2677ef['query'][_0x3568b8('0x1b')]),_0x126179[_0x3568b8('0x3c')]=qs[_0x3568b8('0x1')](_[_0x3568b8('0x41')](_0x2677ef['query'],_0x24a6a8[_0x3568b8('0x1')])),_0x2677ef[_0x3568b8('0xa')][_0x3568b8('0x20')]&&(_0x126179['where']=_['merge'](_0x126179[_0x3568b8('0x3c')],{[Op['or']]:_[_0x3568b8('0x2e')](_0x126179[_0x3568b8('0x36')],function(_0x3b92ce){const _0x5a9b26=_0x3568b8,_0x150596={};return _0x150596[_0x3b92ce]={[Op[_0x5a9b26('0x31')]]:'%'+_0x2677ef[_0x5a9b26('0xa')][_0x5a9b26('0x20')]+'%'},_0x150596;})})),_0x126179=_[_0x3568b8('0x2')]({},_0x126179,_0x2677ef[_0x3568b8('0x39')]),_0x5abe24[_0x3568b8('0x10')](_0x126179);})[_0x48299c('0x3e')](function(_0x3f7a1a){const _0x85201d=_0x48299c;if(_0x3f7a1a)return _0x301a22=_0x3f7a1a[_0x85201d('0x3b')],typeof _0x2677ef[_0x85201d('0xa')]['nolimit']===_0x85201d('0x34')&&(_0x126179['limit']=qs[_0x85201d('0x17')](_0x2677ef[_0x85201d('0xa')][_0x85201d('0x17')]),_0x126179[_0x85201d('0x2b')]=qs['offset'](_0x2677ef['query']['offset'])),_0x5abe24[_0x85201d('0x10')](_0x126179);})['then'](function(_0x4c7d22){if(_0x4c7d22)return _0x4c7d22?{'count':_0x301a22,'rows':_0x4c7d22}:null;})[_0x48299c('0x3e')](respondWithResult(_0x43c442,null))[_0x48299c('0x3d')](handleError(_0x43c442,null));},exports[_0x49075d('0x13')]=function(_0x458ef9,_0x5a238b){const _0x323576=_0x49075d;return db[_0x323576('0x37')][_0x323576('0x6')]({'where':{'id':_0x458ef9[_0x323576('0xb')]['id']}})[_0x323576('0x3e')](handleEntityNotFound(_0x5a238b,null))[_0x323576('0x3e')](function(_0x13fc80){const _0x17e189=_0x323576;if(_0x13fc80)return _0x13fc80[_0x17e189('0x13')](_0x458ef9['query'][_0x17e189('0x18')]);})['then'](respondWithStatusCode(_0x5a238b,null))[_0x323576('0x3d')](handleError(_0x5a238b,null));},exports['addMessage']=function(_0x30d703,_0x15eb31){const _0x386ef6=_0x49075d;return _0x30d703['body']['id']&&delete _0x30d703['body']['id'],db[_0x386ef6('0x37')][_0x386ef6('0x6')]({'where':{'id':_0x30d703[_0x386ef6('0xb')]['id']}})[_0x386ef6('0x3e')](handleEntityNotFound(_0x15eb31,null))[_0x386ef6('0x3e')](function(_0xfd3744){const _0x52b05e=_0x386ef6;if(_0xfd3744)return _0x30d703['body']['ChatGroupId']=_0xfd3744['id'],db[_0x52b05e('0x40')][_0x52b05e('0x1f')](_0x30d703['body']);})[_0x386ef6('0x3e')](respondWithResult(_0x15eb31,null))[_0x386ef6('0x3d')](handleError(_0x15eb31,null));},exports[_0x49075d('0x3')]=function(_0x3d4305,_0x37af96){const _0x4c578e=_0x49075d;let _0x44a4a8={};const _0x4c7dc3={};let _0x316ef5,_0x1020b5;return db[_0x4c578e('0x37')][_0x4c578e('0x6')]({'where':{'id':_0x3d4305[_0x4c578e('0xb')]['id']}})[_0x4c578e('0x3e')](handleEntityNotFound(_0x37af96,null))['then'](function(_0x2eeb2f){const _0x69738c=_0x4c578e;if(_0x2eeb2f){_0x316ef5=_0x2eeb2f,_0x4c7dc3[_0x69738c('0x35')]=_[_0x69738c('0x11')](db[_0x69738c('0x40')]['rawAttributes']),_0x4c7dc3[_0x69738c('0xa')]=_[_0x69738c('0x11')](_0x3d4305['query']),_0x4c7dc3['filters']=_['intersection'](_0x4c7dc3['model'],_0x4c7dc3[_0x69738c('0xa')]),_0x44a4a8[_0x69738c('0x36')]=_[_0x69738c('0x1c')](_0x4c7dc3[_0x69738c('0x35')],qs[_0x69738c('0x28')](_0x3d4305[_0x69738c('0xa')][_0x69738c('0x28')])),_0x44a4a8[_0x69738c('0x36')]=_0x44a4a8['attributes'][_0x69738c('0x3b')]?_0x44a4a8[_0x69738c('0x36')]:_0x4c7dc3[_0x69738c('0x35')],_0x44a4a8['order']=qs[_0x69738c('0x1b')](_0x3d4305[_0x69738c('0xa')][_0x69738c('0x1b')]),_0x44a4a8[_0x69738c('0x3c')]=qs['filters'](_[_0x69738c('0x41')](_0x3d4305[_0x69738c('0xa')],_0x4c7dc3[_0x69738c('0x1')]));_0x3d4305['query'][_0x69738c('0x20')]&&(_0x44a4a8[_0x69738c('0x3c')]=_[_0x69738c('0x2')](_0x44a4a8['where'],{[Op['or']]:_[_0x69738c('0x2e')](_0x44a4a8[_0x69738c('0x36')],function(_0x1c3df5){const _0x3784c9=_0x69738c,_0x46d3f0={};return _0x46d3f0[_0x1c3df5]={[Op[_0x3784c9('0x31')]]:'%'+_0x3d4305[_0x3784c9('0xa')][_0x3784c9('0x20')]+'%'},_0x46d3f0;})}));if(_0x3d4305[_0x69738c('0xa')][_0x69738c('0x2c')]){const _0x39b422=_0x3d4305['query'][_0x69738c('0x2c')][_0x69738c('0x21')](','),_0x403f9d={};_0x403f9d[_0x39b422[0x0]]={[Op[_0x69738c('0x1d')]]:moment(_0x39b422[0x1])[_0x69738c('0x2a')]('YYYY-MM-DD\x20HH:mm:ss')},_0x44a4a8[_0x69738c('0x3c')]=_[_0x69738c('0x2')](_0x44a4a8[_0x69738c('0x3c')],_0x403f9d);}return _0x44a4a8=_[_0x69738c('0x2')]({},_0x44a4a8,_0x3d4305[_0x69738c('0x39')]),_0x316ef5[_0x69738c('0x3')](_0x44a4a8);}})['then'](function(_0x2c9d6a){const _0x31e34f=_0x4c578e;if(_0x2c9d6a)return _0x1020b5=_0x2c9d6a[_0x31e34f('0x3b')],typeof _0x3d4305[_0x31e34f('0xa')]['nolimit']===_0x31e34f('0x34')&&(_0x44a4a8[_0x31e34f('0x17')]=qs['limit'](_0x3d4305[_0x31e34f('0xa')][_0x31e34f('0x17')]),_0x44a4a8[_0x31e34f('0x2b')]=qs[_0x31e34f('0x2b')](_0x3d4305['query'][_0x31e34f('0x2b')])),_0x316ef5[_0x31e34f('0x3')](_0x44a4a8);})['then'](function(_0xc4827b){if(_0xc4827b)return _0xc4827b?{'count':_0x1020b5,'rows':_0xc4827b}:null;})[_0x4c578e('0x3e')](respondWithResult(_0x37af96,null))[_0x4c578e('0x3d')](handleError(_0x37af96,null));};
\ No newline at end of file