Skip to content

Commit b87ca11

Browse files
committed
jk no webhook replies. remove close reason from embed title
1 parent 5aa20e5 commit b87ca11

5 files changed

Lines changed: 7 additions & 19 deletions

File tree

web/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class BaseSession extends Container<Env> {
5353
// In-memory only: on DO hibernation we lose geo/ISP fields in the end
5454
// embed, which is cosmetic — never a correctness concern.
5555
protected obsContext?: RequestContext;
56-
private startMessageId?: string;
5756

5857
private async fetchCapacitySnapshot(): Promise<CapacitySnapshot | undefined> {
5958
try {
@@ -108,7 +107,7 @@ export class BaseSession extends Container<Env> {
108107
this.obsContext = parseContext(request.headers.get(OBS_CONTEXT_HEADER));
109108
void (async () => {
110109
const capacity = await this.fetchCapacitySnapshot();
111-
this.startMessageId = await notify.sessionStarted(this.env, {
110+
await notify.sessionStarted(this.env, {
112111
sessionId,
113112
branch: this.branch,
114113
context: this.obsContext ?? { ip: "unknown" },
@@ -415,7 +414,6 @@ export class BaseSession extends Container<Env> {
415414
extensionGranted: this.extensionGranted,
416415
context: this.obsContext,
417416
capacity,
418-
replyTo: this.startMessageId,
419417
});
420418
})();
421419
}

web/src/observability/embeds.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ interface DiscordEmbed {
2727

2828
export interface DiscordWebhookPayload {
2929
embeds: DiscordEmbed[];
30-
message_reference?: { message_id: string };
3130
}
3231

3332
const COLORS = {
@@ -197,7 +196,7 @@ export function buildSessionEndedEmbed(e: SessionEndedEvent): DiscordEmbed {
197196
);
198197

199198
return {
200-
title: `🏁 Session ended · ${reason.label}`,
199+
title: "🏁 Session ended",
201200
url: sessionHistoryUrl(e.sessionId),
202201
description: truncate(lines.join("\n"), LIMIT_DESCRIPTION),
203202
color: reason.color,

web/src/observability/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ export const notify = {
2323
sessionStarted: (env: Env, event: SessionStartedEvent) =>
2424
post(env, { embeds: [buildSessionStartedEmbed(event)] }),
2525
sessionEnded: (env: Env, event: SessionEndedEvent) =>
26-
post(env, {
27-
embeds: [buildSessionEndedEmbed(event)],
28-
...(event.replyTo ? { message_reference: { message_id: event.replyTo } } : {}),
29-
}),
26+
post(env, { embeds: [buildSessionEndedEmbed(event)] }),
3027
queueEntered: (env: Env, event: QueueEnteredEvent) =>
3128
post(env, { embeds: [buildQueueEnteredEmbed(event)] }),
3229
error: (env: Env, event: ErrorEvent) =>

web/src/observability/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export interface SessionEndedEvent {
4646
extensionGranted: boolean;
4747
context?: RequestContext;
4848
capacity?: CapacitySnapshot;
49-
replyTo?: string;
5049
}
5150

5251
export interface QueueEnteredEvent {

web/src/observability/webhook.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@ const WEBHOOK_TIMEOUT_MS = 3000;
44

55
// Fire-and-forget. No-op when the secret is unset. Never throws —
66
// observability must not be able to break the request path.
7-
// Returns the Discord message ID when available (for threading replies).
8-
export async function post(env: { DISCORD_WEBHOOK_URL?: string }, payload: DiscordWebhookPayload): Promise<string | undefined> {
7+
export async function post(env: { DISCORD_WEBHOOK_URL?: string }, payload: DiscordWebhookPayload): Promise<void> {
98
const url = env.DISCORD_WEBHOOK_URL;
10-
if (!url) return undefined;
9+
if (!url) return;
1110

1211
let body: string;
1312
try {
1413
body = JSON.stringify(payload);
1514
} catch (e) {
1615
console.error("[obs] webhook payload JSON.stringify failed:", e);
17-
return undefined;
16+
return;
1817
}
1918

2019
const controller = new AbortController();
2120
const timeout = setTimeout(() => controller.abort(), WEBHOOK_TIMEOUT_MS);
2221

2322
try {
24-
const res = await fetch(`${url}?wait=true`, {
23+
const res = await fetch(url, {
2524
method: "POST",
2625
headers: { "Content-Type": "application/json" },
2726
body,
@@ -32,10 +31,7 @@ export async function post(env: { DISCORD_WEBHOOK_URL?: string }, payload: Disco
3231
console.error(
3332
`[obs] webhook non-2xx: status=${res.status} statusText=${res.statusText} body=${resBody.slice(0, 300)}`,
3433
);
35-
return undefined;
3634
}
37-
const data = await res.json<{ id: string }>();
38-
return data.id;
3935
} catch (e) {
4036
if (e instanceof Error && e.name === "AbortError") {
4137
console.error(`[obs] webhook timed out after ${WEBHOOK_TIMEOUT_MS}ms`);
@@ -44,7 +40,6 @@ export async function post(env: { DISCORD_WEBHOOK_URL?: string }, payload: Disco
4440
const msg = e instanceof Error ? e.message : String(e);
4541
console.error(`[obs] webhook post failed: ${name}: ${msg}`);
4642
}
47-
return undefined;
4843
} finally {
4944
clearTimeout(timeout);
5045
}

0 commit comments

Comments
 (0)