mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Refactor: Use emoji in notification title
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
export async function onRequestPost(ctx) {
|
export async function onRequestPost({ request, env }) {
|
||||||
const { request, env } = ctx;
|
|
||||||
const { email } = await request.json().catch(() => ({}));
|
const { email } = await request.json().catch(() => ({}));
|
||||||
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email))
|
||||||
return new Response(JSON.stringify({ error: 'Invalid email' }), { status: 400, headers: { 'Content-Type': 'application/json' } });
|
return new Response('{"error":"Invalid email"}', { status: 400, headers: { 'Content-Type': 'application/json' } });
|
||||||
}
|
|
||||||
const cf = request.cf || {};
|
const c = request.cf || {};
|
||||||
const geo = [cf.city, cf.region, cf.country].filter(Boolean).join(', ') || 'Unknown';
|
const geo = [c.city, c.region, c.country].filter(Boolean).join(', ') || 'Unknown';
|
||||||
|
|
||||||
await fetch(`https://ntfy.sh/${env.NTFY_TOPIC}`, {
|
await fetch(`https://ntfy.sh/${env.NTFY_TOPIC}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { Priority: '3', Title: `New sub: ${geo}` },
|
headers: { Priority: '3', Title: `📬 ${geo}` },
|
||||||
body: email
|
body: email
|
||||||
});
|
});
|
||||||
return new Response(JSON.stringify({ ok: true }), { headers: { 'Content-Type': 'application/json' } });
|
|
||||||
|
return new Response('{"ok":true}', { headers: { 'Content-Type': 'application/json' } });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user