Feat: Add Seize action button to ntfy on update

This commit is contained in:
2025-11-22 07:27:07 -08:00
parent 72e1e70612
commit 247ee6dcc3

View File

@@ -1,11 +1,12 @@
const ntfy = (env,title,msg,p=2) => const ntfy = (env,title,msg,act,p=2) =>
env.NTFY_TOPIC env.NTFY_TOPIC
? fetch(`https://ntfy.sh/${env.NTFY_TOPIC}`,{ ? fetch(`https://ntfy.sh/${env.NTFY_TOPIC}`,{
method:"POST", method:"POST",
headers:{ headers:{
"Title":`✏️ ${title}`, "Title":`✏️ ${title}`,
"Priority":String(p), "Priority":String(p),
"Content-Type":"text/plain" "Content-Type":"text/plain",
...(act?{"Actions":`view, Seize, ${act}`}:{})
}, },
body:msg body:msg
}).catch(()=>{}) }).catch(()=>{})
@@ -68,6 +69,7 @@ export async function onRequestPost({ request, env }) {
env, env,
`link-${evt}`, `link-${evt}`,
`event=${evt}\nuser=${username}\nslug=${slug}\ndestination=${dest_no_proto}\nanalytics_enabled=${!!analytics_enabled}`, `event=${evt}\nuser=${username}\nslug=${slug}\ndestination=${dest_no_proto}\nanalytics_enabled=${!!analytics_enabled}`,
`${new URL(request.url).origin}/admin?slug=${slug}`,
2 2
) )
]); ]);
@@ -77,4 +79,3 @@ export async function onRequestPost({ request, env }) {
return new Response(e.message,{ status:500 }); return new Response(e.message,{ status:500 });
} }
} }