Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index c3fc0a5..6451f42 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9354=['threadId','inspect','finally','util','../../config/logger','moment','bluebird','request-promise','path','../../config/environment','./openchannelMessage.attributes','exports','define','OpenchannelMessage','openchannel_messages','fti_openchannel_messages','FULLTEXT','models','get','direction','secret','isNil','UserId','OpenchannelInteraction','findOne','OpenchannelInteractionId','then','update','createdAt','toLowerCase','catch','error','CmContact','describe','find','OpenchannelAccountId','Interactions','replyUri','info','OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','length','Interaction','Contact','POST','method','GET','body'];(function(_0x245d3c,_0x49b181){var _0xd59179=function(_0x1cd025){while(--_0x1cd025){_0x245d3c['push'](_0x245d3c['shift']());}};_0xd59179(++_0x49b181);}(_0x9354,0x96));var _0x4935=function(_0x277fa3,_0x3b2dde){_0x277fa3=_0x277fa3-0x0;var _0x2e4520=_0x9354[_0x277fa3];return _0x2e4520;};'use strict';var _=require('lodash');var util=require(_0x4935('0x0'));var logger=require(_0x4935('0x1'))('api');var moment=require(_0x4935('0x2'));var BPromise=require(_0x4935('0x3'));var rp=require(_0x4935('0x4'));var fs=require('fs');var path=require(_0x4935('0x5'));var rimraf=require('rimraf');var config=require(_0x4935('0x6'));var attributes=require(_0x4935('0x7'));module[_0x4935('0x8')]=function(_0x2d518a,_0x263864){return _0x2d518a[_0x4935('0x9')](_0x4935('0xa'),attributes,{'tableName':_0x4935('0xb'),'paranoid':![],'indexes':[{'name':_0x4935('0xc'),'fields':['body'],'type':_0x4935('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x47a44f,_0x2aac9a,_0x38de96){var _0xd5b117=_0x2d518a[_0x4935('0xe')];var _0x261462=_0x47a44f[_0x4935('0xf')]({'plain':!![]});if(_0x261462['direction']['toLowerCase']()==='in'||_0x261462[_0x4935('0x10')]['toLowerCase']()==='out'&&!_0x261462[_0x4935('0x11')]&&!_[_0x4935('0x12')](_0x261462[_0x4935('0x13')])){_0xd5b117[_0x4935('0x14')][_0x4935('0x15')]({'where':{'id':_0x261462[_0x4935('0x16')]}})[_0x4935('0x17')](function(_0x3a7c30){if(_0x3a7c30){_0x3a7c30[_0x4935('0x18')]({'lastMsgAt':_0x261462[_0x4935('0x19')],'lastMsgDirection':_0x261462[_0x4935('0x10')][_0x4935('0x1a')]()});}})[_0x4935('0x1b')](function(_0x3652c4){console[_0x4935('0x1c')](_0x3652c4);});}if(_0x261462[_0x4935('0x10')]==='out'&&!_0x261462[_0x4935('0x11')]){var _0x46526a;_0xd5b117[_0x4935('0x1d')][_0x4935('0x1e')]()[_0x4935('0x17')](function(_0x429ef3){return _0xd5b117['OpenchannelAccount'][_0x4935('0x1f')]({'where':{'id':_0x261462[_0x4935('0x20')]},'include':[{'model':_0xd5b117['OpenchannelInteraction'],'as':_0x4935('0x21'),'where':{'id':_0x261462[_0x4935('0x16')]},'limit':0x1,'include':[{'model':_0xd5b117[_0x4935('0x1d')],'as':'Contact','attributes':_['keys'](_0x429ef3)}]}]});})[_0x4935('0x17')](function(_0x6b849f){_0x46526a=_0x6b849f[_0x4935('0xf')]({'plain':!![]});if(_0x46526a&&_0x46526a[_0x4935('0x22')]){logger[_0x4935('0x23')](_0x4935('0x24'),_0x4935('0x25'),util[_0x4935('0x26')]('Forwarding\x20message\x20%d\x20to\x20%s',_0x261462['id'],_0x46526a[_0x4935('0x22')]));if(_0x46526a[_0x4935('0x21')]&&_0x46526a[_0x4935('0x21')][_0x4935('0x27')]){_0x261462[_0x4935('0x28')]=_['omit'](_0x46526a['Interactions'][0x0],_0x4935('0x29'));_0x261462[_0x4935('0x29')]=_0x46526a[_0x4935('0x21')][0x0][_0x4935('0x29')];}var _0x2aac9a={'method':_0x4935('0x2a'),'uri':encodeURI(_0x46526a[_0x4935('0x22')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x2aac9a[_0x4935('0x2b')]){case _0x4935('0x2c'):_0x2aac9a['qs']=_0x261462;break;case _0x4935('0x2a'):_0x2aac9a[_0x4935('0x2d')]=_0x261462;break;}return rp(_0x2aac9a)[_0x4935('0x17')](function(_0x2c47ab){logger[_0x4935('0x23')](_0x4935('0x24'),'afterCreate',util['format']('Message\x20%d\x20forwarded\x20to\x20%s',_0x261462['id'],_0x46526a[_0x4935('0x22')]));if(_0x2c47ab[_0x4935('0x2d')]['threadId']&&_0x2c47ab[_0x4935('0x2d')][_0x4935('0x2e')]!=_0x261462[_0x4935('0x28')][_0x4935('0x2e')]){return _0xd5b117[_0x4935('0x14')][_0x4935('0x18')]({'threadId':_0x2c47ab[_0x4935('0x2d')][_0x4935('0x2e')]},{'logging':!![],'where':{'id':_0x261462['Interaction']['id']}});}else{return;}})[_0x4935('0x17')](function(){return _0x47a44f[_0x4935('0x18')]({'read':!![]});})['catch'](function(_0x48a289){logger[_0x4935('0x1c')]('OpenchannelMessage,\x20%s,\x20%s',_0x4935('0x25'),util[_0x4935('0x2f')](_0x48a289,{'showHidden':![],'depth':null}));_0x38de96();});}else{_0x38de96();}})[_0x4935('0x30')](function(){_0x38de96();});}else{_0x38de96();}}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};
\ No newline at end of file
+var _0x4b63=['POST','info','OpenchannelMessage,\x20%s,\x20%s','Message\x20%d\x20forwarded\x20to\x20%s','threadId','error','inspect','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment','bluebird','request-promise','path','../../config/environment','./openchannelMessage.attributes','fti_openchannel_messages','body','FULLTEXT','models','get','direction','out','secret','isNil','UserId','OpenchannelInteractionId','update','createdAt','catch','CmContact','describe','OpenchannelAccount','find','OpenchannelInteraction','Interactions','keys','then','replyUri','afterCreate','format','Forwarding\x20message\x20%d\x20to\x20%s','length','Interaction','omit','Contact','method','GET'];(function(_0x2ea4d4,_0x15af14){var _0x1ef235=function(_0x260c1a){while(--_0x260c1a){_0x2ea4d4['push'](_0x2ea4d4['shift']());}};_0x1ef235(++_0x15af14);}(_0x4b63,0x199));var _0x34b6=function(_0x377cce,_0x3b4f48){_0x377cce=_0x377cce-0x0;var _0x256bc9=_0x4b63[_0x377cce];return _0x256bc9;};'use strict';var _=require(_0x34b6('0x0'));var util=require(_0x34b6('0x1'));var logger=require('../../config/logger')(_0x34b6('0x2'));var moment=require(_0x34b6('0x3'));var BPromise=require(_0x34b6('0x4'));var rp=require(_0x34b6('0x5'));var fs=require('fs');var path=require(_0x34b6('0x6'));var rimraf=require('rimraf');var config=require(_0x34b6('0x7'));var attributes=require(_0x34b6('0x8'));module['exports']=function(_0x8f6f0f,_0x1f7c6f){return _0x8f6f0f['define']('OpenchannelMessage',attributes,{'tableName':'openchannel_messages','paranoid':![],'indexes':[{'name':_0x34b6('0x9'),'fields':[_0x34b6('0xa')],'type':_0x34b6('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x4e7dea,_0x5d9094,_0x243a15){var _0x20bf26=_0x8f6f0f[_0x34b6('0xc')];var _0x2709cc=_0x4e7dea[_0x34b6('0xd')]({'plain':!![]});if(_0x2709cc[_0x34b6('0xe')]['toLowerCase']()==='in'||_0x2709cc['direction']['toLowerCase']()===_0x34b6('0xf')&&!_0x2709cc[_0x34b6('0x10')]&&!_[_0x34b6('0x11')](_0x2709cc[_0x34b6('0x12')])){_0x20bf26['OpenchannelInteraction']['findOne']({'where':{'id':_0x2709cc[_0x34b6('0x13')]}})['then'](function(_0x24dd8c){if(_0x24dd8c){_0x24dd8c[_0x34b6('0x14')]({'lastMsgAt':_0x2709cc[_0x34b6('0x15')],'lastMsgDirection':_0x2709cc[_0x34b6('0xe')]['toLowerCase']()});}})[_0x34b6('0x16')](function(_0x242baf){console['error'](_0x242baf);});}if(_0x2709cc['direction']===_0x34b6('0xf')&&!_0x2709cc[_0x34b6('0x10')]){var _0x1cc619;_0x20bf26[_0x34b6('0x17')][_0x34b6('0x18')]()['then'](function(_0x5f1f5d){return _0x20bf26[_0x34b6('0x19')][_0x34b6('0x1a')]({'where':{'id':_0x2709cc['OpenchannelAccountId']},'include':[{'model':_0x20bf26[_0x34b6('0x1b')],'as':_0x34b6('0x1c'),'where':{'id':_0x2709cc['OpenchannelInteractionId']},'limit':0x1,'include':[{'model':_0x20bf26[_0x34b6('0x17')],'as':'Contact','attributes':_[_0x34b6('0x1d')](_0x5f1f5d)}]}]});})[_0x34b6('0x1e')](function(_0x3c0f7e){_0x1cc619=_0x3c0f7e[_0x34b6('0xd')]({'plain':!![]});if(_0x1cc619&&_0x1cc619[_0x34b6('0x1f')]){logger['info']('OpenchannelMessage,\x20%s,\x20%s',_0x34b6('0x20'),util[_0x34b6('0x21')](_0x34b6('0x22'),_0x2709cc['id'],_0x1cc619[_0x34b6('0x1f')]));if(_0x1cc619['Interactions']&&_0x1cc619['Interactions'][_0x34b6('0x23')]){_0x2709cc[_0x34b6('0x24')]=_[_0x34b6('0x25')](_0x1cc619[_0x34b6('0x1c')][0x0],_0x34b6('0x26'));_0x2709cc['Contact']=_0x1cc619[_0x34b6('0x1c')][0x0][_0x34b6('0x26')];}var _0x5d9094={'method':'POST','uri':encodeURI(_0x1cc619[_0x34b6('0x1f')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x5d9094[_0x34b6('0x27')]){case _0x34b6('0x28'):_0x5d9094['qs']=_0x2709cc;break;case _0x34b6('0x29'):_0x5d9094[_0x34b6('0xa')]=_0x2709cc;break;}return rp(_0x5d9094)[_0x34b6('0x1e')](function(_0x196b83){logger[_0x34b6('0x2a')](_0x34b6('0x2b'),_0x34b6('0x20'),util[_0x34b6('0x21')](_0x34b6('0x2c'),_0x2709cc['id'],_0x1cc619[_0x34b6('0x1f')]));if(_0x196b83[_0x34b6('0xa')][_0x34b6('0x2d')]&&_0x196b83['body'][_0x34b6('0x2d')]!=_0x2709cc[_0x34b6('0x24')][_0x34b6('0x2d')]){return _0x20bf26['OpenchannelInteraction'][_0x34b6('0x14')]({'threadId':_0x196b83[_0x34b6('0xa')][_0x34b6('0x2d')]},{'where':{'id':_0x2709cc[_0x34b6('0x24')]['id']}});}else{return;}})[_0x34b6('0x1e')](function(){return _0x4e7dea[_0x34b6('0x14')]({'read':!![]});})[_0x34b6('0x16')](function(_0x46ae2b){logger[_0x34b6('0x2e')]('OpenchannelMessage,\x20%s,\x20%s',_0x34b6('0x20'),util[_0x34b6('0x2f')](_0x46ae2b,{'showHidden':![],'depth':null}));_0x243a15();});}else{_0x243a15();}})['finally'](function(){_0x243a15();});}else{_0x243a15();}}},'charset':_0x34b6('0x30'),'collate':_0x34b6('0x31')});};
\ No newline at end of file