diff --git a/backend/brico-bot/src/discord/display-manager.ts b/backend/brico-bot/src/discord/display-manager.ts index ee209d2f..ebd6c2da 100644 --- a/backend/brico-bot/src/discord/display-manager.ts +++ b/backend/brico-bot/src/discord/display-manager.ts @@ -59,6 +59,11 @@ function isForbidden(cause: unknown): boolean { return cause instanceof DiscordAPIError && cause.status === 403; } +/** The target is an archived thread (Discord error 50083, HTTP 400), which no longer accepts messages. */ +function isThreadArchived(cause: unknown): boolean { + return cause instanceof DiscordAPIError && cause.code === 50083; +} + export function createDisplayManager(options: DisplayManagerOptions): DisplayManager { const log = options.log.child("display"); let latestRows: CraftRow[] = []; @@ -78,7 +83,7 @@ export function createDisplayManager(options: DisplayManagerOptions): DisplayMan await recordMessage(conn, display.id, messageId, true); return; } catch (cause) { - if (isForbidden(cause)) { + if (isForbidden(cause) || isThreadArchived(cause)) { await markDeleted(conn, display); return; } @@ -105,7 +110,7 @@ export function createDisplayManager(options: DisplayManagerOptions): DisplayMan displayUpdatesTotal.inc({outcome: "posted"}); await recordMessage(conn, display.id, posted.id, false); } catch (cause) { - if (isForbidden(cause) || isNotFound(cause)) { + if (isForbidden(cause) || isNotFound(cause) || isThreadArchived(cause)) { await markDeleted(conn, display); return; } @@ -124,7 +129,7 @@ export function createDisplayManager(options: DisplayManagerOptions): DisplayMan }); } - /** The channel stopped accepting posts (403/404): tombstone the display (same reducer as `/crafts display-remove`). */ + /** The channel stopped accepting posts (403/404/archived thread): tombstone the display (same reducer as `/crafts display-remove`). */ async function markDeleted(conn: DbConnection, display: DiscordWatchDisplay): Promise { if (!conn.isActive) return; displayUpdatesTotal.inc({outcome: "detached"}); diff --git a/common/bitcraft-bindings/upstream b/common/bitcraft-bindings/upstream index 4f1e4500..6084a9f1 160000 --- a/common/bitcraft-bindings/upstream +++ b/common/bitcraft-bindings/upstream @@ -1 +1 @@ -Subproject commit 4f1e4500e16133c3cdfe832980598c388431d476 +Subproject commit 6084a9f140b20307f56d0ea22216cafbaa9e41a5 diff --git a/frontend/public/bsatn b/frontend/public/bsatn index 63da499c..9a4194f0 160000 --- a/frontend/public/bsatn +++ b/frontend/public/bsatn @@ -1 +1 @@ -Subproject commit 63da499c0ba39a116ddaca55c2abc471131ab7e9 +Subproject commit 9a4194f00319b6113014041fe547ddbdbe19eb02