Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index 4b2d394..0709346 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x391a=['util','../../config/logger','api','request-promise','../../config/environment','./openchannelMessage.attributes','exports','OpenchannelMessage','fti_openchannel_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','OpenchannelInteraction','findOne','then','update','catch','error','CmContact','describe','OpenchannelAccount','OpenchannelAccountId','OpenchannelInteractionId','Contact','keys','info','OpenchannelMessage,\x20%s,\x20%s','afterCreate','Forwarding\x20message\x20%d\x20to\x20%s','Interactions','Interaction','omit','POST','replyUri','method','GET','Message\x20%d\x20forwarded\x20to\x20%s','threadId','inspect','finally','utf8mb4','lodash'];(function(_0x42bf3c,_0x5a0613){var _0x3123b9=function(_0x2dc3f8){while(--_0x2dc3f8){_0x42bf3c['push'](_0x42bf3c['shift']());}};_0x3123b9(++_0x5a0613);}(_0x391a,0x1df));var _0xa391=function(_0x18f629,_0x4f9f23){_0x18f629=_0x18f629-0x0;var _0x6c4d72=_0x391a[_0x18f629];return _0x6c4d72;};'use strict';var _=require(_0xa391('0x0'));var util=require(_0xa391('0x1'));var logger=require(_0xa391('0x2'))(_0xa391('0x3'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xa391('0x4'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0xa391('0x5'));var attributes=require(_0xa391('0x6'));module[_0xa391('0x7')]=function(_0x408daa,_0x2928f0){return _0x408daa['define'](_0xa391('0x8'),attributes,{'tableName':'openchannel_messages','paranoid':![],'indexes':[{'name':_0xa391('0x9'),'fields':[_0xa391('0xa')],'type':_0xa391('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5b6be4,_0x227f16,_0x3d1362){var _0x19a0b6=_0x408daa[_0xa391('0xc')];var _0x140dff=_0x5b6be4[_0xa391('0xd')]({'plain':!![]});if(_0x140dff[_0xa391('0xe')][_0xa391('0xf')]()==='in'||_0x140dff[_0xa391('0xe')]['toLowerCase']()===_0xa391('0x10')&&!_0x140dff[_0xa391('0x11')]&&!_[_0xa391('0x12')](_0x140dff['UserId'])){_0x19a0b6[_0xa391('0x13')][_0xa391('0x14')]({'where':{'id':_0x140dff['OpenchannelInteractionId']}})[_0xa391('0x15')](function(_0x14948e){if(_0x14948e){_0x14948e[_0xa391('0x16')]({'lastMsgAt':_0x140dff['createdAt'],'lastMsgDirection':_0x140dff[_0xa391('0xe')][_0xa391('0xf')]()});}})[_0xa391('0x17')](function(_0x1618fc){console[_0xa391('0x18')](_0x1618fc);});}if(_0x140dff[_0xa391('0xe')]===_0xa391('0x10')&&!_0x140dff['secret']){var _0x4000f4;_0x19a0b6[_0xa391('0x19')][_0xa391('0x1a')]()[_0xa391('0x15')](function(_0x2f9fd5){return _0x19a0b6[_0xa391('0x1b')]['find']({'where':{'id':_0x140dff[_0xa391('0x1c')]},'include':[{'model':_0x19a0b6[_0xa391('0x13')],'as':'Interactions','where':{'id':_0x140dff[_0xa391('0x1d')]},'limit':0x1,'include':[{'model':_0x19a0b6[_0xa391('0x19')],'as':_0xa391('0x1e'),'attributes':_[_0xa391('0x1f')](_0x2f9fd5)}]}]});})[_0xa391('0x15')](function(_0xf21c84){_0x4000f4=_0xf21c84['get']({'plain':!![]});if(_0x4000f4&&_0x4000f4['replyUri']){logger[_0xa391('0x20')](_0xa391('0x21'),_0xa391('0x22'),util['format'](_0xa391('0x23'),_0x140dff['id'],_0x4000f4['replyUri']));if(_0x4000f4[_0xa391('0x24')]&&_0x4000f4[_0xa391('0x24')]['length']){_0x140dff[_0xa391('0x25')]=_[_0xa391('0x26')](_0x4000f4[_0xa391('0x24')][0x0],'Contact');_0x140dff['Contact']=_0x4000f4[_0xa391('0x24')][0x0]['Contact'];}var _0x227f16={'method':_0xa391('0x27'),'uri':encodeURI(_0x4000f4[_0xa391('0x28')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x227f16[_0xa391('0x29')]){case _0xa391('0x2a'):_0x227f16['qs']=_0x140dff;break;case'POST':_0x227f16[_0xa391('0xa')]=_0x140dff;break;}return rp(_0x227f16)['then'](function(_0x304ae6){logger[_0xa391('0x20')](_0xa391('0x21'),_0xa391('0x22'),util['format'](_0xa391('0x2b'),_0x140dff['id'],_0x4000f4[_0xa391('0x28')]));if(_0x304ae6['body'][_0xa391('0x2c')]&&_0x304ae6[_0xa391('0xa')][_0xa391('0x2c')]!=_0x140dff[_0xa391('0x25')][_0xa391('0x2c')]){return _0x19a0b6[_0xa391('0x13')][_0xa391('0x16')]({'threadId':_0x304ae6[_0xa391('0xa')][_0xa391('0x2c')]},{'logging':!![],'where':{'id':_0x140dff['Interaction']['id']}});}else{return;}})[_0xa391('0x15')](function(){return _0x5b6be4[_0xa391('0x16')]({'read':!![]});})[_0xa391('0x17')](function(_0x29202f){logger[_0xa391('0x18')]('OpenchannelMessage,\x20%s,\x20%s','afterCreate',util[_0xa391('0x2d')](_0x29202f,{'showHidden':![],'depth':null}));_0x3d1362();});}else{_0x3d1362();}})[_0xa391('0x2e')](function(){_0x3d1362();});}else{_0x3d1362();}}},'charset':_0xa391('0x2f'),'collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file
+var _0x7f46=['POST','method','GET','body','info','Message\x20%d\x20forwarded\x20to\x20%s','threadId','error','inspect','utf8mb4','utf8mb4_unicode_ci','lodash','api','bluebird','request-promise','rimraf','../../config/environment','exports','define','OpenchannelMessage','openchannel_messages','FULLTEXT','get','direction','toLowerCase','out','secret','isNil','UserId','OpenchannelInteraction','findOne','OpenchannelInteractionId','then','update','createdAt','catch','CmContact','describe','OpenchannelAccount','find','OpenchannelAccountId','Interactions','Contact','keys','replyUri','OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','length','Interaction','omit'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0x7f46,0x170));var _0x67f4=function(_0x58ee19,_0xdf0765){_0x58ee19=_0x58ee19-0x0;var _0x49af25=_0x7f46[_0x58ee19];return _0x49af25;};'use strict';var _=require(_0x67f4('0x0'));var util=require('util');var logger=require('../../config/logger')(_0x67f4('0x1'));var moment=require('moment');var BPromise=require(_0x67f4('0x2'));var rp=require(_0x67f4('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0x67f4('0x4'));var config=require(_0x67f4('0x5'));var attributes=require('./openchannelMessage.attributes');module[_0x67f4('0x6')]=function(_0x425076,_0x4b2756){return _0x425076[_0x67f4('0x7')](_0x67f4('0x8'),attributes,{'tableName':_0x67f4('0x9'),'paranoid':![],'indexes':[{'name':'fti_openchannel_messages','fields':['body'],'type':_0x67f4('0xa')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3146e0,_0x3256c5,_0x252bb8){var _0x5d1271=_0x425076['models'];var _0x2882bb=_0x3146e0[_0x67f4('0xb')]({'plain':!![]});if(_0x2882bb[_0x67f4('0xc')][_0x67f4('0xd')]()==='in'||_0x2882bb[_0x67f4('0xc')][_0x67f4('0xd')]()===_0x67f4('0xe')&&!_0x2882bb[_0x67f4('0xf')]&&!_[_0x67f4('0x10')](_0x2882bb[_0x67f4('0x11')])){_0x5d1271[_0x67f4('0x12')][_0x67f4('0x13')]({'where':{'id':_0x2882bb[_0x67f4('0x14')]}})[_0x67f4('0x15')](function(_0x236fc8){if(_0x236fc8){_0x236fc8[_0x67f4('0x16')]({'lastMsgAt':_0x2882bb[_0x67f4('0x17')],'lastMsgDirection':_0x2882bb[_0x67f4('0xc')][_0x67f4('0xd')]()});}})[_0x67f4('0x18')](function(_0x56b057){console['error'](_0x56b057);});}if(_0x2882bb[_0x67f4('0xc')]===_0x67f4('0xe')&&!_0x2882bb[_0x67f4('0xf')]){var _0x57f6c3;_0x5d1271[_0x67f4('0x19')][_0x67f4('0x1a')]()[_0x67f4('0x15')](function(_0x5e3071){return _0x5d1271[_0x67f4('0x1b')][_0x67f4('0x1c')]({'where':{'id':_0x2882bb[_0x67f4('0x1d')]},'include':[{'model':_0x5d1271[_0x67f4('0x12')],'as':_0x67f4('0x1e'),'where':{'id':_0x2882bb[_0x67f4('0x14')]},'limit':0x1,'include':[{'model':_0x5d1271[_0x67f4('0x19')],'as':_0x67f4('0x1f'),'attributes':_[_0x67f4('0x20')](_0x5e3071)}]}]});})[_0x67f4('0x15')](function(_0xa3741){_0x57f6c3=_0xa3741[_0x67f4('0xb')]({'plain':!![]});if(_0x57f6c3&&_0x57f6c3[_0x67f4('0x21')]){logger['info'](_0x67f4('0x22'),_0x67f4('0x23'),util[_0x67f4('0x24')]('Forwarding\x20message\x20%d\x20to\x20%s',_0x2882bb['id'],_0x57f6c3[_0x67f4('0x21')]));if(_0x57f6c3['Interactions']&&_0x57f6c3[_0x67f4('0x1e')][_0x67f4('0x25')]){_0x2882bb[_0x67f4('0x26')]=_[_0x67f4('0x27')](_0x57f6c3[_0x67f4('0x1e')][0x0],_0x67f4('0x1f'));_0x2882bb[_0x67f4('0x1f')]=_0x57f6c3[_0x67f4('0x1e')][0x0][_0x67f4('0x1f')];}var _0x3256c5={'method':_0x67f4('0x28'),'uri':encodeURI(_0x57f6c3[_0x67f4('0x21')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x3256c5[_0x67f4('0x29')]){case _0x67f4('0x2a'):_0x3256c5['qs']=_0x2882bb;break;case _0x67f4('0x28'):_0x3256c5[_0x67f4('0x2b')]=_0x2882bb;break;}return rp(_0x3256c5)['then'](function(_0x6efb65){logger[_0x67f4('0x2c')](_0x67f4('0x22'),_0x67f4('0x23'),util[_0x67f4('0x24')](_0x67f4('0x2d'),_0x2882bb['id'],_0x57f6c3[_0x67f4('0x21')]));if(_0x6efb65[_0x67f4('0x2b')][_0x67f4('0x2e')]&&_0x6efb65[_0x67f4('0x2b')][_0x67f4('0x2e')]!=_0x2882bb['Interaction']['threadId']){return _0x5d1271[_0x67f4('0x12')][_0x67f4('0x16')]({'threadId':_0x6efb65[_0x67f4('0x2b')][_0x67f4('0x2e')]},{'where':{'id':_0x2882bb[_0x67f4('0x26')]['id']}});}else{return;}})[_0x67f4('0x15')](function(){return _0x3146e0[_0x67f4('0x16')]({'read':!![]});})[_0x67f4('0x18')](function(_0x5242c7){logger[_0x67f4('0x2f')](_0x67f4('0x22'),_0x67f4('0x23'),util[_0x67f4('0x30')](_0x5242c7,{'showHidden':![],'depth':null}));_0x252bb8();});}else{_0x252bb8();}})['finally'](function(){_0x252bb8();});}else{_0x252bb8();}}},'charset':_0x67f4('0x31'),'collate':_0x67f4('0x32')});};
\ No newline at end of file