Skip to content

Commit

Permalink
Unfollow group when blocking it
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Jul 10, 2024
1 parent 5724327 commit 306607b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend/api/src/block-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ export const blockGroup: APIHandler<'group/:slug/block'> = async (
auth
) => {
const pg = createSupabaseDirectClient()
const group = await pg.oneOrNone(
`select id from groups where slug = $1`,
slug
)
if (group.id) {
await pg.none(
`delete
from group_members
where member_id = $1
and group_id = $2`,
[auth.uid, group.id]
)
}
await updatePrivateUser(pg, auth.uid, {
blockedGroupSlugs: FieldVal.arrayConcat(slug),
})
Expand Down

0 comments on commit 306607b

Please sign in to comment.