Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / config / triggers / index.js
index 0311f1a..a3713ad 100644 (file)
@@ -1 +1 @@
-const a1048_0x8d4b=['format','default','closedinteraction','../logger','addHook','UserId','EventManager','Fax','undefined','then','OpenchannelInteraction','FaxInteraction','newmessage','catch','SIP/%s','OpenchannelMessage','error','User','jayson/promise','get','http','Whatsapp','opened','../../mysqldb','model','direction','condition','incomingmessage','Openchannel','callback','client','afterUpdate','FaxMessage','SmsMessage','WhatsappInteraction','toLowerCase','channel','ChatMessage','info','ChatInteraction','length','closed','code','Trigger,\x20%s','WhatsappMessage','newinteraction','afterCreate','Sms','event','interface','Chat','changed','SmsInteraction','findOne','Mail','name'];(function(_0x37463b,_0x5dff49){const _0x8d4b5f=function(_0x5a5443){while(--_0x5a5443){_0x37463b['push'](_0x37463b['shift']());}};_0x8d4b5f(++_0x5dff49);}(a1048_0x8d4b,0xd9));const a1048_0x5a54=function(_0x37463b,_0x5dff49){_0x37463b=_0x37463b-0x8f;let _0x8d4b5f=a1048_0x8d4b[_0x37463b];return _0x8d4b5f;};const a1048_0x194bf2=a1048_0x5a54;'use strict';const util=require('util'),{db}=require(a1048_0x194bf2(0xad)),jayson=require(a1048_0x194bf2(0xa8)),logger=require(a1048_0x194bf2(0x99))('triggers'),client=jayson[a1048_0x194bf2(0xb4)][a1048_0x194bf2(0xaa)]({'port':0x232a}),triggers=[{'channel':'Chat','model':a1048_0x194bf2(0xbd),'event':a1048_0x194bf2(0xc4),'condition':a1048_0x194bf2(0xc3),'callback':afterCreate},{'channel':a1048_0x194bf2(0x90),'model':a1048_0x194bf2(0xbd),'event':a1048_0x194bf2(0xb5),'condition':'closedinteraction','callback':afterUpdate},{'channel':a1048_0x194bf2(0x90),'model':a1048_0x194bf2(0xbb),'event':a1048_0x194bf2(0xc4),'condition':'newmessage','callback':afterCreateMessage},{'channel':a1048_0x194bf2(0xc5),'model':a1048_0x194bf2(0x92),'event':a1048_0x194bf2(0xc4),'condition':a1048_0x194bf2(0xc3),'callback':afterCreate},{'channel':a1048_0x194bf2(0xc5),'model':a1048_0x194bf2(0x92),'event':'afterUpdate','condition':a1048_0x194bf2(0x98),'callback':afterUpdate},{'channel':a1048_0x194bf2(0xc5),'model':a1048_0x194bf2(0xb7),'event':a1048_0x194bf2(0xc4),'condition':'newmessage','callback':afterCreateMessage},{'channel':a1048_0x194bf2(0xab),'model':'WhatsappInteraction','event':a1048_0x194bf2(0xc4),'condition':'newinteraction','callback':afterCreate},{'channel':a1048_0x194bf2(0xab),'model':a1048_0x194bf2(0xb8),'event':'afterUpdate','condition':a1048_0x194bf2(0x98),'callback':afterUpdate},{'channel':a1048_0x194bf2(0xab),'model':a1048_0x194bf2(0xc2),'event':a1048_0x194bf2(0xc4),'condition':'newmessage','callback':afterCreateMessage},{'channel':a1048_0x194bf2(0x9d),'model':a1048_0x194bf2(0xa1),'event':a1048_0x194bf2(0xc4),'condition':a1048_0x194bf2(0xc3),'callback':afterCreate},{'channel':a1048_0x194bf2(0x9d),'model':a1048_0x194bf2(0xa1),'event':'afterUpdate','condition':a1048_0x194bf2(0x98),'callback':afterUpdate},{'channel':a1048_0x194bf2(0x9d),'model':a1048_0x194bf2(0xb6),'event':a1048_0x194bf2(0xc4),'condition':a1048_0x194bf2(0xa2),'callback':afterCreateMessage},{'channel':a1048_0x194bf2(0x94),'model':'MailInteraction','event':'afterCreate','condition':a1048_0x194bf2(0xc3),'callback':afterCreate},{'channel':a1048_0x194bf2(0x94),'model':'MailInteraction','event':a1048_0x194bf2(0xb5),'condition':a1048_0x194bf2(0x98),'callback':afterUpdate},{'channel':a1048_0x194bf2(0x94),'model':'MailMessage','event':a1048_0x194bf2(0xc4),'condition':a1048_0x194bf2(0xa2),'callback':afterCreateMessage},{'channel':a1048_0x194bf2(0xb2),'model':a1048_0x194bf2(0xa0),'event':a1048_0x194bf2(0xc4),'condition':'newinteraction','callback':afterCreate},{'channel':'Openchannel','model':a1048_0x194bf2(0xa0),'event':a1048_0x194bf2(0xb5),'condition':a1048_0x194bf2(0x98),'callback':afterUpdate},{'channel':'Openchannel','model':a1048_0x194bf2(0xa5),'event':'afterCreate','condition':a1048_0x194bf2(0xa2),'callback':afterCreateMessage}];function request(_0x2c46cf){const _0x5595c5=a1048_0x194bf2;return client['request'](_0x5595c5(0x9c),_0x2c46cf)[_0x5595c5(0x9f)](function(_0x5399da){const _0xe52bc6=_0x5595c5;logger[_0xe52bc6(0xbc)]('Trigger,\x20%s','EventManager',_0x5399da),_0x5399da['error']&&(_0x5399da[_0xe52bc6(0xa6)][_0xe52bc6(0xc0)]===0x1f4&&logger['error']('Trigger,\x20%s',_0xe52bc6(0x9c),_0x5399da[_0xe52bc6(0xa6)]));})[_0x5595c5(0xa3)](function(_0x31ead0){const _0x444394=_0x5595c5;logger[_0x444394(0xa6)](_0x444394(0xc1),_0x444394(0x9c),_0x31ead0);});}function afterCreateMessage(_0x17abc3){return function(_0xaa1bbd){const _0x339a9f=a1048_0x5a54;return _0xaa1bbd=_0xaa1bbd[_0x339a9f(0xa9)]({'plain':!![]}),_0xaa1bbd[_0x339a9f(0xba)]=_0x17abc3,_0xaa1bbd[_0x339a9f(0xc6)]=_0xaa1bbd[_0x339a9f(0xaf)],_0xaa1bbd[_0x339a9f(0x9b)]?db[_0x339a9f(0xa7)][_0x339a9f(0x93)]({'where':{'id':_0xaa1bbd[_0x339a9f(0x9b)]},'attributes':['id',_0x339a9f(0x95)],'raw':!![]})[_0x339a9f(0x9f)](function(_0x37fd2c){const _0x200f76=_0x339a9f;return _0xaa1bbd[_0x200f76(0x8f)]=util['format'](_0x200f76(0xa4),_0x37fd2c[_0x200f76(0x95)]),_0xaa1bbd['channel']=_0x17abc3,request({'event':_0x200f76(0xb1),'message':_0xaa1bbd});})[_0x339a9f(0xa3)](function(_0x3cc0ec){console['error'](_0x3cc0ec);}):request({'event':'outgoingmessage','message':_0xaa1bbd});};}function afterCreate(_0x44c6e9,_0x20585c){return function(_0x43396a){const _0x30c85d=a1048_0x5a54;return _0x43396a=_0x43396a[_0x30c85d(0xa9)]({'plain':!![]}),_0x43396a['channel']=_0x44c6e9,_0x43396a[_0x30c85d(0xc6)]=_0x30c85d(0xac),request({'event':_0x20585c,'message':_0x43396a});};}function afterUpdate(_0x1ca1df,_0x398f49){return function(_0x1e8514){const _0x22cf00=a1048_0x5a54;if(_0x1e8514[_0x22cf00(0x91)](_0x22cf00(0xbf))&&_0x1e8514[_0x22cf00(0xbf)])return _0x1e8514=_0x1e8514[_0x22cf00(0xa9)]({'plain':!![]}),_0x1e8514[_0x22cf00(0xba)]=_0x1ca1df,_0x1e8514[_0x22cf00(0xc6)]=_0x22cf00(0xbf),_0x1e8514['UserId']?db[_0x22cf00(0xa7)][_0x22cf00(0x93)]({'where':{'id':_0x1e8514[_0x22cf00(0x9b)]},'attributes':['id','name'],'raw':!![]})[_0x22cf00(0x9f)](function(_0x3c9b4f){const _0x22bf57=_0x22cf00;return _0x1e8514[_0x22bf57(0x8f)]=util[_0x22bf57(0x96)](_0x22bf57(0xa4),_0x3c9b4f['name']),request({'event':_0x398f49,'message':_0x1e8514});})[_0x22cf00(0xa3)](function(_0x3e7601){console['error'](_0x3e7601);}):request({'event':_0x398f49,'message':_0x1e8514});};}exports[a1048_0x194bf2(0x97)]=function(){const _0x512975=a1048_0x194bf2;for(let _0x19f990=0x0;_0x19f990<triggers[_0x512975(0xbe)];_0x19f990+=0x1){typeof db[triggers[_0x19f990][_0x512975(0xae)]]!==_0x512975(0x9e)&&db[triggers[_0x19f990]['model']][_0x512975(0x9a)](triggers[_0x19f990][_0x512975(0xc6)],triggers[_0x19f990][_0x512975(0xb3)](triggers[_0x19f990][_0x512975(0xba)][_0x512975(0xb9)](),triggers[_0x19f990][_0x512975(0xb0)]));}};
\ No newline at end of file
+const a1051_0x5aea=['Sms','event','direction','afterUpdate','WhatsappMessage','FaxMessage','default','OpenchannelInteraction','SmsMessage','outgoingmessage','http','opened','newmessage','Openchannel','newinteraction','get','Fax','ChatInteraction','incomingmessage','EventManager','then','UserId','afterCreate','closed','undefined','util','client','Trigger,\x20%s','SIP/%s','WhatsappInteraction','OpenchannelMessage','../logger','interface','code','catch','toLowerCase','SmsInteraction','addHook','findOne','Chat','FaxInteraction','request','changed','model','format','jayson/promise','../../mysqldb','triggers','name','ChatMessage','closedinteraction','callback','User','MailInteraction','Mail','error','channel','Whatsapp'];(function(_0x2883f3,_0x1148da){const _0x5aeaba=function(_0x56c8ed){while(--_0x56c8ed){_0x2883f3['push'](_0x2883f3['shift']());}};_0x5aeaba(++_0x1148da);}(a1051_0x5aea,0xd2));const a1051_0x56c8=function(_0x2883f3,_0x1148da){_0x2883f3=_0x2883f3-0x1b0;let _0x5aeaba=a1051_0x5aea[_0x2883f3];return _0x5aeaba;};const a1051_0x1068f2=a1051_0x56c8;'use strict';const util=require(a1051_0x1068f2(0x1df)),{db}=require(a1051_0x1068f2(0x1ba)),jayson=require(a1051_0x1068f2(0x1b9)),logger=require(a1051_0x1068f2(0x1e5))(a1051_0x1068f2(0x1bb)),client=jayson[a1051_0x1068f2(0x1e0)][a1051_0x1068f2(0x1d0)]({'port':0x232a}),TRIGGERS=[{'channel':a1051_0x1068f2(0x1b3),'model':a1051_0x1068f2(0x1d7),'event':'afterCreate','condition':a1051_0x1068f2(0x1d4),'callback':afterCreate},{'channel':a1051_0x1068f2(0x1b3),'model':a1051_0x1068f2(0x1d7),'event':a1051_0x1068f2(0x1c9),'condition':a1051_0x1068f2(0x1be),'callback':afterUpdate},{'channel':'Chat','model':a1051_0x1068f2(0x1bd),'event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d2),'callback':afterCreateMessage},{'channel':a1051_0x1068f2(0x1c6),'model':a1051_0x1068f2(0x1b0),'event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d4),'callback':afterCreate},{'channel':'Sms','model':a1051_0x1068f2(0x1b0),'event':'afterUpdate','condition':'closedinteraction','callback':afterUpdate},{'channel':'Sms','model':a1051_0x1068f2(0x1ce),'event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d2),'callback':afterCreateMessage},{'channel':a1051_0x1068f2(0x1c5),'model':a1051_0x1068f2(0x1e3),'event':'afterCreate','condition':a1051_0x1068f2(0x1d4),'callback':afterCreate},{'channel':'Whatsapp','model':'WhatsappInteraction','event':a1051_0x1068f2(0x1c9),'condition':a1051_0x1068f2(0x1be),'callback':afterUpdate},{'channel':a1051_0x1068f2(0x1c5),'model':a1051_0x1068f2(0x1ca),'event':'afterCreate','condition':a1051_0x1068f2(0x1d2),'callback':afterCreateMessage},{'channel':a1051_0x1068f2(0x1d6),'model':a1051_0x1068f2(0x1b4),'event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d4),'callback':afterCreate},{'channel':a1051_0x1068f2(0x1d6),'model':a1051_0x1068f2(0x1b4),'event':a1051_0x1068f2(0x1c9),'condition':a1051_0x1068f2(0x1be),'callback':afterUpdate},{'channel':a1051_0x1068f2(0x1d6),'model':a1051_0x1068f2(0x1cb),'event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d2),'callback':afterCreateMessage},{'channel':'Mail','model':a1051_0x1068f2(0x1c1),'event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d4),'callback':afterCreate},{'channel':a1051_0x1068f2(0x1c2),'model':a1051_0x1068f2(0x1c1),'event':a1051_0x1068f2(0x1c9),'condition':a1051_0x1068f2(0x1be),'callback':afterUpdate},{'channel':a1051_0x1068f2(0x1c2),'model':'MailMessage','event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d2),'callback':afterCreateMessage},{'channel':a1051_0x1068f2(0x1d3),'model':'OpenchannelInteraction','event':a1051_0x1068f2(0x1dc),'condition':a1051_0x1068f2(0x1d4),'callback':afterCreate},{'channel':a1051_0x1068f2(0x1d3),'model':a1051_0x1068f2(0x1cd),'event':'afterUpdate','condition':a1051_0x1068f2(0x1be),'callback':afterUpdate},{'channel':a1051_0x1068f2(0x1d3),'model':a1051_0x1068f2(0x1e4),'event':a1051_0x1068f2(0x1dc),'condition':'newmessage','callback':afterCreateMessage}];function request(_0xd61d6){const _0x453cc2=a1051_0x1068f2;return client[_0x453cc2(0x1b5)]('EventManager',_0xd61d6)[_0x453cc2(0x1da)](function(_0x33d59f){const _0x39e41c=_0x453cc2;logger['info']('Trigger,\x20%s',_0x39e41c(0x1d9),_0x33d59f),_0x33d59f[_0x39e41c(0x1c3)]&&(_0x33d59f[_0x39e41c(0x1c3)][_0x39e41c(0x1e7)]===0x1f4&&logger[_0x39e41c(0x1c3)](_0x39e41c(0x1e1),_0x39e41c(0x1d9),_0x33d59f[_0x39e41c(0x1c3)]));})[_0x453cc2(0x1e8)](function(_0x319049){const _0x3af508=_0x453cc2;logger[_0x3af508(0x1c3)](_0x3af508(0x1e1),'EventManager',_0x319049);});}function afterCreateMessage(_0x302332){return function(_0x34a995){const _0x21868e=a1051_0x56c8;return _0x34a995=_0x34a995[_0x21868e(0x1d5)]({'plain':!![]}),_0x34a995['channel']=_0x302332,_0x34a995[_0x21868e(0x1c7)]=_0x34a995[_0x21868e(0x1c8)],_0x34a995[_0x21868e(0x1db)]?db[_0x21868e(0x1c0)][_0x21868e(0x1b2)]({'where':{'id':_0x34a995['UserId']},'attributes':['id','name'],'raw':!![]})['then'](function(_0x1b6a6c){const _0x45a19d=_0x21868e;return _0x34a995[_0x45a19d(0x1e6)]=util[_0x45a19d(0x1b8)](_0x45a19d(0x1e2),_0x1b6a6c[_0x45a19d(0x1bc)]),_0x34a995[_0x45a19d(0x1c4)]=_0x302332,request({'event':_0x45a19d(0x1d8),'message':_0x34a995});})[_0x21868e(0x1e8)](function(_0x2ffdb9){const _0x33c17b=_0x21868e;console[_0x33c17b(0x1c3)](_0x2ffdb9);}):request({'event':_0x21868e(0x1cf),'message':_0x34a995});};}function afterCreate(_0x42e742,_0x2e023b){return function(_0x43c731){const _0x2b8763=a1051_0x56c8;return _0x43c731=_0x43c731[_0x2b8763(0x1d5)]({'plain':!![]}),_0x43c731[_0x2b8763(0x1c4)]=_0x42e742,_0x43c731[_0x2b8763(0x1c7)]=_0x2b8763(0x1d1),request({'event':_0x2e023b,'message':_0x43c731});};}function afterUpdate(_0x55f86d,_0x438c0b){return function(_0x1734dd){const _0x8cf8b=a1051_0x56c8;if(_0x1734dd[_0x8cf8b(0x1b6)]('closed')&&_0x1734dd[_0x8cf8b(0x1dd)])return _0x1734dd=_0x1734dd[_0x8cf8b(0x1d5)]({'plain':!![]}),_0x1734dd[_0x8cf8b(0x1c4)]=_0x55f86d,_0x1734dd[_0x8cf8b(0x1c7)]='closed',_0x1734dd[_0x8cf8b(0x1db)]?db[_0x8cf8b(0x1c0)][_0x8cf8b(0x1b2)]({'where':{'id':_0x1734dd['UserId']},'attributes':['id',_0x8cf8b(0x1bc)],'raw':!![]})[_0x8cf8b(0x1da)](function(_0x38f235){const _0x249ffc=_0x8cf8b;return _0x1734dd[_0x249ffc(0x1e6)]=util[_0x249ffc(0x1b8)]('SIP/%s',_0x38f235['name']),request({'event':_0x438c0b,'message':_0x1734dd});})['catch'](function(_0x28c07e){console['error'](_0x28c07e);}):request({'event':_0x438c0b,'message':_0x1734dd});};}function triggers(){const _0x387ade=a1051_0x1068f2;for(let _0xeabd82=0x0;_0xeabd82<TRIGGERS['length'];_0xeabd82+=0x1){typeof db[TRIGGERS[_0xeabd82][_0x387ade(0x1b7)]]!==_0x387ade(0x1de)&&db[TRIGGERS[_0xeabd82][_0x387ade(0x1b7)]][_0x387ade(0x1b1)](TRIGGERS[_0xeabd82][_0x387ade(0x1c7)],TRIGGERS[_0xeabd82][_0x387ade(0x1bf)](TRIGGERS[_0xeabd82][_0x387ade(0x1c4)][_0x387ade(0x1e9)](),TRIGGERS[_0xeabd82]['condition']));}}exports[a1051_0x1068f2(0x1bb)]=triggers,exports[a1051_0x1068f2(0x1cc)]=triggers;
\ No newline at end of file