refactor(shared): rename TriggerReason → PeeringTriggerReason, pin subscribers semantics

- Symmetric with PeeringNotificationKind at module scope; avoids
  future collision with unrelated trigger systems.
- subscribers field doc now explicit: undefined for inbound, present
  (possibly []) for outbound. Pins the response contract before Task 7
  implements the GET endpoint response shape.
This commit is contained in:
Jannis Braun
2026-04-26 21:14:51 +02:00
parent 55af76f8b4
commit 94c291c472
+11 -5
View File
@@ -1037,7 +1037,7 @@ export interface FederationPeer {
* the human-readable cause and the user can recover their original action * the human-readable cause and the user can recover their original action
* after approval. Persisted as a string column with this exact set of values. * after approval. Persisted as a string column with this exact set of values.
*/ */
export type TriggerReason = 'friend_add' | 'space_join' | 'direct_message'; export type PeeringTriggerReason = 'friend_add' | 'space_join' | 'direct_message';
/** /**
* Caller intent passed into `ensurePeered()`. The gate (when * Caller intent passed into `ensurePeered()`. The gate (when
@@ -1053,7 +1053,7 @@ export type TriggerReason = 'friend_add' | 'space_join' | 'direct_message';
* for space_join, the federated DM channel id for direct_message). * for space_join, the federated DM channel id for direct_message).
*/ */
export type EnsurePeeredCallerIntent = export type EnsurePeeredCallerIntent =
| { kind: 'user_action'; userId: string; reason: TriggerReason; target: string } | { kind: 'user_action'; userId: string; reason: PeeringTriggerReason; target: string }
| { kind: 'system' }; | { kind: 'system' };
/** /**
@@ -1074,7 +1074,7 @@ export interface PeeringSubscription {
requestId: string; requestId: string;
peerOrigin: string; peerOrigin: string;
peerInstanceName: string | null; peerInstanceName: string | null;
triggerReason: TriggerReason; triggerReason: PeeringTriggerReason;
triggerTarget: string; triggerTarget: string;
createdAt: number; createdAt: number;
} }
@@ -1089,7 +1089,7 @@ export interface PeeringNotification {
id: string; id: string;
kind: PeeringNotificationKind; kind: PeeringNotificationKind;
peerOrigin: string; peerOrigin: string;
triggerReason: TriggerReason; triggerReason: PeeringTriggerReason;
triggerTarget: string; triggerTarget: string;
createdAt: number; createdAt: number;
readAt: number | null; readAt: number | null;
@@ -1103,7 +1103,7 @@ export interface PeeringNotification {
export interface ApprovalRequestSubscriberSummary { export interface ApprovalRequestSubscriberSummary {
userId: string; userId: string;
username: string; username: string;
triggerReason: TriggerReason; triggerReason: PeeringTriggerReason;
triggerTarget: string; triggerTarget: string;
} }
@@ -1121,5 +1121,11 @@ export interface ApprovalRequest {
instanceName: string | null; instanceName: string | null;
requestedAt: number; requestedAt: number;
expiresAt: number; expiresAt: number;
/**
* Subscriber summaries — present (and possibly empty array) only when
* `direction === 'outbound'`. ABSENT (`undefined`) when `direction === 'inbound'`.
* Inbound rows have no per-action context; the field is omitted from the server
* response, not set to `[]`.
*/
subscribers?: ApprovalRequestSubscriberSummary[]; subscribers?: ApprovalRequestSubscriberSummary[];
} }