Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index d4d4320..f0b3c83 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8c6b=['OpenchannelAccount','find','Interactions','Contact','keys','OpenchannelMessage,\x20%s,\x20%s','Forwarding\x20message\x20%d\x20to\x20%s','replyUri','length','omit','POST','method','GET','info','afterCreate','format','Message\x20%d\x20forwarded\x20to\x20%s','threadId','Interaction','inspect','finally','utf8mb4_unicode_ci','lodash','api','bluebird','request-promise','path','rimraf','./openchannelMessage.attributes','exports','define','OpenchannelMessage','openchannel_messages','fti_openchannel_messages','body','FULLTEXT','models','get','toLowerCase','secret','isNil','UserId','OpenchannelInteraction','findOne','OpenchannelInteractionId','update','direction','catch','error','CmContact','describe','then'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x8c6b,0x1ea));var _0xb8c6=function(_0x337e04,_0x45dca8){_0x337e04=_0x337e04-0x0;var _0x237b90=_0x8c6b[_0x337e04];return _0x237b90;};'use strict';var _=require(_0xb8c6('0x0'));var util=require('util');var logger=require('../../config/logger')(_0xb8c6('0x1'));var moment=require('moment');var BPromise=require(_0xb8c6('0x2'));var rp=require(_0xb8c6('0x3'));var fs=require('fs');var path=require(_0xb8c6('0x4'));var rimraf=require(_0xb8c6('0x5'));var config=require('../../config/environment');var attributes=require(_0xb8c6('0x6'));module[_0xb8c6('0x7')]=function(_0x4bec70,_0x9b4dee){return _0x4bec70[_0xb8c6('0x8')](_0xb8c6('0x9'),attributes,{'tableName':_0xb8c6('0xa'),'paranoid':![],'indexes':[{'name':_0xb8c6('0xb'),'fields':[_0xb8c6('0xc')],'type':_0xb8c6('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5194fd,_0xa08be7,_0x520319){var _0x37b3fb=_0x4bec70[_0xb8c6('0xe')];var _0x293a5a=_0x5194fd[_0xb8c6('0xf')]({'plain':!![]});if(_0x293a5a['direction']['toLowerCase']()==='in'||_0x293a5a['direction'][_0xb8c6('0x10')]()==='out'&&!_0x293a5a[_0xb8c6('0x11')]&&!_[_0xb8c6('0x12')](_0x293a5a[_0xb8c6('0x13')])){_0x37b3fb[_0xb8c6('0x14')][_0xb8c6('0x15')]({'where':{'id':_0x293a5a[_0xb8c6('0x16')]}})['then'](function(_0x2e3b08){if(_0x2e3b08){_0x2e3b08[_0xb8c6('0x17')]({'lastMsgAt':_0x293a5a['createdAt'],'lastMsgDirection':_0x293a5a[_0xb8c6('0x18')][_0xb8c6('0x10')]()});}})[_0xb8c6('0x19')](function(_0x573ba4){console[_0xb8c6('0x1a')](_0x573ba4);});}if(_0x293a5a[_0xb8c6('0x18')]==='out'&&!_0x293a5a[_0xb8c6('0x11')]){var _0x6883a6;_0x37b3fb[_0xb8c6('0x1b')][_0xb8c6('0x1c')]()[_0xb8c6('0x1d')](function(_0x5010da){return _0x37b3fb[_0xb8c6('0x1e')][_0xb8c6('0x1f')]({'where':{'id':_0x293a5a['OpenchannelAccountId']},'include':[{'model':_0x37b3fb[_0xb8c6('0x14')],'as':_0xb8c6('0x20'),'where':{'id':_0x293a5a['OpenchannelInteractionId']},'limit':0x1,'include':[{'model':_0x37b3fb[_0xb8c6('0x1b')],'as':_0xb8c6('0x21'),'attributes':_[_0xb8c6('0x22')](_0x5010da)}]}]});})[_0xb8c6('0x1d')](function(_0x34dbba){_0x6883a6=_0x34dbba[_0xb8c6('0xf')]({'plain':!![]});if(_0x6883a6&&_0x6883a6['replyUri']){logger['info'](_0xb8c6('0x23'),'afterCreate',util['format'](_0xb8c6('0x24'),_0x293a5a['id'],_0x6883a6[_0xb8c6('0x25')]));if(_0x6883a6[_0xb8c6('0x20')]&&_0x6883a6[_0xb8c6('0x20')][_0xb8c6('0x26')]){_0x293a5a['Interaction']=_[_0xb8c6('0x27')](_0x6883a6[_0xb8c6('0x20')][0x0],_0xb8c6('0x21'));_0x293a5a[_0xb8c6('0x21')]=_0x6883a6['Interactions'][0x0][_0xb8c6('0x21')];}var _0xa08be7={'method':_0xb8c6('0x28'),'uri':encodeURI(_0x6883a6[_0xb8c6('0x25')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0xa08be7[_0xb8c6('0x29')]){case _0xb8c6('0x2a'):_0xa08be7['qs']=_0x293a5a;break;case'POST':_0xa08be7[_0xb8c6('0xc')]=_0x293a5a;break;}return rp(_0xa08be7)['then'](function(_0xa70d22){logger[_0xb8c6('0x2b')]('OpenchannelMessage,\x20%s,\x20%s',_0xb8c6('0x2c'),util[_0xb8c6('0x2d')](_0xb8c6('0x2e'),_0x293a5a['id'],_0x6883a6[_0xb8c6('0x25')]));if(_0xa70d22[_0xb8c6('0xc')]['threadId']&&_0xa70d22[_0xb8c6('0xc')][_0xb8c6('0x2f')]!=_0x293a5a[_0xb8c6('0x30')][_0xb8c6('0x2f')]){return _0x37b3fb[_0xb8c6('0x14')][_0xb8c6('0x17')]({'threadId':_0xa70d22['body']['threadId']},{'logging':!![],'where':{'id':_0x293a5a[_0xb8c6('0x30')]['id']}});}else{return;}})['then'](function(){return _0x5194fd[_0xb8c6('0x17')]({'read':!![]});})[_0xb8c6('0x19')](function(_0xc2bae2){logger[_0xb8c6('0x1a')](_0xb8c6('0x23'),'afterCreate',util[_0xb8c6('0x31')](_0xc2bae2,{'showHidden':![],'depth':null}));_0x520319();});}else{_0x520319();}})[_0xb8c6('0x32')](function(){_0x520319();});}else{_0x520319();}}},'charset':'utf8mb4','collate':_0xb8c6('0x33')});};
\ No newline at end of file
+var _0xb03e=['info','OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','Forwarding\x20message\x20%d\x20to\x20%s','length','Interaction','omit','POST','method','GET','threadId','inspect','utf8mb4','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./openchannelMessage.attributes','exports','define','OpenchannelMessage','openchannel_messages','fti_openchannel_messages','body','FULLTEXT','direction','toLowerCase','out','secret','isNil','UserId','OpenchannelInteraction','findOne','OpenchannelInteractionId','then','update','createdAt','error','CmContact','describe','OpenchannelAccount','find','OpenchannelAccountId','Interactions','Contact','get','replyUri'];(function(_0x503185,_0x20d261){var _0xb29eff=function(_0x15e65e){while(--_0x15e65e){_0x503185['push'](_0x503185['shift']());}};_0xb29eff(++_0x20d261);}(_0xb03e,0x1eb));var _0xeb03=function(_0x3e6199,_0x3e8da6){_0x3e6199=_0x3e6199-0x0;var _0x1b598d=_0xb03e[_0x3e6199];return _0x1b598d;};'use strict';var _=require('lodash');var util=require(_0xeb03('0x0'));var logger=require(_0xeb03('0x1'))(_0xeb03('0x2'));var moment=require(_0xeb03('0x3'));var BPromise=require(_0xeb03('0x4'));var rp=require(_0xeb03('0x5'));var fs=require('fs');var path=require(_0xeb03('0x6'));var rimraf=require(_0xeb03('0x7'));var config=require(_0xeb03('0x8'));var attributes=require(_0xeb03('0x9'));module[_0xeb03('0xa')]=function(_0xee2291,_0x4e1cea){return _0xee2291[_0xeb03('0xb')](_0xeb03('0xc'),attributes,{'tableName':_0xeb03('0xd'),'paranoid':![],'indexes':[{'name':_0xeb03('0xe'),'fields':[_0xeb03('0xf')],'type':_0xeb03('0x10')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5a8491,_0x403b77,_0x99f4e2){var _0x14cfa0=_0xee2291['models'];var _0x31af2c=_0x5a8491['get']({'plain':!![]});if(_0x31af2c[_0xeb03('0x11')][_0xeb03('0x12')]()==='in'||_0x31af2c[_0xeb03('0x11')][_0xeb03('0x12')]()===_0xeb03('0x13')&&!_0x31af2c[_0xeb03('0x14')]&&!_[_0xeb03('0x15')](_0x31af2c[_0xeb03('0x16')])){_0x14cfa0[_0xeb03('0x17')][_0xeb03('0x18')]({'where':{'id':_0x31af2c[_0xeb03('0x19')]}})[_0xeb03('0x1a')](function(_0x4d9c8e){if(_0x4d9c8e){_0x4d9c8e[_0xeb03('0x1b')]({'lastMsgAt':_0x31af2c[_0xeb03('0x1c')],'lastMsgDirection':_0x31af2c[_0xeb03('0x11')][_0xeb03('0x12')]()});}})['catch'](function(_0x15f4fe){console[_0xeb03('0x1d')](_0x15f4fe);});}if(_0x31af2c[_0xeb03('0x11')]==='out'&&!_0x31af2c[_0xeb03('0x14')]){var _0x46dd1b;_0x14cfa0[_0xeb03('0x1e')][_0xeb03('0x1f')]()[_0xeb03('0x1a')](function(_0x1b4cbd){return _0x14cfa0[_0xeb03('0x20')][_0xeb03('0x21')]({'where':{'id':_0x31af2c[_0xeb03('0x22')]},'include':[{'model':_0x14cfa0[_0xeb03('0x17')],'as':_0xeb03('0x23'),'where':{'id':_0x31af2c[_0xeb03('0x19')]},'limit':0x1,'include':[{'model':_0x14cfa0[_0xeb03('0x1e')],'as':_0xeb03('0x24'),'attributes':_['keys'](_0x1b4cbd)}]}]});})[_0xeb03('0x1a')](function(_0x3855dd){_0x46dd1b=_0x3855dd[_0xeb03('0x25')]({'plain':!![]});if(_0x46dd1b&&_0x46dd1b[_0xeb03('0x26')]){logger[_0xeb03('0x27')](_0xeb03('0x28'),_0xeb03('0x29'),util[_0xeb03('0x2a')](_0xeb03('0x2b'),_0x31af2c['id'],_0x46dd1b['replyUri']));if(_0x46dd1b[_0xeb03('0x23')]&&_0x46dd1b[_0xeb03('0x23')][_0xeb03('0x2c')]){_0x31af2c[_0xeb03('0x2d')]=_[_0xeb03('0x2e')](_0x46dd1b['Interactions'][0x0],_0xeb03('0x24'));_0x31af2c[_0xeb03('0x24')]=_0x46dd1b[_0xeb03('0x23')][0x0][_0xeb03('0x24')];}var _0x403b77={'method':_0xeb03('0x2f'),'uri':encodeURI(_0x46dd1b[_0xeb03('0x26')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x403b77[_0xeb03('0x30')]){case _0xeb03('0x31'):_0x403b77['qs']=_0x31af2c;break;case'POST':_0x403b77[_0xeb03('0xf')]=_0x31af2c;break;}return rp(_0x403b77)[_0xeb03('0x1a')](function(_0x2683f9){logger[_0xeb03('0x27')]('OpenchannelMessage,\x20%s,\x20%s','afterCreate',util[_0xeb03('0x2a')]('Message\x20%d\x20forwarded\x20to\x20%s',_0x31af2c['id'],_0x46dd1b[_0xeb03('0x26')]));if(_0x2683f9[_0xeb03('0xf')][_0xeb03('0x32')]&&_0x2683f9['body'][_0xeb03('0x32')]!=_0x31af2c['Interaction']['threadId']){return _0x14cfa0['OpenchannelInteraction']['update']({'threadId':_0x2683f9[_0xeb03('0xf')][_0xeb03('0x32')]},{'logging':!![],'where':{'id':_0x31af2c['Interaction']['id']}});}else{return;}})['then'](function(){return _0x5a8491['update']({'read':!![]});})['catch'](function(_0x1e8009){logger[_0xeb03('0x1d')](_0xeb03('0x28'),_0xeb03('0x29'),util[_0xeb03('0x33')](_0x1e8009,{'showHidden':![],'depth':null}));_0x99f4e2();});}else{_0x99f4e2();}})['finally'](function(){_0x99f4e2();});}else{_0x99f4e2();}}},'charset':_0xeb03('0x34'),'collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file