File tree Expand file tree Collapse file tree 1 file changed +20
-22
lines changed
src/flows/pipes/Notification/endpoints/Mailgun Expand file tree Collapse file tree 1 file changed +20
-22
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ export default register => {
2626 const subject = encodeURIComponent ( 'InfluxDB Alert' )
2727 const fromEmail = `mailgun@${ data . domain } `
2828
29- return `task_data
29+ return `apiKey = secrets.get(key: "${ data . apiKey } ")
30+ auth = http.basicAuth(u: "api", p: "\${apiKey}")
31+
32+ task_data
3033 |> schema["fieldsAsCols"]()
3134 |> set(key: "_notebook_link", value: "${ window . location . href } ")
3235 |> monitor["check"](
@@ -36,27 +39,22 @@ export default register => {
3639 )
3740 |> monitor["notify"](
3841 data: notification,
39- endpoint: ((r) => {
40- apiKey = secrets.get(key: "${ data . apiKey } ")
41- auth = http.basicAuth(u: "api", p: "\${apiKey}")
42- url = "https://api.mailgun.net/v3/${ data . domain } /messages"
43- data = strings.joinStr(arr: [
44- "from=${ fromEmail } ",
45- "to=${ data . email } ",
46- "subject=${ subject } ",
47- "text=\${r._message}"
48- ], v: "&"
49- )
50- http.post(
51- url: url,
52- headers: {
53- "Content-Type": "application/x-www-form-urlencoded",
54- "Authorization": "\${auth}"
55- },
56- data: bytes(v: data)
57- )
58- array.from(rows: [{value: 0}])
59- |> yield(name: "ignore")
42+ endpoint: http.endpoint(url: "https://api.mailgun.net/v3/${ data . domain } /messages")(
43+ mapFn: (r) => {
44+ data = strings.joinStr(arr: [
45+ "from=${ fromEmail } ",
46+ "to=${ data . email } ",
47+ "subject=${ subject } ",
48+ "text=\${r._message}"
49+ ], v: "&"
50+ )
51+ return {
52+ headers: {
53+ "Content-Type": "application/x-www-form-urlencoded",
54+ "Authorization": "\${auth}"
55+ },
56+ data: bytes(v: data)
57+ }
6058 })
6159 )`
6260 } ,
You can’t perform that action at this time.
0 commit comments