Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index d4d4320..2229c15 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 _0xedbf=['describe','OpenchannelAccount','Interactions','Contact','keys','OpenchannelMessage,\x20%s,\x20%s','Forwarding\x20message\x20%d\x20to\x20%s','replyUri','length','Interaction','omit','method','GET','POST','info','afterCreate','format','Message\x20%d\x20forwarded\x20to\x20%s','threadId','utf8mb4','utf8mb4_unicode_ci','../../config/logger','api','bluebird','rimraf','../../config/environment','exports','define','openchannel_messages','body','FULLTEXT','models','get','direction','toLowerCase','UserId','findOne','OpenchannelInteractionId','then','update','createdAt','catch','error','out','secret'];(function(_0x3237a6,_0x288106){var _0x3447fc=function(_0x510480){while(--_0x510480){_0x3237a6['push'](_0x3237a6['shift']());}};_0x3447fc(++_0x288106);}(_0xedbf,0x6f));var _0xfedb=function(_0x244ddb,_0x107a6c){_0x244ddb=_0x244ddb-0x0;var _0x2aa596=_0xedbf[_0x244ddb];return _0x2aa596;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xfedb('0x0'))(_0xfedb('0x1'));var moment=require('moment');var BPromise=require(_0xfedb('0x2'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0xfedb('0x3'));var config=require(_0xfedb('0x4'));var attributes=require('./openchannelMessage.attributes');module[_0xfedb('0x5')]=function(_0x2304df,_0x573dff){return _0x2304df[_0xfedb('0x6')]('OpenchannelMessage',attributes,{'tableName':_0xfedb('0x7'),'paranoid':![],'indexes':[{'name':'fti_openchannel_messages','fields':[_0xfedb('0x8')],'type':_0xfedb('0x9')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x41336b,_0x227165,_0x53cfd1){var _0x429f38=_0x2304df[_0xfedb('0xa')];var _0x58fd38=_0x41336b[_0xfedb('0xb')]({'plain':!![]});if(_0x58fd38[_0xfedb('0xc')]['toLowerCase']()==='in'||_0x58fd38[_0xfedb('0xc')][_0xfedb('0xd')]()==='out'&&!_0x58fd38['secret']&&!_['isNil'](_0x58fd38[_0xfedb('0xe')])){_0x429f38['OpenchannelInteraction'][_0xfedb('0xf')]({'where':{'id':_0x58fd38[_0xfedb('0x10')]}})[_0xfedb('0x11')](function(_0x427b18){if(_0x427b18){_0x427b18[_0xfedb('0x12')]({'lastMsgAt':_0x58fd38[_0xfedb('0x13')],'lastMsgDirection':_0x58fd38[_0xfedb('0xc')][_0xfedb('0xd')]()});}})[_0xfedb('0x14')](function(_0xc4fa5b){console[_0xfedb('0x15')](_0xc4fa5b);});}if(_0x58fd38['direction']===_0xfedb('0x16')&&!_0x58fd38[_0xfedb('0x17')]){var _0x124c68;_0x429f38['CmContact'][_0xfedb('0x18')]()['then'](function(_0x3f7896){return _0x429f38[_0xfedb('0x19')]['find']({'where':{'id':_0x58fd38['OpenchannelAccountId']},'include':[{'model':_0x429f38['OpenchannelInteraction'],'as':_0xfedb('0x1a'),'where':{'id':_0x58fd38[_0xfedb('0x10')]},'limit':0x1,'include':[{'model':_0x429f38['CmContact'],'as':_0xfedb('0x1b'),'attributes':_[_0xfedb('0x1c')](_0x3f7896)}]}]});})[_0xfedb('0x11')](function(_0x5b9ea6){_0x124c68=_0x5b9ea6[_0xfedb('0xb')]({'plain':!![]});if(_0x124c68&&_0x124c68['replyUri']){logger['info'](_0xfedb('0x1d'),'afterCreate',util['format'](_0xfedb('0x1e'),_0x58fd38['id'],_0x124c68[_0xfedb('0x1f')]));if(_0x124c68[_0xfedb('0x1a')]&&_0x124c68[_0xfedb('0x1a')][_0xfedb('0x20')]){_0x58fd38[_0xfedb('0x21')]=_[_0xfedb('0x22')](_0x124c68[_0xfedb('0x1a')][0x0],_0xfedb('0x1b'));_0x58fd38['Contact']=_0x124c68[_0xfedb('0x1a')][0x0][_0xfedb('0x1b')];}var _0x227165={'method':'POST','uri':encodeURI(_0x124c68[_0xfedb('0x1f')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x227165[_0xfedb('0x23')]){case _0xfedb('0x24'):_0x227165['qs']=_0x58fd38;break;case _0xfedb('0x25'):_0x227165[_0xfedb('0x8')]=_0x58fd38;break;}return rp(_0x227165)[_0xfedb('0x11')](function(_0x93c759){logger[_0xfedb('0x26')](_0xfedb('0x1d'),_0xfedb('0x27'),util[_0xfedb('0x28')](_0xfedb('0x29'),_0x58fd38['id'],_0x124c68[_0xfedb('0x1f')]));if(_0x93c759['body'][_0xfedb('0x2a')]&&_0x93c759['body'][_0xfedb('0x2a')]!=_0x58fd38[_0xfedb('0x21')][_0xfedb('0x2a')]){return _0x429f38['OpenchannelInteraction']['update']({'threadId':_0x93c759[_0xfedb('0x8')]['threadId']},{'logging':!![],'where':{'id':_0x58fd38[_0xfedb('0x21')]['id']}});}else{return;}})[_0xfedb('0x11')](function(){return _0x41336b[_0xfedb('0x12')]({'read':!![]});})[_0xfedb('0x14')](function(_0x34e740){logger[_0xfedb('0x15')](_0xfedb('0x1d'),_0xfedb('0x27'),util['inspect'](_0x34e740,{'showHidden':![],'depth':null}));_0x53cfd1();});}else{_0x53cfd1();}})['finally'](function(){_0x53cfd1();});}else{_0x53cfd1();}}},'charset':_0xfedb('0x2b'),'collate':_0xfedb('0x2c')});};
\ No newline at end of file