mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 21:04:03 +00:00
feat(bot): add anonymous feedback flow
This commit is contained in:
51
packages/ports/src/anonymous-feedback.ts
Normal file
51
packages/ports/src/anonymous-feedback.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
export type AnonymousFeedbackModerationStatus = 'accepted' | 'posted' | 'rejected' | 'failed'
|
||||
|
||||
export type AnonymousFeedbackRejectionReason =
|
||||
| 'not_member'
|
||||
| 'too_short'
|
||||
| 'too_long'
|
||||
| 'cooldown'
|
||||
| 'daily_cap'
|
||||
| 'blocklisted'
|
||||
|
||||
export interface AnonymousFeedbackMemberRecord {
|
||||
id: string
|
||||
telegramUserId: string
|
||||
displayName: string
|
||||
}
|
||||
|
||||
export interface AnonymousFeedbackRateLimitSnapshot {
|
||||
acceptedCountSince: number
|
||||
lastAcceptedAt: Date | null
|
||||
}
|
||||
|
||||
export interface AnonymousFeedbackSubmissionRecord {
|
||||
id: string
|
||||
moderationStatus: AnonymousFeedbackModerationStatus
|
||||
}
|
||||
|
||||
export interface AnonymousFeedbackRepository {
|
||||
getMemberByTelegramUserId(telegramUserId: string): Promise<AnonymousFeedbackMemberRecord | null>
|
||||
getRateLimitSnapshot(
|
||||
memberId: string,
|
||||
acceptedSince: Date
|
||||
): Promise<AnonymousFeedbackRateLimitSnapshot>
|
||||
createSubmission(input: {
|
||||
submittedByMemberId: string
|
||||
rawText: string
|
||||
sanitizedText: string | null
|
||||
moderationStatus: AnonymousFeedbackModerationStatus
|
||||
moderationReason: string | null
|
||||
telegramChatId: string
|
||||
telegramMessageId: string
|
||||
telegramUpdateId: string
|
||||
}): Promise<{ submission: AnonymousFeedbackSubmissionRecord; duplicate: boolean }>
|
||||
markPosted(input: {
|
||||
submissionId: string
|
||||
postedChatId: string
|
||||
postedThreadId: string
|
||||
postedMessageId: string
|
||||
postedAt: Date
|
||||
}): Promise<void>
|
||||
markFailed(submissionId: string, failureReason: string): Promise<void>
|
||||
}
|
||||
@@ -5,6 +5,14 @@ export {
|
||||
type ReminderDispatchRepository,
|
||||
type ReminderType
|
||||
} from './reminders'
|
||||
export type {
|
||||
AnonymousFeedbackMemberRecord,
|
||||
AnonymousFeedbackModerationStatus,
|
||||
AnonymousFeedbackRateLimitSnapshot,
|
||||
AnonymousFeedbackRejectionReason,
|
||||
AnonymousFeedbackRepository,
|
||||
AnonymousFeedbackSubmissionRecord
|
||||
} from './anonymous-feedback'
|
||||
export type {
|
||||
FinanceCycleRecord,
|
||||
FinanceMemberRecord,
|
||||
|
||||
Reference in New Issue
Block a user