Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index e231da1..f034435 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5eb8=['OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','Forwarding\x20message\x20%d\x20to\x20%s','replyUri','omit','POST','method','GET','info','body','Interaction','threadId','inspect','finally','utf8mb4','utf8mb4_unicode_ci','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./openchannelMessage.attributes','exports','OpenchannelMessage','openchannel_messages','fti_openchannel_messages','FULLTEXT','models','get','direction','toLowerCase','secret','isNil','UserId','OpenchannelInteraction','then','update','createdAt','catch','error','out','CmContact','OpenchannelAccount','find','OpenchannelAccountId','Interactions','OpenchannelInteractionId','Contact','keys'];(function(_0x551ad0,_0x6f4102){var _0x4a75d2=function(_0x3a051a){while(--_0x3a051a){_0x551ad0['push'](_0x551ad0['shift']());}};_0x4a75d2(++_0x6f4102);}(_0x5eb8,0xb0));var _0x85eb=function(_0x300e96,_0x329b01){_0x300e96=_0x300e96-0x0;var _0x3a4fe6=_0x5eb8[_0x300e96];return _0x3a4fe6;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x85eb('0x0'))(_0x85eb('0x1'));var moment=require(_0x85eb('0x2'));var BPromise=require(_0x85eb('0x3'));var rp=require(_0x85eb('0x4'));var fs=require('fs');var path=require(_0x85eb('0x5'));var rimraf=require(_0x85eb('0x6'));var config=require(_0x85eb('0x7'));var attributes=require(_0x85eb('0x8'));module[_0x85eb('0x9')]=function(_0x2bf83c,_0x1ba1d8){return _0x2bf83c['define'](_0x85eb('0xa'),attributes,{'tableName':_0x85eb('0xb'),'paranoid':![],'indexes':[{'name':_0x85eb('0xc'),'fields':['body'],'type':_0x85eb('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x50ea77,_0x1f0036,_0x40d6b6){var _0x673228=_0x2bf83c[_0x85eb('0xe')];var _0x1dacf2=_0x50ea77[_0x85eb('0xf')]({'plain':!![]});if(_0x1dacf2[_0x85eb('0x10')]['toLowerCase']()==='in'||_0x1dacf2[_0x85eb('0x10')][_0x85eb('0x11')]()==='out'&&!_0x1dacf2[_0x85eb('0x12')]&&!_[_0x85eb('0x13')](_0x1dacf2[_0x85eb('0x14')])){_0x673228[_0x85eb('0x15')]['findOne']({'where':{'id':_0x1dacf2['OpenchannelInteractionId']}})[_0x85eb('0x16')](function(_0x5c760a){if(_0x5c760a){_0x5c760a[_0x85eb('0x17')]({'lastMsgAt':_0x1dacf2[_0x85eb('0x18')],'lastMsgDirection':_0x1dacf2[_0x85eb('0x10')][_0x85eb('0x11')]()});}})[_0x85eb('0x19')](function(_0x49efdf){console[_0x85eb('0x1a')](_0x49efdf);});}if(_0x1dacf2['direction']===_0x85eb('0x1b')&&!_0x1dacf2[_0x85eb('0x12')]){var _0x3e23e8;_0x673228[_0x85eb('0x1c')]['describe']()['then'](function(_0x50d2a8){return _0x673228[_0x85eb('0x1d')][_0x85eb('0x1e')]({'where':{'id':_0x1dacf2[_0x85eb('0x1f')]},'include':[{'model':_0x673228[_0x85eb('0x15')],'as':_0x85eb('0x20'),'where':{'id':_0x1dacf2[_0x85eb('0x21')]},'limit':0x1,'include':[{'model':_0x673228['CmContact'],'as':_0x85eb('0x22'),'attributes':_[_0x85eb('0x23')](_0x50d2a8)}]}]});})[_0x85eb('0x16')](function(_0x4e8041){_0x3e23e8=_0x4e8041['get']({'plain':!![]});if(_0x3e23e8&&_0x3e23e8['replyUri']){logger['info'](_0x85eb('0x24'),_0x85eb('0x25'),util[_0x85eb('0x26')](_0x85eb('0x27'),_0x1dacf2['id'],_0x3e23e8[_0x85eb('0x28')]));if(_0x3e23e8[_0x85eb('0x20')]&&_0x3e23e8['Interactions']['length']){_0x1dacf2['Interaction']=_[_0x85eb('0x29')](_0x3e23e8[_0x85eb('0x20')][0x0],_0x85eb('0x22'));_0x1dacf2[_0x85eb('0x22')]=_0x3e23e8[_0x85eb('0x20')][0x0][_0x85eb('0x22')];}var _0x1f0036={'method':_0x85eb('0x2a'),'uri':encodeURI(_0x3e23e8[_0x85eb('0x28')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x1f0036[_0x85eb('0x2b')]){case _0x85eb('0x2c'):_0x1f0036['qs']=_0x1dacf2;break;case _0x85eb('0x2a'):_0x1f0036['body']=_0x1dacf2;break;}return rp(_0x1f0036)[_0x85eb('0x16')](function(_0x792d3a){logger[_0x85eb('0x2d')](_0x85eb('0x24'),_0x85eb('0x25'),util[_0x85eb('0x26')]('Message\x20%d\x20forwarded\x20to\x20%s',_0x1dacf2['id'],_0x3e23e8['replyUri']));if(_0x792d3a[_0x85eb('0x2e')]['threadId']&&_0x792d3a[_0x85eb('0x2e')]['threadId']!=_0x1dacf2[_0x85eb('0x2f')][_0x85eb('0x30')]){return _0x673228[_0x85eb('0x15')][_0x85eb('0x17')]({'threadId':_0x792d3a[_0x85eb('0x2e')][_0x85eb('0x30')]},{'logging':!![],'where':{'id':_0x1dacf2[_0x85eb('0x2f')]['id']}});}else{return;}})['then'](function(){return _0x50ea77[_0x85eb('0x17')]({'read':!![]});})[_0x85eb('0x19')](function(_0x515ee9){logger[_0x85eb('0x1a')]('OpenchannelMessage,\x20%s,\x20%s','afterCreate',util[_0x85eb('0x31')](_0x515ee9,{'showHidden':![],'depth':null}));_0x40d6b6();});}else{_0x40d6b6();}})[_0x85eb('0x32')](function(){_0x40d6b6();});}else{_0x40d6b6();}}},'charset':_0x85eb('0x33'),'collate':_0x85eb('0x34')});};
\ No newline at end of file
+var _0x3d34=['FULLTEXT','models','get','direction','toLowerCase','out','isNil','UserId','OpenchannelInteraction','findOne','OpenchannelInteractionId','then','update','createdAt','catch','secret','CmContact','OpenchannelAccount','find','OpenchannelAccountId','Contact','replyUri','info','afterCreate','format','Interactions','length','Interaction','POST','method','GET','OpenchannelMessage,\x20%s,\x20%s','Message\x20%d\x20forwarded\x20to\x20%s','threadId','error','inspect','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','request-promise','rimraf','../../config/environment','./openchannelMessage.attributes','exports','define','OpenchannelMessage','openchannel_messages','fti_openchannel_messages','body'];(function(_0x11da19,_0x5bebb9){var _0x25c772=function(_0x5a90d9){while(--_0x5a90d9){_0x11da19['push'](_0x11da19['shift']());}};_0x25c772(++_0x5bebb9);}(_0x3d34,0x93));var _0x43d3=function(_0x3a8d18,_0x34096f){_0x3a8d18=_0x3a8d18-0x0;var _0x13cb5d=_0x3d34[_0x3a8d18];return _0x13cb5d;};'use strict';var _=require(_0x43d3('0x0'));var util=require(_0x43d3('0x1'));var logger=require(_0x43d3('0x2'))(_0x43d3('0x3'));var moment=require('moment');var BPromise=require(_0x43d3('0x4'));var rp=require(_0x43d3('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0x43d3('0x6'));var config=require(_0x43d3('0x7'));var attributes=require(_0x43d3('0x8'));module[_0x43d3('0x9')]=function(_0x3f63d5,_0x3661b9){return _0x3f63d5[_0x43d3('0xa')](_0x43d3('0xb'),attributes,{'tableName':_0x43d3('0xc'),'paranoid':![],'indexes':[{'name':_0x43d3('0xd'),'fields':[_0x43d3('0xe')],'type':_0x43d3('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5216b9,_0x3b37bd,_0x24f0cb){var _0x3d45c2=_0x3f63d5[_0x43d3('0x10')];var _0x4f694b=_0x5216b9[_0x43d3('0x11')]({'plain':!![]});if(_0x4f694b[_0x43d3('0x12')][_0x43d3('0x13')]()==='in'||_0x4f694b['direction'][_0x43d3('0x13')]()===_0x43d3('0x14')&&!_0x4f694b['secret']&&!_[_0x43d3('0x15')](_0x4f694b[_0x43d3('0x16')])){_0x3d45c2[_0x43d3('0x17')][_0x43d3('0x18')]({'where':{'id':_0x4f694b[_0x43d3('0x19')]}})[_0x43d3('0x1a')](function(_0x2e22d2){if(_0x2e22d2){_0x2e22d2[_0x43d3('0x1b')]({'lastMsgAt':_0x4f694b[_0x43d3('0x1c')],'lastMsgDirection':_0x4f694b['direction'][_0x43d3('0x13')]()});}})[_0x43d3('0x1d')](function(_0x4a28e7){console['error'](_0x4a28e7);});}if(_0x4f694b['direction']===_0x43d3('0x14')&&!_0x4f694b[_0x43d3('0x1e')]){var _0x3a483b;_0x3d45c2[_0x43d3('0x1f')]['describe']()[_0x43d3('0x1a')](function(_0x120cf4){return _0x3d45c2[_0x43d3('0x20')][_0x43d3('0x21')]({'where':{'id':_0x4f694b[_0x43d3('0x22')]},'include':[{'model':_0x3d45c2[_0x43d3('0x17')],'as':'Interactions','where':{'id':_0x4f694b[_0x43d3('0x19')]},'limit':0x1,'include':[{'model':_0x3d45c2[_0x43d3('0x1f')],'as':_0x43d3('0x23'),'attributes':_['keys'](_0x120cf4)}]}]});})['then'](function(_0x539c7e){_0x3a483b=_0x539c7e[_0x43d3('0x11')]({'plain':!![]});if(_0x3a483b&&_0x3a483b[_0x43d3('0x24')]){logger[_0x43d3('0x25')]('OpenchannelMessage,\x20%s,\x20%s',_0x43d3('0x26'),util[_0x43d3('0x27')]('Forwarding\x20message\x20%d\x20to\x20%s',_0x4f694b['id'],_0x3a483b[_0x43d3('0x24')]));if(_0x3a483b[_0x43d3('0x28')]&&_0x3a483b['Interactions'][_0x43d3('0x29')]){_0x4f694b[_0x43d3('0x2a')]=_['omit'](_0x3a483b[_0x43d3('0x28')][0x0],'Contact');_0x4f694b[_0x43d3('0x23')]=_0x3a483b[_0x43d3('0x28')][0x0][_0x43d3('0x23')];}var _0x3b37bd={'method':_0x43d3('0x2b'),'uri':encodeURI(_0x3a483b[_0x43d3('0x24')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x3b37bd[_0x43d3('0x2c')]){case _0x43d3('0x2d'):_0x3b37bd['qs']=_0x4f694b;break;case _0x43d3('0x2b'):_0x3b37bd[_0x43d3('0xe')]=_0x4f694b;break;}return rp(_0x3b37bd)[_0x43d3('0x1a')](function(_0x27ff74){logger['info'](_0x43d3('0x2e'),_0x43d3('0x26'),util[_0x43d3('0x27')](_0x43d3('0x2f'),_0x4f694b['id'],_0x3a483b[_0x43d3('0x24')]));if(_0x27ff74[_0x43d3('0xe')]['threadId']&&_0x27ff74[_0x43d3('0xe')][_0x43d3('0x30')]!=_0x4f694b[_0x43d3('0x2a')][_0x43d3('0x30')]){return _0x3d45c2['OpenchannelInteraction'][_0x43d3('0x1b')]({'threadId':_0x27ff74['body'][_0x43d3('0x30')]},{'where':{'id':_0x4f694b['Interaction']['id']}});}else{return;}})[_0x43d3('0x1a')](function(){return _0x5216b9[_0x43d3('0x1b')]({'read':!![]});})[_0x43d3('0x1d')](function(_0x14ed5b){logger[_0x43d3('0x31')](_0x43d3('0x2e'),_0x43d3('0x26'),util[_0x43d3('0x32')](_0x14ed5b,{'showHidden':![],'depth':null}));_0x24f0cb();});}else{_0x24f0cb();}})[_0x43d3('0x33')](function(){_0x24f0cb();});}else{_0x24f0cb();}}},'charset':_0x43d3('0x34'),'collate':_0x43d3('0x35')});};
\ No newline at end of file