kitgit

tirbofish/kitgit · commit

a64ae95c13394f4a54d2fe5295d59a1063a43fa6

merge: feat/notifications into integrate/all-features

Verified

Thribhu K <4tkbytes@pm.me> · 2026-07-29 00:06

view full diff

diff --git a/migrations/016_notifications.sql b/migrations/016_notifications.sql
new file mode 100644
index 0000000..0439544
--- /dev/null
+++ b/migrations/016_notifications.sql
@@ -0,0 +1,20 @@
+-- In-app notifications for watched repos and thread participants
+
+CREATE TABLE IF NOT EXISTS notifications (
+    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+    user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+    kind TEXT NOT NULL,
+    title TEXT NOT NULL,
+    body TEXT NOT NULL DEFAULT '',
+    href TEXT NOT NULL DEFAULT '',
+    repo_id UUID REFERENCES repositories(id) ON DELETE SET NULL,
+    read_at TIMESTAMPTZ,
+    created_at TIMESTAMPTZ NOT NULL DEFAULT now()
+);
+
+CREATE INDEX IF NOT EXISTS notifications_user_id_created_at_idx
+    ON notifications (user_id, created_at DESC);
+
+CREATE INDEX IF NOT EXISTS notifications_user_id_unread_idx
+    ON notifications (user_id)
+    WHERE read_at IS NULL;
diff --git a/src/db/models.rs b/src/db/models.rs
index 762208b..d119230 100644
--- a/src/db/models.rs
+++ b/src/db/models.rs
@@ -295,6 +295,19 @@ pub struct WebhookDelivery {
     pub created_at: DateTime<Utc>,
 }
 
+#[derive(Debug, Clone, FromRow, Serialize)]
+pub struct Notification {
+    pub id: Uuid,
+    pub user_id: Uuid,
+    pub kind: String,
+    pub title: String,
+    pub body: String,
+    pub href: String,
+    pub repo_id: Option<Uuid>,
+    pub read_at: Option<DateTime<Utc>>,
+    pub created_at: DateTime<Utc>,
+}
+
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
 #[serde(rename_all = "lowercase")]
 pub enum Access {

Large diffs are not rendered by default. Showing the first 50 of 635 lines. Show full diff