Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / openchannelMessage / openchannelMessage.model.js
index ce778c4..39d652c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x955f=['openchannel_messages','body','FULLTEXT','models','get','toLowerCase','direction','secret','UserId','findOne','OpenchannelInteractionId','then','update','createdAt','catch','CmContact','describe','OpenchannelAccount','find','OpenchannelAccountId','Interactions','Contact','keys','replyUri','OpenchannelMessage,\x20%s,\x20%s','format','Forwarding\x20message\x20%d\x20to\x20%s','Interaction','omit','POST','method','GET','info','afterCreate','Message\x20%d\x20forwarded\x20to\x20%s','threadId','OpenchannelInteraction','error','inspect','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','request-promise','../../config/environment','exports','OpenchannelMessage'];(function(_0x456fb1,_0x859a1d){var _0x4083d6=function(_0xe1d0f2){while(--_0xe1d0f2){_0x456fb1['push'](_0x456fb1['shift']());}};_0x4083d6(++_0x859a1d);}(_0x955f,0x1eb));var _0xf955=function(_0x220e18,_0x1bd108){_0x220e18=_0x220e18-0x0;var _0x3a8474=_0x955f[_0x220e18];return _0x3a8474;};'use strict';var _=require(_0xf955('0x0'));var util=require(_0xf955('0x1'));var logger=require(_0xf955('0x2'))(_0xf955('0x3'));var moment=require(_0xf955('0x4'));var BPromise=require('bluebird');var rp=require(_0xf955('0x5'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0xf955('0x6'));var attributes=require('./openchannelMessage.attributes');module[_0xf955('0x7')]=function(_0x2caff2,_0x3fdac2){return _0x2caff2['define'](_0xf955('0x8'),attributes,{'tableName':_0xf955('0x9'),'paranoid':![],'indexes':[{'name':'fti_openchannel_messages','fields':[_0xf955('0xa')],'type':_0xf955('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x168ffb,_0x38b190,_0x134c1b){var _0x421e4a=_0x2caff2[_0xf955('0xc')];var _0x4d213a=_0x168ffb[_0xf955('0xd')]({'plain':!![]});if(_0x4d213a['direction'][_0xf955('0xe')]()==='in'||_0x4d213a[_0xf955('0xf')][_0xf955('0xe')]()==='out'&&!_0x4d213a[_0xf955('0x10')]&&!_['isNil'](_0x4d213a[_0xf955('0x11')])){_0x421e4a['OpenchannelInteraction'][_0xf955('0x12')]({'where':{'id':_0x4d213a[_0xf955('0x13')]}})[_0xf955('0x14')](function(_0x109bc5){if(_0x109bc5){_0x109bc5[_0xf955('0x15')]({'lastMsgAt':_0x4d213a[_0xf955('0x16')],'lastMsgDirection':_0x4d213a[_0xf955('0xf')][_0xf955('0xe')]()});}})[_0xf955('0x17')](function(_0x24e75c){console['error'](_0x24e75c);});}if(_0x4d213a[_0xf955('0xf')]==='out'&&!_0x4d213a[_0xf955('0x10')]){var _0x3a814f;_0x421e4a[_0xf955('0x18')][_0xf955('0x19')]()['then'](function(_0x5ac6cb){return _0x421e4a[_0xf955('0x1a')][_0xf955('0x1b')]({'where':{'id':_0x4d213a[_0xf955('0x1c')]},'include':[{'model':_0x421e4a['OpenchannelInteraction'],'as':_0xf955('0x1d'),'where':{'id':_0x4d213a[_0xf955('0x13')]},'limit':0x1,'include':[{'model':_0x421e4a[_0xf955('0x18')],'as':_0xf955('0x1e'),'attributes':_[_0xf955('0x1f')](_0x5ac6cb)}]}]});})['then'](function(_0x17d86a){_0x3a814f=_0x17d86a[_0xf955('0xd')]({'plain':!![]});if(_0x3a814f&&_0x3a814f[_0xf955('0x20')]){logger['info'](_0xf955('0x21'),'afterCreate',util[_0xf955('0x22')](_0xf955('0x23'),_0x4d213a['id'],_0x3a814f[_0xf955('0x20')]));if(_0x3a814f[_0xf955('0x1d')]&&_0x3a814f[_0xf955('0x1d')]['length']){_0x4d213a[_0xf955('0x24')]=_[_0xf955('0x25')](_0x3a814f[_0xf955('0x1d')][0x0],_0xf955('0x1e'));_0x4d213a[_0xf955('0x1e')]=_0x3a814f[_0xf955('0x1d')][0x0][_0xf955('0x1e')];}var _0x38b190={'method':_0xf955('0x26'),'uri':encodeURI(_0x3a814f[_0xf955('0x20')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x38b190[_0xf955('0x27')]){case _0xf955('0x28'):_0x38b190['qs']=_0x4d213a;break;case _0xf955('0x26'):_0x38b190[_0xf955('0xa')]=_0x4d213a;break;}return rp(_0x38b190)[_0xf955('0x14')](function(_0x51f3ab){logger[_0xf955('0x29')](_0xf955('0x21'),_0xf955('0x2a'),util[_0xf955('0x22')](_0xf955('0x2b'),_0x4d213a['id'],_0x3a814f[_0xf955('0x20')]));if(_0x51f3ab['body'][_0xf955('0x2c')]&&_0x51f3ab[_0xf955('0xa')]['threadId']!=_0x4d213a[_0xf955('0x24')][_0xf955('0x2c')]){return _0x421e4a[_0xf955('0x2d')][_0xf955('0x15')]({'threadId':_0x51f3ab['body'][_0xf955('0x2c')]},{'logging':!![],'where':{'id':_0x4d213a['Interaction']['id']}});}else{return;}})[_0xf955('0x14')](function(){return _0x168ffb[_0xf955('0x15')]({'read':!![]});})[_0xf955('0x17')](function(_0x4069fe){logger[_0xf955('0x2e')](_0xf955('0x21'),_0xf955('0x2a'),util[_0xf955('0x2f')](_0x4069fe,{'showHidden':![],'depth':null}));_0x134c1b();});}else{_0x134c1b();}})['finally'](function(){_0x134c1b();});}else{_0x134c1b();}}},'charset':_0xf955('0x30'),'collate':_0xf955('0x31')});};
\ No newline at end of file
+var _0x9c34=['length','omit','POST','method','GET','Message\x20%d\x20forwarded\x20to\x20%s','body','Interaction','threadId','inspect','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','request-promise','rimraf','./openchannelMessage.attributes','exports','define','OpenchannelMessage','openchannel_messages','fti_openchannel_messages','FULLTEXT','direction','toLowerCase','out','isNil','UserId','OpenchannelInteraction','findOne','OpenchannelInteractionId','update','createdAt','catch','error','CmContact','describe','then','OpenchannelAccount','find','OpenchannelAccountId','Interactions','Contact','keys','get','replyUri','info','OpenchannelMessage,\x20%s,\x20%s','afterCreate','format','Forwarding\x20message\x20%d\x20to\x20%s'];(function(_0x2f1cdf,_0x1f422e){var _0x476c6e=function(_0x30375a){while(--_0x30375a){_0x2f1cdf['push'](_0x2f1cdf['shift']());}};_0x476c6e(++_0x1f422e);}(_0x9c34,0xb2));var _0x49c3=function(_0x5d810b,_0x5d07fd){_0x5d810b=_0x5d810b-0x0;var _0x53b0ed=_0x9c34[_0x5d810b];return _0x53b0ed;};'use strict';var _=require(_0x49c3('0x0'));var util=require(_0x49c3('0x1'));var logger=require(_0x49c3('0x2'))(_0x49c3('0x3'));var moment=require('moment');var BPromise=require(_0x49c3('0x4'));var rp=require(_0x49c3('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0x49c3('0x6'));var config=require('../../config/environment');var attributes=require(_0x49c3('0x7'));module[_0x49c3('0x8')]=function(_0x307e87,_0x596c98){return _0x307e87[_0x49c3('0x9')](_0x49c3('0xa'),attributes,{'tableName':_0x49c3('0xb'),'paranoid':![],'indexes':[{'name':_0x49c3('0xc'),'fields':['body'],'type':_0x49c3('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x560b82,_0x5b490e,_0x2bd3c1){var _0x43760e=_0x307e87['models'];var _0x1a75ef=_0x560b82['get']({'plain':!![]});if(_0x1a75ef[_0x49c3('0xe')][_0x49c3('0xf')]()==='in'||_0x1a75ef[_0x49c3('0xe')][_0x49c3('0xf')]()===_0x49c3('0x10')&&!_0x1a75ef['secret']&&!_[_0x49c3('0x11')](_0x1a75ef[_0x49c3('0x12')])){_0x43760e[_0x49c3('0x13')][_0x49c3('0x14')]({'where':{'id':_0x1a75ef[_0x49c3('0x15')]}})['then'](function(_0x15fb01){if(_0x15fb01){_0x15fb01[_0x49c3('0x16')]({'lastMsgAt':_0x1a75ef[_0x49c3('0x17')],'lastMsgDirection':_0x1a75ef[_0x49c3('0xe')][_0x49c3('0xf')]()});}})[_0x49c3('0x18')](function(_0xb57de4){console[_0x49c3('0x19')](_0xb57de4);});}if(_0x1a75ef[_0x49c3('0xe')]==='out'&&!_0x1a75ef['secret']){var _0x34a696;_0x43760e[_0x49c3('0x1a')][_0x49c3('0x1b')]()[_0x49c3('0x1c')](function(_0x3058a7){return _0x43760e[_0x49c3('0x1d')][_0x49c3('0x1e')]({'where':{'id':_0x1a75ef[_0x49c3('0x1f')]},'include':[{'model':_0x43760e[_0x49c3('0x13')],'as':_0x49c3('0x20'),'where':{'id':_0x1a75ef['OpenchannelInteractionId']},'limit':0x1,'include':[{'model':_0x43760e[_0x49c3('0x1a')],'as':_0x49c3('0x21'),'attributes':_[_0x49c3('0x22')](_0x3058a7)}]}]});})[_0x49c3('0x1c')](function(_0x49a529){_0x34a696=_0x49a529[_0x49c3('0x23')]({'plain':!![]});if(_0x34a696&&_0x34a696[_0x49c3('0x24')]){logger[_0x49c3('0x25')](_0x49c3('0x26'),_0x49c3('0x27'),util[_0x49c3('0x28')](_0x49c3('0x29'),_0x1a75ef['id'],_0x34a696['replyUri']));if(_0x34a696['Interactions']&&_0x34a696[_0x49c3('0x20')][_0x49c3('0x2a')]){_0x1a75ef['Interaction']=_[_0x49c3('0x2b')](_0x34a696['Interactions'][0x0],'Contact');_0x1a75ef['Contact']=_0x34a696[_0x49c3('0x20')][0x0][_0x49c3('0x21')];}var _0x5b490e={'method':_0x49c3('0x2c'),'uri':encodeURI(_0x34a696[_0x49c3('0x24')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x5b490e[_0x49c3('0x2d')]){case _0x49c3('0x2e'):_0x5b490e['qs']=_0x1a75ef;break;case'POST':_0x5b490e['body']=_0x1a75ef;break;}return rp(_0x5b490e)[_0x49c3('0x1c')](function(_0x43380f){logger[_0x49c3('0x25')]('OpenchannelMessage,\x20%s,\x20%s','afterCreate',util[_0x49c3('0x28')](_0x49c3('0x2f'),_0x1a75ef['id'],_0x34a696['replyUri']));if(_0x43380f['body']['threadId']&&_0x43380f[_0x49c3('0x30')]['threadId']!=_0x1a75ef[_0x49c3('0x31')]['threadId']){return _0x43760e[_0x49c3('0x13')]['update']({'threadId':_0x43380f[_0x49c3('0x30')][_0x49c3('0x32')]},{'where':{'id':_0x1a75ef[_0x49c3('0x31')]['id']}});}else{return;}})[_0x49c3('0x1c')](function(){return _0x560b82[_0x49c3('0x16')]({'read':!![]});})[_0x49c3('0x18')](function(_0xebcb20){logger[_0x49c3('0x19')](_0x49c3('0x26'),'afterCreate',util[_0x49c3('0x33')](_0xebcb20,{'showHidden':![],'depth':null}));_0x2bd3c1();});}else{_0x2bd3c1();}})[_0x49c3('0x34')](function(){_0x2bd3c1();});}else{_0x2bd3c1();}}},'charset':_0x49c3('0x35'),'collate':_0x49c3('0x36')});};
\ No newline at end of file