mirror of
https://github.com/spchcap/speech.capital.git
synced 2026-02-04 02:47:55 +00:00
Fix: Await ntfy notifications to ensure delivery
This commit is contained in:
@@ -3,7 +3,7 @@ const json = (d, o = {}) => {
|
||||
h.set('Content-Type', 'application/json');
|
||||
return new Response(JSON.stringify(d), { ...o, headers: h });
|
||||
};
|
||||
const notify=(url,msg,prio=3)=>{if(!url)return;const target=url.startsWith('http')?url:`https://${url}`;fetch(target,{method:'POST',body:msg,headers:{'X-Priority':prio.toString()}}).catch(()=>{})};
|
||||
const notify=async(url,msg,prio=3)=>{if(!url)return;const target=url.startsWith('http')?url:`https://${url}`;try{await fetch(target,{method:'POST',body:msg,headers:{'X-Priority':prio.toString()}})}catch(e){}};
|
||||
|
||||
export async function onRequestPost({ request, env }) {
|
||||
try {
|
||||
@@ -24,7 +24,7 @@ export async function onRequestPost({ request, env }) {
|
||||
|
||||
const user = await env.D1_SPCHCAP.prepare('SELECT role FROM users WHERE username = ?').bind(username).first();
|
||||
|
||||
notify(env.NTFY_URL, `New User Signup: ${username} (${email})`, 3);
|
||||
await notify(env.NTFY_URL, `New User Signup: ${username} (${email})`, 3);
|
||||
|
||||
const exp = new Date(Date.now() + 2592e6); // 30 days
|
||||
const opts = `Domain=.speech.capital; Path=/; Expires=${exp.toUTCString()}; HttpOnly; Secure; SameSite=Strict`;
|
||||
|
||||
Reference in New Issue
Block a user