diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts index 2bf0b44a..c0152464 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts @@ -65,21 +65,21 @@ export async function publishComment(args: { } as unknown as Json, }) .select(); - let notifications = [ - { - comment: uri.toString(), - identity: new AtUri(args.document).host, - reason: "reply-on-post", - }, - ]; - if (args.comment.replyTo) - notifications.push({ - comment: uri.toString(), - identity: new AtUri(args.comment.replyTo).host, - reason: "reply-to-comment", - }); - // SOMEDAY: move this out the action with inngest or workflows - await supabaseServerClient.from("notif_comments").insert(notifications); + // let notifications = [ + // { + // comment: uri.toString(), + // identity: new AtUri(args.document).host, + // reason: "reply-on-post", + // }, + // ]; + // if (args.comment.replyTo) + // notifications.push({ + // comment: uri.toString(), + // identity: new AtUri(args.comment.replyTo).host, + // reason: "reply-to-comment", + // }); + // // SOMEDAY: move this out the action with inngest or workflows + // await supabaseServerClient.from("notif_comments").insert(notifications); return { record: data?.[0].record as Json, diff --git a/supabase/migrations/20251030201428_add_notifications_schema_and_comments_notification_table.sql b/supabase/migrations/20251030201428_add_notifications_schema_and_comments_notification_table.sql deleted file mode 100644 index cdb3da54..00000000 --- a/supabase/migrations/20251030201428_add_notifications_schema_and_comments_notification_table.sql +++ /dev/null @@ -1,24 +0,0 @@ -create schema if not exists "notifications"; - -create table "notifications"."comment_notifications" ( - "comment" text not null, - "created_at" timestamp with time zone not null default now(), - "identity" uuid not null, - "reason" text not null, - "read" boolean not null default false -); - - -alter table "notifications"."comment_notifications" enable row level security; - -CREATE UNIQUE INDEX comment_notifications_pkey ON notifications.comment_notifications USING btree (comment, identity); - -alter table "notifications"."comment_notifications" add constraint "comment_notifications_pkey" PRIMARY KEY using index "comment_notifications_pkey"; - -alter table "notifications"."comment_notifications" add constraint "comment_notifications_comment_fkey" FOREIGN KEY (comment) REFERENCES comments_on_documents(uri) ON UPDATE CASCADE ON DELETE CASCADE not valid; - -alter table "notifications"."comment_notifications" validate constraint "comment_notifications_comment_fkey"; - -alter table "notifications"."comment_notifications" add constraint "comment_notifications_identity_fkey" FOREIGN KEY (identity) REFERENCES identities(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; - -alter table "notifications"."comment_notifications" validate constraint "comment_notifications_identity_fkey"; diff --git a/supabase/migrations/20251030203149_add_grants_and_priveleges_to_notifications_schema.sql b/supabase/migrations/20251030203149_add_grants_and_priveleges_to_notifications_schema.sql deleted file mode 100644 index c9ea8bd5..00000000 --- a/supabase/migrations/20251030203149_add_grants_and_priveleges_to_notifications_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -GRANT USAGE ON SCHEMA notifications TO anon, authenticated, service_role; -GRANT ALL ON ALL TABLES IN SCHEMA notifications TO anon, authenticated, service_role; -GRANT ALL ON ALL ROUTINES IN SCHEMA notifications TO anon, authenticated, service_role; -GRANT ALL ON ALL SEQUENCES IN SCHEMA notifications TO anon, authenticated, service_role; -ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA notifications GRANT ALL ON TABLES TO anon, authenticated, service_role; -ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA notifications GRANT ALL ON ROUTINES TO anon, authenticated, service_role; -ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA notifications GRANT ALL ON SEQUENCES TO anon, authenticated, service_role; diff --git a/supabase/migrations/20251030205840_move_notif_table_to_public.sql b/supabase/migrations/20251030205840_move_notif_table_to_public.sql deleted file mode 100644 index dcba88b9..00000000 --- a/supabase/migrations/20251030205840_move_notif_table_to_public.sql +++ /dev/null @@ -1,67 +0,0 @@ -create table "public"."notif_comments" ( - "comment" text not null, - "created_at" timestamp with time zone not null default now(), - "identity" uuid not null, - "reason" text not null, - "read" boolean not null default false -); - - -alter table "public"."notif_comments" enable row level security; - -CREATE UNIQUE INDEX notif_comments_pkey ON public.notif_comments USING btree (comment, identity); - -alter table "public"."notif_comments" add constraint "notif_comments_pkey" PRIMARY KEY using index "notif_comments_pkey"; - -alter table "public"."notif_comments" add constraint "notif_comments_comment_fkey" FOREIGN KEY (comment) REFERENCES comments_on_documents(uri) ON UPDATE CASCADE ON DELETE CASCADE not valid; - -alter table "public"."notif_comments" validate constraint "notif_comments_comment_fkey"; - -alter table "public"."notif_comments" add constraint "notif_comments_identity_fkey" FOREIGN KEY (identity) REFERENCES identities(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; - -alter table "public"."notif_comments" validate constraint "notif_comments_identity_fkey"; - -grant delete on table "public"."notif_comments" to "anon"; - -grant insert on table "public"."notif_comments" to "anon"; - -grant references on table "public"."notif_comments" to "anon"; - -grant select on table "public"."notif_comments" to "anon"; - -grant trigger on table "public"."notif_comments" to "anon"; - -grant truncate on table "public"."notif_comments" to "anon"; - -grant update on table "public"."notif_comments" to "anon"; - -grant delete on table "public"."notif_comments" to "authenticated"; - -grant insert on table "public"."notif_comments" to "authenticated"; - -grant references on table "public"."notif_comments" to "authenticated"; - -grant select on table "public"."notif_comments" to "authenticated"; - -grant trigger on table "public"."notif_comments" to "authenticated"; - -grant truncate on table "public"."notif_comments" to "authenticated"; - -grant update on table "public"."notif_comments" to "authenticated"; - -grant delete on table "public"."notif_comments" to "service_role"; - -grant insert on table "public"."notif_comments" to "service_role"; - -grant references on table "public"."notif_comments" to "service_role"; - -grant select on table "public"."notif_comments" to "service_role"; - -grant trigger on table "public"."notif_comments" to "service_role"; - -grant truncate on table "public"."notif_comments" to "service_role"; - -grant update on table "public"."notif_comments" to "service_role"; - -drop table "notifications"."comment_notifications"; -drop schema if exists "notifications"; diff --git a/supabase/migrations/20251030211410_notif_relate_to_atp_did_not_id.sql b/supabase/migrations/20251030211410_notif_relate_to_atp_did_not_id.sql deleted file mode 100644 index 1a03db7e..00000000 --- a/supabase/migrations/20251030211410_notif_relate_to_atp_did_not_id.sql +++ /dev/null @@ -1,7 +0,0 @@ -alter table "public"."notif_comments" drop constraint "notif_comments_identity_fkey"; - -alter table "public"."notif_comments" alter column "identity" set data type text using "identity"::text; - -alter table "public"."notif_comments" add constraint "notif_comments_identity_fkey" FOREIGN KEY (identity) REFERENCES identities(atp_did) ON UPDATE CASCADE ON DELETE CASCADE not valid; - -alter table "public"."notif_comments" validate constraint "notif_comments_identity_fkey"; diff --git a/supabase/migrations/20251030215033_add_notifications_table.sql b/supabase/migrations/20251030215033_add_notifications_table.sql new file mode 100644 index 00000000..5369ad57 --- /dev/null +++ b/supabase/migrations/20251030215033_add_notifications_table.sql @@ -0,0 +1,59 @@ +create table "public"."notifications" ( + "recipient" text not null, + "created_at" timestamp with time zone not null default now(), + "read" boolean not null default false, + "data" jsonb not null +); + + +alter table "public"."notifications" enable row level security; + +CREATE UNIQUE INDEX notifications_pkey ON public.notifications USING btree (recipient); + +alter table "public"."notifications" add constraint "notifications_pkey" PRIMARY KEY using index "notifications_pkey"; + +alter table "public"."notifications" add constraint "notifications_recipient_fkey" FOREIGN KEY (recipient) REFERENCES identities(atp_did) ON UPDATE CASCADE ON DELETE CASCADE not valid; + +alter table "public"."notifications" validate constraint "notifications_recipient_fkey"; + +grant delete on table "public"."notifications" to "anon"; + +grant insert on table "public"."notifications" to "anon"; + +grant references on table "public"."notifications" to "anon"; + +grant select on table "public"."notifications" to "anon"; + +grant trigger on table "public"."notifications" to "anon"; + +grant truncate on table "public"."notifications" to "anon"; + +grant update on table "public"."notifications" to "anon"; + +grant delete on table "public"."notifications" to "authenticated"; + +grant insert on table "public"."notifications" to "authenticated"; + +grant references on table "public"."notifications" to "authenticated"; + +grant select on table "public"."notifications" to "authenticated"; + +grant trigger on table "public"."notifications" to "authenticated"; + +grant truncate on table "public"."notifications" to "authenticated"; + +grant update on table "public"."notifications" to "authenticated"; + +grant delete on table "public"."notifications" to "service_role"; + +grant insert on table "public"."notifications" to "service_role"; + +grant references on table "public"."notifications" to "service_role"; + +grant select on table "public"."notifications" to "service_role"; + +grant trigger on table "public"."notifications" to "service_role"; + +grant truncate on table "public"."notifications" to "service_role"; + +grant update on table "public"."notifications" to "service_role";