37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
/**
|
|
* Pure rules for support message edit/delete windows.
|
|
* Window duration comes from system settings; callers enforce ownership separately.
|
|
*/
|
|
export type SupportMessageAction = 'edit' | 'delete';
|
|
export type SupportMessageActionWindows = {
|
|
editWindowMinutes: number;
|
|
deleteWindowMinutes: number;
|
|
};
|
|
export type SupportMessageActionFlags = {
|
|
canEdit: boolean;
|
|
canDelete: boolean;
|
|
editAvailableUntil: string | null;
|
|
deleteAvailableUntil: string | null;
|
|
};
|
|
export declare function clampSupportWindowMinutes(value: number): number;
|
|
export declare function computeActionWindow(createdAt: Date, windowMinutes: number, now?: Date): {
|
|
allowed: boolean;
|
|
availableUntil: Date | null;
|
|
};
|
|
export declare function resolveSupportMessageActions(input: {
|
|
createdAt: Date;
|
|
deleted: boolean;
|
|
isOwner: boolean;
|
|
editWindowMinutes: number;
|
|
deleteWindowMinutes: number;
|
|
now?: Date;
|
|
}): SupportMessageActionFlags;
|
|
export declare function assertSupportMessageAction(action: SupportMessageAction, input: Parameters<typeof resolveSupportMessageActions>[0]): SupportMessageActionFlags;
|
|
export declare function isSupportMessageOwner(input: {
|
|
senderType: 'user' | 'visitor' | 'staff';
|
|
senderUserId: string | null;
|
|
conversationVisitorToken: string | null;
|
|
actorUserId?: string;
|
|
actorVisitorToken?: string | null;
|
|
}): boolean;
|
|
//# sourceMappingURL=supportMessagePolicy.d.ts.map
|