fix(config): transact per-group configuration

Whole-table writes and cached snapshots can overwrite other groups
or resurrect removed configuration. Use per-group guarded writes,
one-time identity migration and explicit unreadable-row failures.
This commit is contained in:
翅膀 committed 2026-10-23 23:23:25 +08:00
1 parent ceb906d479
commit c853f2910f
7 files changed
+1764 -587

No files matched your search

+46
View File
@@ -51,6 +51,12 @@ export interface Config {
token: string;
};
routes: Route[];
/**
* Groups with a stored route that could not be read. Their events are
* reported as transient failures instead of passing for delivered while a
* route that might have matched was silently left out.
*/
unreadableGroups?: string[];
}
export interface RouteTarget {
@@ -138,6 +144,46 @@ export interface Group {
* `owners` list. Empty/omitted = no installation restriction.
*/
installationId?: number;
/**
* Isolated groups (self-service personal groups) only receive events from
* their own `/webhook/{groupId}` ingress; the global endpoint dispatches to
* them only once a super admin binds a source (`installationId` or
* `owners`). Only super admins may edit this field.
*/
isolated?: boolean;
/**
* Immutable identity of this group, assigned by the server when the group is
* created and kept across renames. A group re-created under a former id gets
* a new one, so invites and delivery ledgers of the old group never apply to
* it. Clients cannot set it.
*/
instance?: string;
/**
* Set when the group got its `instance` from the one-time backfill, i.e. it
* existed before instances: only such a group may adopt state stored under
* its id (a pre-instance webhook secret or invite). Server-owned.
*/
instanceBackfilled?: boolean;
/**
* For a backfilled group: the id it had when it got its instance. State
* stored under a group id before instances (a webhook secret, an invite, a
* queued delivery) belongs to the group with that `legacyId` only — not to
* whichever group holds the id now (another one may have been renamed to
* it). Server-owned, kept across renames.
*/
legacyId?: string;
/**
* The group's webhook secret (per-group ingress). Server-owned, stored with
* the group so it changes only through a compare-and-swap that re-checks the
* writer's role; never sent to clients. `null` in a mutation removes it.
*/
webhookSecret?: string | null;
/**
* Opaque revision of the stored group, set on read by the admin API and
* echoed back on update so a stale edit is rejected instead of overwriting a
* newer one. Never persisted.
*/
revision?: string;
/**
* Whether to include emoji in messages sent through this group's routes.
* Defaults to true when omitted.