b9fcce7b152b9b6653a85a569bb6fd22ec92006a
[motion-next.git] / server / api / chatOfflineMessage / chatOfflineMessage.controller.js
1 const a87_0x5d24=['query','api','pick','map','where','like','describe','stack','nolimit','type','destroy','status','name','sendStatus','rawAttributes','show','includeAll','Content-Range','then','options','set','offset','include','fieldName','filters','attributes','findAll','key','end','catch','count','filter','sequelize','body','send','intersection','../../config/logger','params','merge','../../components/parsers/qs','update','fields','error','model','limit','undefined','findOne','sort','json','keys','create','ChatOfflineMessage'];(function(_0xe8b892,_0x5d2445){const _0x103f7a=function(_0x465c4b){while(--_0x465c4b){_0xe8b892['push'](_0xe8b892['shift']());}};_0x103f7a(++_0x5d2445);}(a87_0x5d24,0x120));const a87_0x103f=function(_0xe8b892,_0x5d2445){_0xe8b892=_0xe8b892-0x0;let _0x103f7a=a87_0x5d24[_0xe8b892];return _0x103f7a;};const _0x3d2e29=a87_0x103f;'use strict';const _=require('lodash'),qs=require(_0x3d2e29('0xb')),logger=require(_0x3d2e29('0x8'))(_0x3d2e29('0x19')),db=require('../../mysqldb')['db'],{Op}=require(_0x3d2e29('0x4'));function respondWithResult(_0x465c4b,_0x18085b){return _0x18085b=_0x18085b||0xc8,function(_0x496d3f){const _0x7ad640=a87_0x103f;if(_0x496d3f)return _0x465c4b[_0x7ad640('0x23')](_0x18085b)[_0x7ad640('0x14')](_0x496d3f);};}function respondWithFilteredResult(_0xfa421f,_0x24ae90){return function(_0x4175cf){const _0x5913fb=a87_0x103f;if(_0x4175cf){const _0x3ef875=_0x4175cf[_0x5913fb('0x2')],_0x5976a9=_0x24ae90['offset'];let _0xc0bcfd=_0x24ae90[_0x5913fb('0x2d')]+_0x24ae90[_0x5913fb('0x10')],_0x3362ed;return _0xc0bcfd>=_0x3ef875?(_0xc0bcfd=_0x3ef875,_0x3362ed=0xc8):_0x3362ed=0xce,_0xfa421f[_0x5913fb('0x23')](_0x3362ed),_0xfa421f[_0x5913fb('0x2c')](_0x5913fb('0x29'),_0x5976a9+'-'+_0xc0bcfd+'/'+_0x3ef875)['json'](_0x4175cf);}return null;};}function saveUpdates(_0xd0d02f){return function(_0x26ddf9){const _0x625007=a87_0x103f;if(_0x26ddf9)return _0x26ddf9['update'](_0xd0d02f)[_0x625007('0x2a')](function(_0x49f304){return _0x49f304;});return null;};}function removeEntity(_0xefd7ee){return function(_0x52e3b9){const _0x337927=a87_0x103f;if(_0x52e3b9)return _0x52e3b9[_0x337927('0x22')]()[_0x337927('0x2a')](function(){const _0x1f11bf=_0x337927;_0xefd7ee['status'](0xcc)[_0x1f11bf('0x0')]();});};}function handleEntityNotFound(_0x17372d){return function(_0xaac3a4){const _0x5a04f3=a87_0x103f;return!_0xaac3a4&&_0x17372d[_0x5a04f3('0x25')](0x194),_0xaac3a4;};}function handleError(_0x5ad5fe,_0x45860d){return _0x45860d=_0x45860d||0x1f4,function(_0x329a29){const _0xa025b=a87_0x103f;logger[_0xa025b('0xe')](_0x329a29[_0xa025b('0x1f')]),_0x329a29[_0xa025b('0x24')]&&delete _0x329a29[_0xa025b('0x24')],_0x5ad5fe[_0xa025b('0x23')](_0x45860d)[_0xa025b('0x6')](_0x329a29);};}exports['index']=function(_0x3ab9c9,_0x3ad16c){const _0x1cc575=_0x3d2e29;let _0x74e2f8={};const _0x358f99={},_0x23bb34={'count':0x0,'rows':[]},_0x56c27f=_[_0x1cc575('0x1b')](db['ChatOfflineMessage'][_0x1cc575('0x26')],function(_0x530a23){const _0x29fd06=_0x1cc575;return{'name':_0x530a23[_0x29fd06('0x2f')],'type':_0x530a23[_0x29fd06('0x21')][_0x29fd06('0x33')]};});_0x358f99['model']=_[_0x1cc575('0x1b')](_0x56c27f,_0x1cc575('0x24')),_0x358f99[_0x1cc575('0x18')]=_[_0x1cc575('0x15')](_0x3ab9c9[_0x1cc575('0x18')]),_0x358f99[_0x1cc575('0x30')]=_[_0x1cc575('0x7')](_0x358f99[_0x1cc575('0xf')],_0x358f99[_0x1cc575('0x18')]),_0x74e2f8[_0x1cc575('0x31')]=_[_0x1cc575('0x7')](_0x358f99[_0x1cc575('0xf')],qs[_0x1cc575('0xd')](_0x3ab9c9[_0x1cc575('0x18')][_0x1cc575('0xd')])),_0x74e2f8[_0x1cc575('0x31')]=_0x74e2f8[_0x1cc575('0x31')]['length']?_0x74e2f8[_0x1cc575('0x31')]:_0x358f99[_0x1cc575('0xf')];typeof _0x3ab9c9[_0x1cc575('0x18')][_0x1cc575('0x20')]===_0x1cc575('0x11')&&(_0x74e2f8['limit']=qs[_0x1cc575('0x10')](_0x3ab9c9[_0x1cc575('0x18')]['limit']),_0x74e2f8['offset']=qs[_0x1cc575('0x2d')](_0x3ab9c9[_0x1cc575('0x18')]['offset']));_0x74e2f8['order']=qs[_0x1cc575('0x13')](_0x3ab9c9[_0x1cc575('0x18')][_0x1cc575('0x13')]),_0x74e2f8['where']=qs['filters'](_[_0x1cc575('0x1a')](_0x3ab9c9[_0x1cc575('0x18')],_0x358f99[_0x1cc575('0x30')]),_0x56c27f);_0x3ab9c9['query'][_0x1cc575('0x3')]&&(_0x74e2f8['where']=_[_0x1cc575('0xa')](_0x74e2f8['where'],{[Op['or']]:_['map'](_0x56c27f,function(_0x232bd0){const _0x28196c=_0x1cc575;if(_0x232bd0[_0x28196c('0x21')]!=='VIRTUAL'){const _0x52a7fd={};return _0x52a7fd[_0x232bd0[_0x28196c('0x24')]]={[Op[_0x28196c('0x1d')]]:'%'+_0x3ab9c9[_0x28196c('0x18')][_0x28196c('0x3')]+'%'},_0x52a7fd;}})}));_0x74e2f8=_[_0x1cc575('0xa')]({},_0x74e2f8,_0x3ab9c9[_0x1cc575('0x2b')]);const _0x163185={'where':_0x74e2f8[_0x1cc575('0x1c')]};return db[_0x1cc575('0x17')][_0x1cc575('0x2')](_0x163185)[_0x1cc575('0x2a')](function(_0x53dce7){const _0x15c168=_0x1cc575;return _0x23bb34[_0x15c168('0x2')]=_0x53dce7,_0x3ab9c9['query'][_0x15c168('0x28')]&&(_0x74e2f8['include']=[{'all':!![]}]),db[_0x15c168('0x17')][_0x15c168('0x32')](_0x74e2f8);})[_0x1cc575('0x2a')](function(_0x4410e2){return _0x23bb34['rows']=_0x4410e2,_0x23bb34;})['then'](respondWithFilteredResult(_0x3ad16c,_0x74e2f8))[_0x1cc575('0x1')](handleError(_0x3ad16c,null));},exports[_0x3d2e29('0x27')]=function(_0x211500,_0x153551){const _0x42dea5=_0x3d2e29;let _0x34f702={'raw':!![],'where':{'id':_0x211500['params']['id']}};const _0x4207e1={};return _0x4207e1[_0x42dea5('0xf')]=_['keys'](db['ChatOfflineMessage'][_0x42dea5('0x26')]),_0x4207e1[_0x42dea5('0x18')]=_[_0x42dea5('0x15')](_0x211500[_0x42dea5('0x18')]),_0x4207e1['filters']=_[_0x42dea5('0x7')](_0x4207e1[_0x42dea5('0xf')],_0x4207e1[_0x42dea5('0x18')]),_0x34f702['attributes']=_['intersection'](_0x4207e1[_0x42dea5('0xf')],qs['fields'](_0x211500[_0x42dea5('0x18')][_0x42dea5('0xd')])),_0x34f702['attributes']=_0x34f702['attributes']['length']?_0x34f702['attributes']:_0x4207e1[_0x42dea5('0xf')],_0x211500[_0x42dea5('0x18')][_0x42dea5('0x28')]&&(_0x34f702[_0x42dea5('0x2e')]=[{'all':!![]}]),_0x34f702=_['merge']({},_0x34f702,_0x211500[_0x42dea5('0x2b')]),db[_0x42dea5('0x17')][_0x42dea5('0x12')](_0x34f702)[_0x42dea5('0x2a')](handleEntityNotFound(_0x153551,null))[_0x42dea5('0x2a')](respondWithResult(_0x153551,null))[_0x42dea5('0x1')](handleError(_0x153551,null));},exports['create']=function(_0xf3dc4d,_0xd28ff5){const _0x2a2f65=_0x3d2e29;return db[_0x2a2f65('0x17')][_0x2a2f65('0x16')](_0xf3dc4d[_0x2a2f65('0x5')],{})['then'](respondWithResult(_0xd28ff5,0xc9))[_0x2a2f65('0x1')](handleError(_0xd28ff5,null));},exports[_0x3d2e29('0xc')]=function(_0x5c65c0,_0x1335b8){const _0x248fbe=_0x3d2e29;return _0x5c65c0[_0x248fbe('0x5')]['id']&&delete _0x5c65c0[_0x248fbe('0x5')]['id'],db[_0x248fbe('0x17')][_0x248fbe('0x12')]({'where':{'id':_0x5c65c0[_0x248fbe('0x9')]['id']}})[_0x248fbe('0x2a')](handleEntityNotFound(_0x1335b8,null))['then'](saveUpdates(_0x5c65c0[_0x248fbe('0x5')],null))[_0x248fbe('0x2a')](respondWithResult(_0x1335b8,null))[_0x248fbe('0x1')](handleError(_0x1335b8,null));},exports[_0x3d2e29('0x22')]=function(_0x4a414c,_0xd5b1f8){const _0x192951=_0x3d2e29;return db[_0x192951('0x17')][_0x192951('0x12')]({'where':{'id':_0x4a414c['params']['id']}})[_0x192951('0x2a')](handleEntityNotFound(_0xd5b1f8,null))[_0x192951('0x2a')](removeEntity(_0xd5b1f8,null))[_0x192951('0x1')](handleError(_0xd5b1f8,null));},exports[_0x3d2e29('0x1e')]=function(_0x24a820,_0x442c6e){const _0x599efd=_0x3d2e29;return db[_0x599efd('0x17')][_0x599efd('0x1e')]()[_0x599efd('0x2a')](respondWithResult(_0x442c6e,null))['catch'](handleError(_0x442c6e,null));};