feat: add user banning

This commit is contained in:
Xyphyn committed 2023-07-31 17:02:54 -07:00
1 parent 47cc6bae67
commit d70548f6c7
8 files changed
+195 -5

No files matched your search

@@ -3,6 +3,8 @@ import type {
Community,
CommunityView,
MyUserInfo,
Person,
PersonView,
PostView,
} from 'lemmy-js-client'
import { writable } from 'svelte/store'
@@ -16,6 +18,12 @@ interface Modals {
open: boolean
item: PostView | CommentView | undefined
}
banning: {
open: boolean
banned: boolean
user: Person | undefined
community: Community | undefined
}
}
export let modals = writable<Modals>({
@@ -27,6 +35,12 @@ export let modals = writable<Modals>({
open: false,
item: undefined,
},
banning: {
open: false,
banned: false,
user: undefined,
community: undefined,
},
})
export function report(item: PostView | CommentView) {
@@ -49,6 +63,18 @@ export function remove(item: PostView | CommentView) {
}))
}
export function ban(banned: boolean, item: Person, community: Community) {
modals.update((m) => ({
...m,
banning: {
open: true,
user: item,
banned: banned,
community,
},
}))
}
export const amMod = (me: MyUserInfo, community: Community) =>
me.moderates.map((c) => c.community.id).includes(community.id) ||
(community.local && isAdmin(me))