kitgit

tirbofish/kitgit · commit

a0369aaad4cae6ed4c7b72e61de6bbaa2c929b1c

feat: add in-app notifications for watched repos

Verified

Thribhu K <4tkbytes@pm.me> · 2026-07-28 15:12

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 874e00c..86e4faa 100644
--- a/src/db/models.rs
+++ b/src/db/models.rs
@@ -234,6 +234,19 @@ pub struct CommitDay {
     pub count: i32,
 }
 
+#[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 653 lines. Show full diff