updated bot
This commit is contained in:
+13
-7
@@ -30,12 +30,16 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await env.SEND_EMAIL.send({
|
if (env.SEND_EMAIL) {
|
||||||
from: `FEDL <[email protected]>`,
|
await env.SEND_EMAIL.send({
|
||||||
to: body.to,
|
from: `FEDL <[email protected]>`,
|
||||||
subject: body.subject,
|
to: body.to,
|
||||||
text: body.text,
|
subject: body.subject,
|
||||||
});
|
text: body.text,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new Error('SEND_EMAIL binding not configured. Go to Workers & Pages → your worker → Settings → Bindings to add it.');
|
||||||
|
}
|
||||||
|
|
||||||
return new Response(JSON.stringify({ ok: true }), {
|
return new Response(JSON.stringify({ ok: true }), {
|
||||||
status: 200,
|
status: 200,
|
||||||
@@ -55,6 +59,8 @@ export default {
|
|||||||
} satisfies ExportedHandler<Env>;
|
} satisfies ExportedHandler<Env>;
|
||||||
|
|
||||||
interface Env {
|
interface Env {
|
||||||
SEND_EMAIL: any;
|
SEND_EMAIL?: {
|
||||||
|
send(options: { from: string; to: string; subject: string; text: string }): Promise<void>;
|
||||||
|
};
|
||||||
FORWARD_TO: string;
|
FORWARD_TO: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user