Skip to content

Commit 07683a3

Browse files
authored
Merge pull request #1202 from Georgechisom/feat/backend-redis-webhooks-alerts-export
2 parents 8723543 + 8c396b6 commit 07683a3

11 files changed

Lines changed: 1629 additions & 275 deletions

File tree

backend/prisma/schema.prisma

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,50 @@ model StreamEvent {
8888
@@index([createdAt])
8989
@@index([streamId, timestamp])
9090
}
91+
92+
// WebhookSubscription model - Outgoing webhook configuration for external integrations (Issue #1189)
93+
model WebhookSubscription {
94+
id String @id @default(uuid())
95+
userAddress String // Stellar public key of the owner
96+
targetUrl String // Destination webhook URL (must be HTTPS)
97+
secretKey String // Secret used for HMAC-SHA256 signature
98+
eventTypes String[] // Array of subscribed event types (e.g., ["STREAM_CREATED", "TOKENS_WITHDRAWN"])
99+
isActive Boolean @default(true)
100+
createdAt DateTime @default(now())
101+
updatedAt DateTime @updatedAt
102+
103+
deliveries WebhookDelivery[]
104+
105+
@@index([userAddress])
106+
@@index([isActive])
107+
}
108+
109+
// WebhookDelivery model - Webhook delivery history and retry tracking (Issue #1189)
110+
model WebhookDelivery {
111+
id String @id @default(uuid())
112+
subscriptionId String
113+
eventType String
114+
payload String // JSON
115+
responseStatus Int?
116+
attempts Int @default(0)
117+
deliveredAt DateTime?
118+
error String?
119+
createdAt DateTime @default(now())
120+
121+
subscription WebhookSubscription @relation(fields: [subscriptionId], references: [id], onDelete: Cascade)
122+
123+
@@index([subscriptionId])
124+
@@index([createdAt])
125+
}
126+
127+
// AlertHistory model - Tracks sent alerts to prevent duplicate notifications (Issue #1190)
128+
model AlertHistory {
129+
id String @id @default(uuid())
130+
streamId BigInt
131+
alertType String // "WARNING_48H" or "CRITICAL_24H"
132+
sentAt DateTime @default(now())
133+
134+
@@unique([streamId, alertType, sentAt])
135+
@@index([streamId])
136+
@@index([sentAt])
137+
}

0 commit comments

Comments
 (0)