Built motion from commit (unavailable).|2.5.28
[motion2.git] / server / config / triggers / index.js
index 545a4b0..eb963f7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x87cb=['error','code','catch','channel','event','direction','UserId','User','find','name','interface','format','SIP/%s','incomingmessage','get','opened','changed','closed','default','model','hook','callback','util','../../mysqldb','jayson/promise','../logger','triggers','client','http','ChatInteraction','afterCreate','newinteraction','Chat','afterUpdate','closedinteraction','ChatMessage','newmessage','Sms','SmsInteraction','SmsMessage','Whatsapp','WhatsappInteraction','WhatsappMessage','Fax','FaxInteraction','FaxMessage','Mail','MailInteraction','Openchannel','OpenchannelInteraction','OpenchannelMessage','request','EventManager','then','info','Trigger,\x20%s'];(function(_0x51bffe,_0x20668c){var _0x4f1236=function(_0x54d0aa){while(--_0x54d0aa){_0x51bffe['push'](_0x51bffe['shift']());}};_0x4f1236(++_0x20668c);}(_0x87cb,0x19e));var _0xb87c=function(_0x4a53d,_0x58a95e){_0x4a53d=_0x4a53d-0x0;var _0x27410e=_0x87cb[_0x4a53d];return _0x27410e;};'use strict';var util=require(_0xb87c('0x0'));var db=require(_0xb87c('0x1'))['db'];var jayson=require(_0xb87c('0x2'));var logger=require(_0xb87c('0x3'))(_0xb87c('0x4'));var client=jayson[_0xb87c('0x5')][_0xb87c('0x6')]({'port':0x232a});var triggers=[{'channel':'Chat','model':_0xb87c('0x7'),'event':_0xb87c('0x8'),'condition':_0xb87c('0x9'),'callback':afterCreate},{'channel':_0xb87c('0xa'),'model':_0xb87c('0x7'),'event':_0xb87c('0xb'),'condition':_0xb87c('0xc'),'callback':afterUpdate},{'channel':_0xb87c('0xa'),'model':_0xb87c('0xd'),'event':_0xb87c('0x8'),'condition':_0xb87c('0xe'),'callback':afterCreateMessage},{'channel':_0xb87c('0xf'),'model':_0xb87c('0x10'),'event':'afterCreate','condition':_0xb87c('0x9'),'callback':afterCreate},{'channel':_0xb87c('0xf'),'model':_0xb87c('0x10'),'event':_0xb87c('0xb'),'condition':_0xb87c('0xc'),'callback':afterUpdate},{'channel':'Sms','model':_0xb87c('0x11'),'event':_0xb87c('0x8'),'condition':_0xb87c('0xe'),'callback':afterCreateMessage},{'channel':_0xb87c('0x12'),'model':'WhatsappInteraction','event':_0xb87c('0x8'),'condition':'newinteraction','callback':afterCreate},{'channel':_0xb87c('0x12'),'model':_0xb87c('0x13'),'event':_0xb87c('0xb'),'condition':_0xb87c('0xc'),'callback':afterUpdate},{'channel':'Whatsapp','model':_0xb87c('0x14'),'event':_0xb87c('0x8'),'condition':_0xb87c('0xe'),'callback':afterCreateMessage},{'channel':_0xb87c('0x15'),'model':_0xb87c('0x16'),'event':_0xb87c('0x8'),'condition':'newinteraction','callback':afterCreate},{'channel':_0xb87c('0x15'),'model':_0xb87c('0x16'),'event':_0xb87c('0xb'),'condition':_0xb87c('0xc'),'callback':afterUpdate},{'channel':_0xb87c('0x15'),'model':_0xb87c('0x17'),'event':_0xb87c('0x8'),'condition':_0xb87c('0xe'),'callback':afterCreateMessage},{'channel':'Mail','model':'MailInteraction','event':_0xb87c('0x8'),'condition':_0xb87c('0x9'),'callback':afterCreate},{'channel':_0xb87c('0x18'),'model':_0xb87c('0x19'),'event':_0xb87c('0xb'),'condition':'closedinteraction','callback':afterUpdate},{'channel':_0xb87c('0x18'),'model':'MailMessage','event':_0xb87c('0x8'),'condition':_0xb87c('0xe'),'callback':afterCreateMessage},{'channel':_0xb87c('0x1a'),'model':_0xb87c('0x1b'),'event':'afterCreate','condition':_0xb87c('0x9'),'callback':afterCreate},{'channel':_0xb87c('0x1a'),'model':_0xb87c('0x1b'),'event':_0xb87c('0xb'),'condition':'closedinteraction','callback':afterUpdate},{'channel':_0xb87c('0x1a'),'model':_0xb87c('0x1c'),'event':_0xb87c('0x8'),'condition':_0xb87c('0xe'),'callback':afterCreateMessage}];function request(_0x398e1b){return client[_0xb87c('0x1d')](_0xb87c('0x1e'),_0x398e1b)[_0xb87c('0x1f')](function(_0x4ce8cd){logger[_0xb87c('0x20')](_0xb87c('0x21'),_0xb87c('0x1e'),_0x4ce8cd);if(_0x4ce8cd[_0xb87c('0x22')]){if(_0x4ce8cd['error'][_0xb87c('0x23')]===0x1f4){logger[_0xb87c('0x22')]('Trigger,\x20%s',_0xb87c('0x1e'),_0x4ce8cd['error']);}}})[_0xb87c('0x24')](function(_0x2355dd){logger['error']('Trigger,\x20%s',_0xb87c('0x1e'),_0x2355dd);});}function afterCreateMessage(_0x11f99e,_0x3fb2d2){return function(_0x260db9,_0x3ec57b){_0x260db9=_0x260db9['get']({'plain':!![]});_0x260db9[_0xb87c('0x25')]=_0x11f99e;_0x260db9[_0xb87c('0x26')]=_0x260db9[_0xb87c('0x27')];if(_0x260db9[_0xb87c('0x28')]){return db[_0xb87c('0x29')][_0xb87c('0x2a')]({'where':{'id':_0x260db9[_0xb87c('0x28')]},'attributes':['id',_0xb87c('0x2b')],'raw':!![]})[_0xb87c('0x1f')](function(_0x5efb28){_0x260db9[_0xb87c('0x2c')]=util[_0xb87c('0x2d')](_0xb87c('0x2e'),_0x5efb28['name']);_0x260db9[_0xb87c('0x25')]=_0x11f99e;return request({'event':_0xb87c('0x2f'),'message':_0x260db9});})['catch'](function(_0x13dab6){console[_0xb87c('0x22')](_0x13dab6);});}else{return request({'event':'outgoingmessage','message':_0x260db9});}};}function afterCreate(_0x37d147,_0x25c776){return function(_0x5e4346,_0x45537a){_0x5e4346=_0x5e4346[_0xb87c('0x30')]({'plain':!![]});_0x5e4346[_0xb87c('0x25')]=_0x37d147;_0x5e4346['event']=_0xb87c('0x31');return request({'event':_0x25c776,'message':_0x5e4346});};}function afterUpdate(_0x3ac1aa,_0xbc61a3){return function(_0x420e5c,_0x6364cd){if(_0x420e5c[_0xb87c('0x32')]('closed')&&_0x420e5c[_0xb87c('0x33')]){_0x420e5c=_0x420e5c['get']({'plain':!![]});_0x420e5c['channel']=_0x3ac1aa;_0x420e5c[_0xb87c('0x26')]=_0xb87c('0x33');if(_0x420e5c['UserId']){return db[_0xb87c('0x29')][_0xb87c('0x2a')]({'where':{'id':_0x420e5c[_0xb87c('0x28')]},'attributes':['id',_0xb87c('0x2b')],'raw':!![]})[_0xb87c('0x1f')](function(_0x137d64){_0x420e5c[_0xb87c('0x2c')]=util[_0xb87c('0x2d')](_0xb87c('0x2e'),_0x137d64[_0xb87c('0x2b')]);return request({'event':_0xbc61a3,'message':_0x420e5c});})[_0xb87c('0x24')](function(_0xc74dc4){console[_0xb87c('0x22')](_0xc74dc4);});}else{return request({'event':_0xbc61a3,'message':_0x420e5c});}}};}exports[_0xb87c('0x34')]=function(){for(var _0x1af086=0x0;_0x1af086<triggers['length'];_0x1af086+=0x1){if(db['hasOwnProperty'](triggers[_0x1af086][_0xb87c('0x35')])){db[triggers[_0x1af086]['model']][_0xb87c('0x36')](triggers[_0x1af086][_0xb87c('0x26')],triggers[_0x1af086][_0xb87c('0x37')](triggers[_0x1af086][_0xb87c('0x25')]['toLowerCase'](),triggers[_0x1af086]['condition']));}}};
\ No newline at end of file
+var _0x9bf2=['direction','UserId','find','then','interface','format','SIP/%s','name','channel','outgoingmessage','opened','changed','closed','User','default','hasOwnProperty','model','callback','toLowerCase','../../mysqldb','../logger','triggers','client','http','ChatInteraction','newinteraction','Chat','afterUpdate','closedinteraction','ChatMessage','afterCreate','newmessage','SmsInteraction','Sms','SmsMessage','Whatsapp','WhatsappInteraction','WhatsappMessage','Fax','FaxInteraction','FaxMessage','Mail','MailMessage','Openchannel','OpenchannelInteraction','OpenchannelMessage','request','EventManager','info','Trigger,\x20%s','error','code','catch','get','event'];(function(_0x557702,_0xd93eea){var _0x3eb6e5=function(_0x3de4ca){while(--_0x3de4ca){_0x557702['push'](_0x557702['shift']());}};_0x3eb6e5(++_0xd93eea);}(_0x9bf2,0x15d));var _0x29bf=function(_0x1f0ac0,_0xef0e93){_0x1f0ac0=_0x1f0ac0-0x0;var _0x2f2761=_0x9bf2[_0x1f0ac0];return _0x2f2761;};'use strict';var util=require('util');var db=require(_0x29bf('0x0'))['db'];var jayson=require('jayson/promise');var logger=require(_0x29bf('0x1'))(_0x29bf('0x2'));var client=jayson[_0x29bf('0x3')][_0x29bf('0x4')]({'port':0x232a});var triggers=[{'channel':'Chat','model':_0x29bf('0x5'),'event':'afterCreate','condition':_0x29bf('0x6'),'callback':afterCreate},{'channel':_0x29bf('0x7'),'model':_0x29bf('0x5'),'event':_0x29bf('0x8'),'condition':_0x29bf('0x9'),'callback':afterUpdate},{'channel':_0x29bf('0x7'),'model':_0x29bf('0xa'),'event':_0x29bf('0xb'),'condition':_0x29bf('0xc'),'callback':afterCreateMessage},{'channel':'Sms','model':_0x29bf('0xd'),'event':_0x29bf('0xb'),'condition':_0x29bf('0x6'),'callback':afterCreate},{'channel':_0x29bf('0xe'),'model':'SmsInteraction','event':_0x29bf('0x8'),'condition':_0x29bf('0x9'),'callback':afterUpdate},{'channel':_0x29bf('0xe'),'model':_0x29bf('0xf'),'event':_0x29bf('0xb'),'condition':'newmessage','callback':afterCreateMessage},{'channel':_0x29bf('0x10'),'model':'WhatsappInteraction','event':_0x29bf('0xb'),'condition':_0x29bf('0x6'),'callback':afterCreate},{'channel':_0x29bf('0x10'),'model':_0x29bf('0x11'),'event':_0x29bf('0x8'),'condition':_0x29bf('0x9'),'callback':afterUpdate},{'channel':_0x29bf('0x10'),'model':_0x29bf('0x12'),'event':_0x29bf('0xb'),'condition':_0x29bf('0xc'),'callback':afterCreateMessage},{'channel':_0x29bf('0x13'),'model':_0x29bf('0x14'),'event':_0x29bf('0xb'),'condition':_0x29bf('0x6'),'callback':afterCreate},{'channel':_0x29bf('0x13'),'model':_0x29bf('0x14'),'event':_0x29bf('0x8'),'condition':_0x29bf('0x9'),'callback':afterUpdate},{'channel':_0x29bf('0x13'),'model':_0x29bf('0x15'),'event':_0x29bf('0xb'),'condition':'newmessage','callback':afterCreateMessage},{'channel':'Mail','model':'MailInteraction','event':_0x29bf('0xb'),'condition':_0x29bf('0x6'),'callback':afterCreate},{'channel':_0x29bf('0x16'),'model':'MailInteraction','event':_0x29bf('0x8'),'condition':_0x29bf('0x9'),'callback':afterUpdate},{'channel':'Mail','model':_0x29bf('0x17'),'event':_0x29bf('0xb'),'condition':'newmessage','callback':afterCreateMessage},{'channel':_0x29bf('0x18'),'model':_0x29bf('0x19'),'event':_0x29bf('0xb'),'condition':_0x29bf('0x6'),'callback':afterCreate},{'channel':_0x29bf('0x18'),'model':_0x29bf('0x19'),'event':_0x29bf('0x8'),'condition':_0x29bf('0x9'),'callback':afterUpdate},{'channel':_0x29bf('0x18'),'model':_0x29bf('0x1a'),'event':_0x29bf('0xb'),'condition':_0x29bf('0xc'),'callback':afterCreateMessage}];function request(_0x189bdc){return client[_0x29bf('0x1b')](_0x29bf('0x1c'),_0x189bdc)['then'](function(_0x5e2d40){logger[_0x29bf('0x1d')](_0x29bf('0x1e'),'EventManager',_0x5e2d40);if(_0x5e2d40[_0x29bf('0x1f')]){if(_0x5e2d40['error'][_0x29bf('0x20')]===0x1f4){logger['error'](_0x29bf('0x1e'),_0x29bf('0x1c'),_0x5e2d40[_0x29bf('0x1f')]);}}})[_0x29bf('0x21')](function(_0x45c087){logger['error'](_0x29bf('0x1e'),_0x29bf('0x1c'),_0x45c087);});}function afterCreateMessage(_0x13f083,_0x3eb6c4){return function(_0x32cec2,_0x2ded99){_0x32cec2=_0x32cec2[_0x29bf('0x22')]({'plain':!![]});_0x32cec2['channel']=_0x13f083;_0x32cec2[_0x29bf('0x23')]=_0x32cec2[_0x29bf('0x24')];if(_0x32cec2[_0x29bf('0x25')]){return db['User'][_0x29bf('0x26')]({'where':{'id':_0x32cec2[_0x29bf('0x25')]},'attributes':['id','name'],'raw':!![]})[_0x29bf('0x27')](function(_0x34f8b6){_0x32cec2[_0x29bf('0x28')]=util[_0x29bf('0x29')](_0x29bf('0x2a'),_0x34f8b6[_0x29bf('0x2b')]);_0x32cec2[_0x29bf('0x2c')]=_0x13f083;return request({'event':'incomingmessage','message':_0x32cec2});})[_0x29bf('0x21')](function(_0x503d0b){console[_0x29bf('0x1f')](_0x503d0b);});}else{return request({'event':_0x29bf('0x2d'),'message':_0x32cec2});}};}function afterCreate(_0x2f1ddb,_0x364d17){return function(_0x1b7b02,_0x31ee25){_0x1b7b02=_0x1b7b02[_0x29bf('0x22')]({'plain':!![]});_0x1b7b02[_0x29bf('0x2c')]=_0x2f1ddb;_0x1b7b02['event']=_0x29bf('0x2e');return request({'event':_0x364d17,'message':_0x1b7b02});};}function afterUpdate(_0x3c0653,_0x43a4d6){return function(_0x3dbca4,_0x1a704a){if(_0x3dbca4[_0x29bf('0x2f')](_0x29bf('0x30'))&&_0x3dbca4[_0x29bf('0x30')]){_0x3dbca4=_0x3dbca4[_0x29bf('0x22')]({'plain':!![]});_0x3dbca4[_0x29bf('0x2c')]=_0x3c0653;_0x3dbca4[_0x29bf('0x23')]=_0x29bf('0x30');if(_0x3dbca4['UserId']){return db[_0x29bf('0x31')][_0x29bf('0x26')]({'where':{'id':_0x3dbca4[_0x29bf('0x25')]},'attributes':['id',_0x29bf('0x2b')],'raw':!![]})[_0x29bf('0x27')](function(_0x3be9a2){_0x3dbca4[_0x29bf('0x28')]=util[_0x29bf('0x29')]('SIP/%s',_0x3be9a2['name']);return request({'event':_0x43a4d6,'message':_0x3dbca4});})[_0x29bf('0x21')](function(_0x411b18){console[_0x29bf('0x1f')](_0x411b18);});}else{return request({'event':_0x43a4d6,'message':_0x3dbca4});}}};}exports[_0x29bf('0x32')]=function(){for(var _0x146746=0x0;_0x146746<triggers['length'];_0x146746+=0x1){if(db[_0x29bf('0x33')](triggers[_0x146746][_0x29bf('0x34')])){db[triggers[_0x146746][_0x29bf('0x34')]]['hook'](triggers[_0x146746][_0x29bf('0x23')],triggers[_0x146746][_0x29bf('0x35')](triggers[_0x146746][_0x29bf('0x2c')][_0x29bf('0x36')](),triggers[_0x146746]['condition']));}}};
\ No newline at end of file