Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index a0143c0..f0b3c83 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7c1c=['describe','then','Interactions','OpenchannelInteractionId','Contact','keys','OpenchannelMessage,\x20%s,\x20%s','format','replyUri','POST','afterCreate','Message\x20%d\x20forwarded\x20to\x20%s','threadId','Interaction','update','inspect','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./openchannelMessage.attributes','exports','define','OpenchannelMessage','fti_openchannel_messages','body','models','get','direction','out','secret','isNil','UserId','OpenchannelInteraction','createdAt','toLowerCase','catch','error','CmContact'];(function(_0x17663f,_0x52b207){var _0xaa4341=function(_0x441f08){while(--_0x441f08){_0x17663f['push'](_0x17663f['shift']());}};_0xaa4341(++_0x52b207);}(_0x7c1c,0x1f3));var _0xc7c1=function(_0x466b8c,_0x492ed0){_0x466b8c=_0x466b8c-0x0;var _0x3f461d=_0x7c1c[_0x466b8c];return _0x3f461d;};'use strict';var _=require(_0xc7c1('0x0'));var util=require(_0xc7c1('0x1'));var logger=require(_0xc7c1('0x2'))(_0xc7c1('0x3'));var moment=require(_0xc7c1('0x4'));var BPromise=require(_0xc7c1('0x5'));var rp=require(_0xc7c1('0x6'));var fs=require('fs');var path=require(_0xc7c1('0x7'));var rimraf=require(_0xc7c1('0x8'));var config=require(_0xc7c1('0x9'));var attributes=require(_0xc7c1('0xa'));module[_0xc7c1('0xb')]=function(_0x470953,_0x27bcab){return _0x470953[_0xc7c1('0xc')](_0xc7c1('0xd'),attributes,{'tableName':'openchannel_messages','paranoid':![],'indexes':[{'name':_0xc7c1('0xe'),'fields':[_0xc7c1('0xf')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x426c36,_0xdb0098,_0x2e6b9e){var _0x287cfd=_0x470953[_0xc7c1('0x10')];var _0xf55b7b=_0x426c36[_0xc7c1('0x11')]({'plain':!![]});if(_0xf55b7b[_0xc7c1('0x12')]['toLowerCase']()==='in'||_0xf55b7b[_0xc7c1('0x12')]['toLowerCase']()===_0xc7c1('0x13')&&!_0xf55b7b[_0xc7c1('0x14')]&&!_[_0xc7c1('0x15')](_0xf55b7b[_0xc7c1('0x16')])){_0x287cfd[_0xc7c1('0x17')]['findOne']({'where':{'id':_0xf55b7b['OpenchannelInteractionId']}})['then'](function(_0x4e1330){if(_0x4e1330){_0x4e1330['update']({'lastMsgAt':_0xf55b7b[_0xc7c1('0x18')],'lastMsgDirection':_0xf55b7b[_0xc7c1('0x12')][_0xc7c1('0x19')]()});}})[_0xc7c1('0x1a')](function(_0x550270){console[_0xc7c1('0x1b')](_0x550270);});}if(_0xf55b7b[_0xc7c1('0x12')]===_0xc7c1('0x13')&&!_0xf55b7b[_0xc7c1('0x14')]){var _0x57013d;_0x287cfd[_0xc7c1('0x1c')][_0xc7c1('0x1d')]()[_0xc7c1('0x1e')](function(_0x556c2e){return _0x287cfd['OpenchannelAccount']['find']({'where':{'id':_0xf55b7b['OpenchannelAccountId']},'include':[{'model':_0x287cfd['OpenchannelInteraction'],'as':_0xc7c1('0x1f'),'where':{'id':_0xf55b7b[_0xc7c1('0x20')]},'limit':0x1,'include':[{'model':_0x287cfd[_0xc7c1('0x1c')],'as':_0xc7c1('0x21'),'attributes':_[_0xc7c1('0x22')](_0x556c2e)}]}]});})['then'](function(_0x457d97){_0x57013d=_0x457d97['get']({'plain':!![]});if(_0x57013d&&_0x57013d['replyUri']){logger['info'](_0xc7c1('0x23'),'afterCreate',util[_0xc7c1('0x24')]('Forwarding\x20message\x20%d\x20to\x20%s',_0xf55b7b['id'],_0x57013d[_0xc7c1('0x25')]));if(_0x57013d['Interactions']&&_0x57013d[_0xc7c1('0x1f')]['length']){_0xf55b7b['Interaction']=_['omit'](_0x57013d['Interactions'][0x0],_0xc7c1('0x21'));_0xf55b7b[_0xc7c1('0x21')]=_0x57013d['Interactions'][0x0]['Contact'];}var _0xdb0098={'method':_0xc7c1('0x26'),'uri':encodeURI(_0x57013d[_0xc7c1('0x25')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0xdb0098['method']){case'GET':_0xdb0098['qs']=_0xf55b7b;break;case _0xc7c1('0x26'):_0xdb0098[_0xc7c1('0xf')]=_0xf55b7b;break;}return rp(_0xdb0098)[_0xc7c1('0x1e')](function(_0x433121){logger['info']('OpenchannelMessage,\x20%s,\x20%s',_0xc7c1('0x27'),util[_0xc7c1('0x24')](_0xc7c1('0x28'),_0xf55b7b['id'],_0x57013d[_0xc7c1('0x25')]));if(_0x433121['body'][_0xc7c1('0x29')]&&_0x433121[_0xc7c1('0xf')][_0xc7c1('0x29')]!=_0xf55b7b[_0xc7c1('0x2a')]['threadId']){return _0x287cfd['OpenchannelInteraction'][_0xc7c1('0x2b')]({'threadId':_0x433121[_0xc7c1('0xf')][_0xc7c1('0x29')]},{'logging':!![],'where':{'id':_0xf55b7b[_0xc7c1('0x2a')]['id']}});}else{return;}})[_0xc7c1('0x1e')](function(){return _0x426c36[_0xc7c1('0x2b')]({'read':!![]});})[_0xc7c1('0x1a')](function(_0x251af6){logger[_0xc7c1('0x1b')]('OpenchannelMessage,\x20%s,\x20%s',_0xc7c1('0x27'),util[_0xc7c1('0x2c')](_0x251af6,{'showHidden':![],'depth':null}));_0x2e6b9e();});}else{_0x2e6b9e();}})[_0xc7c1('0x2d')](function(){_0x2e6b9e();});}else{_0x2e6b9e();}}},'charset':_0xc7c1('0x2e'),'collate':_0xc7c1('0x2f')});};
\ 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