Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index 0709346..8a14cc6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x37df=['POST','GET','threadId','body','catch','inspect','finally','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','api','moment','bluebird','request-promise','rimraf','../../config/environment','./openchannelMessage.attributes','exports','define','OpenchannelMessage','fti_openchannel_messages','FULLTEXT','models','direction','toLowerCase','out','secret','isNil','UserId','OpenchannelInteraction','findOne','OpenchannelInteractionId','update','createdAt','error','CmContact','describe','then','OpenchannelAccount','find','OpenchannelAccountId','Contact','keys','replyUri','info','OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','Forwarding\x20message\x20%d\x20to\x20%s','Interactions','Interaction'];(function(_0x2c3d4f,_0x448a69){var _0x2dddb6=function(_0x35974e){while(--_0x35974e){_0x2c3d4f['push'](_0x2c3d4f['shift']());}};_0x2dddb6(++_0x448a69);}(_0x37df,0x10d));var _0xf37d=function(_0x4fbb86,_0x374ed0){_0x4fbb86=_0x4fbb86-0x0;var _0xb141fe=_0x37df[_0x4fbb86];return _0xb141fe;};'use strict';var _=require(_0xf37d('0x0'));var util=require('util');var logger=require(_0xf37d('0x1'))(_0xf37d('0x2'));var moment=require(_0xf37d('0x3'));var BPromise=require(_0xf37d('0x4'));var rp=require(_0xf37d('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0xf37d('0x6'));var config=require(_0xf37d('0x7'));var attributes=require(_0xf37d('0x8'));module[_0xf37d('0x9')]=function(_0x3bbad6,_0x28cdba){return _0x3bbad6[_0xf37d('0xa')](_0xf37d('0xb'),attributes,{'tableName':'openchannel_messages','paranoid':![],'indexes':[{'name':_0xf37d('0xc'),'fields':['body'],'type':_0xf37d('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5c0c28,_0x2eed8a,_0xe7e3c1){var _0x19f3e4=_0x3bbad6[_0xf37d('0xe')];var _0x37bf6e=_0x5c0c28['get']({'plain':!![]});if(_0x37bf6e[_0xf37d('0xf')]['toLowerCase']()==='in'||_0x37bf6e['direction'][_0xf37d('0x10')]()===_0xf37d('0x11')&&!_0x37bf6e[_0xf37d('0x12')]&&!_[_0xf37d('0x13')](_0x37bf6e[_0xf37d('0x14')])){_0x19f3e4[_0xf37d('0x15')][_0xf37d('0x16')]({'where':{'id':_0x37bf6e[_0xf37d('0x17')]}})['then'](function(_0xe8f42f){if(_0xe8f42f){_0xe8f42f[_0xf37d('0x18')]({'lastMsgAt':_0x37bf6e[_0xf37d('0x19')],'lastMsgDirection':_0x37bf6e[_0xf37d('0xf')][_0xf37d('0x10')]()});}})['catch'](function(_0x39520e){console[_0xf37d('0x1a')](_0x39520e);});}if(_0x37bf6e[_0xf37d('0xf')]===_0xf37d('0x11')&&!_0x37bf6e[_0xf37d('0x12')]){var _0x39eb60;_0x19f3e4[_0xf37d('0x1b')][_0xf37d('0x1c')]()[_0xf37d('0x1d')](function(_0x522c38){return _0x19f3e4[_0xf37d('0x1e')][_0xf37d('0x1f')]({'where':{'id':_0x37bf6e[_0xf37d('0x20')]},'include':[{'model':_0x19f3e4[_0xf37d('0x15')],'as':'Interactions','where':{'id':_0x37bf6e[_0xf37d('0x17')]},'limit':0x1,'include':[{'model':_0x19f3e4['CmContact'],'as':_0xf37d('0x21'),'attributes':_[_0xf37d('0x22')](_0x522c38)}]}]});})['then'](function(_0x4d5624){_0x39eb60=_0x4d5624['get']({'plain':!![]});if(_0x39eb60&&_0x39eb60[_0xf37d('0x23')]){logger[_0xf37d('0x24')](_0xf37d('0x25'),_0xf37d('0x26'),util[_0xf37d('0x27')](_0xf37d('0x28'),_0x37bf6e['id'],_0x39eb60[_0xf37d('0x23')]));if(_0x39eb60[_0xf37d('0x29')]&&_0x39eb60[_0xf37d('0x29')]['length']){_0x37bf6e[_0xf37d('0x2a')]=_['omit'](_0x39eb60['Interactions'][0x0],_0xf37d('0x21'));_0x37bf6e['Contact']=_0x39eb60[_0xf37d('0x29')][0x0][_0xf37d('0x21')];}var _0x2eed8a={'method':_0xf37d('0x2b'),'uri':encodeURI(_0x39eb60[_0xf37d('0x23')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x2eed8a['method']){case _0xf37d('0x2c'):_0x2eed8a['qs']=_0x37bf6e;break;case _0xf37d('0x2b'):_0x2eed8a['body']=_0x37bf6e;break;}return rp(_0x2eed8a)['then'](function(_0x13e1bf){logger[_0xf37d('0x24')]('OpenchannelMessage,\x20%s,\x20%s',_0xf37d('0x26'),util[_0xf37d('0x27')]('Message\x20%d\x20forwarded\x20to\x20%s',_0x37bf6e['id'],_0x39eb60[_0xf37d('0x23')]));if(_0x13e1bf['body'][_0xf37d('0x2d')]&&_0x13e1bf[_0xf37d('0x2e')][_0xf37d('0x2d')]!=_0x37bf6e[_0xf37d('0x2a')][_0xf37d('0x2d')]){return _0x19f3e4['OpenchannelInteraction'][_0xf37d('0x18')]({'threadId':_0x13e1bf[_0xf37d('0x2e')][_0xf37d('0x2d')]},{'where':{'id':_0x37bf6e['Interaction']['id']}});}else{return;}})['then'](function(){return _0x5c0c28[_0xf37d('0x18')]({'read':!![]});})[_0xf37d('0x2f')](function(_0x41bc6b){logger[_0xf37d('0x1a')](_0xf37d('0x25'),'afterCreate',util[_0xf37d('0x30')](_0x41bc6b,{'showHidden':![],'depth':null}));_0xe7e3c1();});}else{_0xe7e3c1();}})[_0xf37d('0x31')](function(){_0xe7e3c1();});}else{_0xe7e3c1();}}},'charset':_0xf37d('0x32'),'collate':_0xf37d('0x33')});};
\ No newline at end of file