Files
svc-api-x/v1/lib/notifier.cfc
2024-10-23 11:17:42 +03:00

33 lines
1.3 KiB
Plaintext

<cfcomponent
displayname="Notifier"
output="true"
hint="Notification helper, to be refactored">
<!---Внимание! необходимо зарегистрировать на сервере сертификат хоста maker.ifttt.com, иначе SSL соединение не установится и будет Connection Failure--->
<!--- Нужно реализовывать нормальную систему с подпиской на события, по типу
https://tonytruong.net/event-emitter-pattern-in-coldfusion/--->
<cffunction name="notify"
access="public"
returntype="any"
output="false"
hint="send notification">
<cfargument name="value1" type="string" required="true" />
<cfargument name="value2" type="string" required="true" />
<cfargument name="value3" type="string" required="true" />
<cftry>
<cfhttp name="ifttt" method="post" url="https://maker.ifttt.com/trigger/mms_task_event/with/key/drWn5g6pNjyP_XRru0tMrQ" result="resp" timeout="10">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="body" value="#serializeJSON(arguments)#">
</cfhttp>
<cfreturn resp.filecontent/>
<cfcatch type="ANY">
<cfreturn "#cfcatch.message# #cfcatch.detail#"/>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>