-
Notifications
You must be signed in to change notification settings - Fork 78
feat(backend): add webhook delivery system for card view events #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ model User { | |
| ownedViews CardView[] @relation("cardOwner") | ||
| viewedCards CardView[] @relation("cardViewer") | ||
| followLogs FollowLog[] | ||
| webhookEndpoints WebhookEndpoint[] | ||
|
|
||
| @@unique([provider, providerId]) | ||
| @@map("users") | ||
|
|
@@ -124,3 +125,34 @@ model FollowLog { | |
|
|
||
| @@map("follow_logs") | ||
| } | ||
|
|
||
| model WebhookEndpoint { | ||
| id String @id @default(uuid()) | ||
| userId String @map("user_id") | ||
| url String | ||
| secret String // encrypted via encryption.ts | ||
| events String[] // e.g. ["card.viewed", "contact.saved"] | ||
| isActive Boolean @default(true) @map("is_active") | ||
| createdAt DateTime @default(now()) @map("created_at") | ||
|
|
||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
| deliveries WebhookDelivery[] | ||
|
|
||
| @@map("webhook_endpoints") | ||
| } | ||
|
|
||
| model WebhookDelivery { | ||
| id String @id @default(uuid()) | ||
| endpointId String @map("endpoint_id") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No indexing on |
||
| eventType String @map("event_type") | ||
| payload Json | ||
| status String @default("pending") // "pending" | "success" | "failed" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
| responseCode Int? @map("response_code") | ||
| attempts Int @default(0) | ||
| nextRetryAt DateTime? @map("next_retry_at") | ||
| createdAt DateTime @default(now()) @map("created_at") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No indexing for |
||
| endpoint WebhookEndpoint @relation(fields: [endpointId], references: [id], onDelete: Cascade) | ||
|
|
||
| @@map("webhook_deliveries") | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
updatedAtneeded for secret rotation auditing