Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index b53b652..1846643 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb4fa=['bluebird','path','rimraf','../../config/environment','./openchannelMessage.attributes','exports','define','openchannel_messages','fti_openchannel_messages','body','FULLTEXT','get','direction','toLowerCase','out','OpenchannelInteraction','OpenchannelInteractionId','then','update','createdAt','catch','error','secret','CmContact','describe','find','Interactions','keys','replyUri','info','OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','Forwarding\x20message\x20%d\x20to\x20%s','length','omit','Contact','POST','method','Message\x20%d\x20forwarded\x20to\x20%s','threadId','Interaction','inspect','finally','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','api','moment'];(function(_0x31f22e,_0x434db1){var _0x16e1b0=function(_0x4f5355){while(--_0x4f5355){_0x31f22e['push'](_0x31f22e['shift']());}};_0x16e1b0(++_0x434db1);}(_0xb4fa,0x1f0));var _0xab4f=function(_0x2aa891,_0x388317){_0x2aa891=_0x2aa891-0x0;var _0x4380c4=_0xb4fa[_0x2aa891];return _0x4380c4;};'use strict';var _=require(_0xab4f('0x0'));var util=require('util');var logger=require(_0xab4f('0x1'))(_0xab4f('0x2'));var moment=require(_0xab4f('0x3'));var BPromise=require(_0xab4f('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xab4f('0x5'));var rimraf=require(_0xab4f('0x6'));var config=require(_0xab4f('0x7'));var attributes=require(_0xab4f('0x8'));module[_0xab4f('0x9')]=function(_0x23ed14,_0x505e82){return _0x23ed14[_0xab4f('0xa')]('OpenchannelMessage',attributes,{'tableName':_0xab4f('0xb'),'paranoid':![],'indexes':[{'name':_0xab4f('0xc'),'fields':[_0xab4f('0xd')],'type':_0xab4f('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x4b61fd,_0x364fd9,_0x5abcda){var _0x32cabe=_0x23ed14['models'];var _0x23b5ea=_0x4b61fd[_0xab4f('0xf')]({'plain':!![]});if(_0x23b5ea[_0xab4f('0x10')][_0xab4f('0x11')]()==='in'||_0x23b5ea['direction'][_0xab4f('0x11')]()===_0xab4f('0x12')&&!_0x23b5ea['secret']&&!_['isNil'](_0x23b5ea['UserId'])){_0x32cabe[_0xab4f('0x13')]['findOne']({'where':{'id':_0x23b5ea[_0xab4f('0x14')]}})[_0xab4f('0x15')](function(_0x45dda5){if(_0x45dda5){_0x45dda5[_0xab4f('0x16')]({'lastMsgAt':_0x23b5ea[_0xab4f('0x17')],'lastMsgDirection':_0x23b5ea['direction'][_0xab4f('0x11')]()});}})[_0xab4f('0x18')](function(_0x17e7f7){console[_0xab4f('0x19')](_0x17e7f7);});}if(_0x23b5ea[_0xab4f('0x10')]==='out'&&!_0x23b5ea[_0xab4f('0x1a')]){var _0x54d0ff;_0x32cabe[_0xab4f('0x1b')][_0xab4f('0x1c')]()[_0xab4f('0x15')](function(_0x47860c){return _0x32cabe['OpenchannelAccount'][_0xab4f('0x1d')]({'where':{'id':_0x23b5ea['OpenchannelAccountId']},'include':[{'model':_0x32cabe[_0xab4f('0x13')],'as':_0xab4f('0x1e'),'where':{'id':_0x23b5ea[_0xab4f('0x14')]},'limit':0x1,'include':[{'model':_0x32cabe[_0xab4f('0x1b')],'as':'Contact','attributes':_[_0xab4f('0x1f')](_0x47860c)}]}]});})[_0xab4f('0x15')](function(_0x2a1348){_0x54d0ff=_0x2a1348[_0xab4f('0xf')]({'plain':!![]});if(_0x54d0ff&&_0x54d0ff[_0xab4f('0x20')]){logger[_0xab4f('0x21')](_0xab4f('0x22'),_0xab4f('0x23'),util[_0xab4f('0x24')](_0xab4f('0x25'),_0x23b5ea['id'],_0x54d0ff['replyUri']));if(_0x54d0ff[_0xab4f('0x1e')]&&_0x54d0ff['Interactions'][_0xab4f('0x26')]){_0x23b5ea['Interaction']=_[_0xab4f('0x27')](_0x54d0ff['Interactions'][0x0],_0xab4f('0x28'));_0x23b5ea['Contact']=_0x54d0ff['Interactions'][0x0]['Contact'];}var _0x364fd9={'method':_0xab4f('0x29'),'uri':encodeURI(_0x54d0ff[_0xab4f('0x20')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x364fd9[_0xab4f('0x2a')]){case'GET':_0x364fd9['qs']=_0x23b5ea;break;case _0xab4f('0x29'):_0x364fd9['body']=_0x23b5ea;break;}return rp(_0x364fd9)[_0xab4f('0x15')](function(_0x3e1574){logger[_0xab4f('0x21')]('OpenchannelMessage,\x20%s,\x20%s',_0xab4f('0x23'),util[_0xab4f('0x24')](_0xab4f('0x2b'),_0x23b5ea['id'],_0x54d0ff['replyUri']));if(_0x3e1574['body']['threadId']&&_0x3e1574[_0xab4f('0xd')][_0xab4f('0x2c')]!=_0x23b5ea[_0xab4f('0x2d')][_0xab4f('0x2c')]){return _0x32cabe[_0xab4f('0x13')][_0xab4f('0x16')]({'threadId':_0x3e1574['body'][_0xab4f('0x2c')]},{'logging':!![],'where':{'id':_0x23b5ea['Interaction']['id']}});}else{return;}})[_0xab4f('0x15')](function(){return _0x4b61fd[_0xab4f('0x16')]({'read':!![]});})['catch'](function(_0x128815){logger['error'](_0xab4f('0x22'),_0xab4f('0x23'),util[_0xab4f('0x2e')](_0x128815,{'showHidden':![],'depth':null}));_0x5abcda();});}else{_0x5abcda();}})[_0xab4f('0x2f')](function(){_0x5abcda();});}else{_0x5abcda();}}},'charset':_0xab4f('0x30'),'collate':_0xab4f('0x31')});};
\ No newline at end of file
+var _0xdb6e=['catch','error','describe','then','OpenchannelAccount','find','OpenchannelAccountId','CmContact','keys','OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','Forwarding\x20message\x20%d\x20to\x20%s','Interactions','length','omit','Contact','POST','replyUri','GET','Message\x20%d\x20forwarded\x20to\x20%s','body','threadId','Interaction','utf8mb4','lodash','util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./openchannelMessage.attributes','exports','OpenchannelMessage','fti_openchannel_messages','FULLTEXT','models','direction','toLowerCase','out','secret','isNil','OpenchannelInteraction','findOne','OpenchannelInteractionId','update','createdAt'];(function(_0x3a030a,_0x19bbda){var _0xf887dc=function(_0x211f20){while(--_0x211f20){_0x3a030a['push'](_0x3a030a['shift']());}};_0xf887dc(++_0x19bbda);}(_0xdb6e,0x145));var _0xedb6=function(_0x5941b7,_0x499160){_0x5941b7=_0x5941b7-0x0;var _0x2ae4df=_0xdb6e[_0x5941b7];return _0x2ae4df;};'use strict';var _=require(_0xedb6('0x0'));var util=require(_0xedb6('0x1'));var logger=require('../../config/logger')(_0xedb6('0x2'));var moment=require(_0xedb6('0x3'));var BPromise=require(_0xedb6('0x4'));var rp=require(_0xedb6('0x5'));var fs=require('fs');var path=require(_0xedb6('0x6'));var rimraf=require(_0xedb6('0x7'));var config=require(_0xedb6('0x8'));var attributes=require(_0xedb6('0x9'));module[_0xedb6('0xa')]=function(_0x43032e,_0x244ecf){return _0x43032e['define'](_0xedb6('0xb'),attributes,{'tableName':'openchannel_messages','paranoid':![],'indexes':[{'name':_0xedb6('0xc'),'fields':['body'],'type':_0xedb6('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x27e2d0,_0x3d1c6b,_0x2d7a7a){var _0x285cbf=_0x43032e[_0xedb6('0xe')];var _0x18b24e=_0x27e2d0['get']({'plain':!![]});if(_0x18b24e[_0xedb6('0xf')][_0xedb6('0x10')]()==='in'||_0x18b24e[_0xedb6('0xf')][_0xedb6('0x10')]()===_0xedb6('0x11')&&!_0x18b24e[_0xedb6('0x12')]&&!_[_0xedb6('0x13')](_0x18b24e['UserId'])){_0x285cbf[_0xedb6('0x14')][_0xedb6('0x15')]({'where':{'id':_0x18b24e[_0xedb6('0x16')]}})['then'](function(_0x5dc3b6){if(_0x5dc3b6){_0x5dc3b6[_0xedb6('0x17')]({'lastMsgAt':_0x18b24e[_0xedb6('0x18')],'lastMsgDirection':_0x18b24e[_0xedb6('0xf')][_0xedb6('0x10')]()});}})[_0xedb6('0x19')](function(_0x26cb18){console[_0xedb6('0x1a')](_0x26cb18);});}if(_0x18b24e[_0xedb6('0xf')]===_0xedb6('0x11')&&!_0x18b24e['secret']){var _0x4d364a;_0x285cbf['CmContact'][_0xedb6('0x1b')]()[_0xedb6('0x1c')](function(_0x169fde){return _0x285cbf[_0xedb6('0x1d')][_0xedb6('0x1e')]({'where':{'id':_0x18b24e[_0xedb6('0x1f')]},'include':[{'model':_0x285cbf[_0xedb6('0x14')],'as':'Interactions','where':{'id':_0x18b24e['OpenchannelInteractionId']},'limit':0x1,'include':[{'model':_0x285cbf[_0xedb6('0x20')],'as':'Contact','attributes':_[_0xedb6('0x21')](_0x169fde)}]}]});})[_0xedb6('0x1c')](function(_0x4320c8){_0x4d364a=_0x4320c8['get']({'plain':!![]});if(_0x4d364a&&_0x4d364a['replyUri']){logger['info'](_0xedb6('0x22'),_0xedb6('0x23'),util[_0xedb6('0x24')](_0xedb6('0x25'),_0x18b24e['id'],_0x4d364a['replyUri']));if(_0x4d364a[_0xedb6('0x26')]&&_0x4d364a[_0xedb6('0x26')][_0xedb6('0x27')]){_0x18b24e['Interaction']=_[_0xedb6('0x28')](_0x4d364a[_0xedb6('0x26')][0x0],_0xedb6('0x29'));_0x18b24e['Contact']=_0x4d364a[_0xedb6('0x26')][0x0]['Contact'];}var _0x3d1c6b={'method':_0xedb6('0x2a'),'uri':encodeURI(_0x4d364a[_0xedb6('0x2b')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x3d1c6b['method']){case _0xedb6('0x2c'):_0x3d1c6b['qs']=_0x18b24e;break;case _0xedb6('0x2a'):_0x3d1c6b['body']=_0x18b24e;break;}return rp(_0x3d1c6b)[_0xedb6('0x1c')](function(_0x5c0606){logger['info'](_0xedb6('0x22'),'afterCreate',util[_0xedb6('0x24')](_0xedb6('0x2d'),_0x18b24e['id'],_0x4d364a['replyUri']));if(_0x5c0606[_0xedb6('0x2e')]['threadId']&&_0x5c0606[_0xedb6('0x2e')][_0xedb6('0x2f')]!=_0x18b24e[_0xedb6('0x30')]['threadId']){return _0x285cbf[_0xedb6('0x14')][_0xedb6('0x17')]({'threadId':_0x5c0606[_0xedb6('0x2e')][_0xedb6('0x2f')]},{'where':{'id':_0x18b24e[_0xedb6('0x30')]['id']}});}else{return;}})[_0xedb6('0x1c')](function(){return _0x27e2d0[_0xedb6('0x17')]({'read':!![]});})[_0xedb6('0x19')](function(_0x44bfbe){logger[_0xedb6('0x1a')](_0xedb6('0x22'),_0xedb6('0x23'),util['inspect'](_0x44bfbe,{'showHidden':![],'depth':null}));_0x2d7a7a();});}else{_0x2d7a7a();}})['finally'](function(){_0x2d7a7a();});}else{_0x2d7a7a();}}},'charset':_0xedb6('0x31'),'collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file