Fix: ntfy create correct topic usage

This commit is contained in:
2025-11-10 13:42:43 -08:00
parent 567cb7ae4d
commit c51b7d25b7

View File

@@ -6,18 +6,18 @@ const RESERVED = new Set([
"settings","profile","password","user","users","link","links","url","urls", "settings","profile","password","user","users","link","links","url","urls",
"robots","sitemap","favicon","well-known","assets","static","img","js","css","public" "robots","sitemap","favicon","well-known","assets","static","img","js","css","public"
]); ]);
const ntfy = (env,topic,title,msg,p=3) => const ntfy = (env,title,msg,p=3) =>
env.NTFY_TOPIC ? env.NTFY_TOPIC
fetch(`https://ntfy.sh/${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"
}, },
body:msg body:msg
}).catch(()=>{}) : }).catch(()=>{})
Promise.resolve(); : Promise.resolve();
export async function onRequestPost({ request, env }) { export async function onRequestPost({ request, env }) {
try { try {
@@ -76,7 +76,6 @@ export async function onRequestPost({ request, env }) {
.run(), .run(),
ntfy( ntfy(
env, env,
env.NTFY_TOPIC,
"link-create", "link-create",
`event=create\nuser=${username}\nslug=${finalSlug}\ndestination=${dest_no_proto}`, `event=create\nuser=${username}\nslug=${finalSlug}\ndestination=${dest_no_proto}`,
3 3