feat: add all admin actions
This commit is contained in:
1 parent
01032a0218
commit
57dbe5176a
3 files changed
+120
-5
No files matched your search
@@ -1,10 +1,17 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type {
|
||||
AdminPurgeCommentView,
|
||||
AdminPurgeCommunityView,
|
||||
AdminPurgePersonView,
|
||||
AdminPurgePostView,
|
||||
Community,
|
||||
ModAddCommunityView,
|
||||
ModAddView,
|
||||
ModBanFromCommunityView,
|
||||
ModBanView,
|
||||
ModFeaturePostView,
|
||||
ModHideCommunityView,
|
||||
ModLockPostView,
|
||||
ModRemoveCommentView,
|
||||
ModRemovePostView,
|
||||
@@ -17,6 +24,9 @@ import { get } from 'svelte/store'
|
||||
|
||||
export type ActionName =
|
||||
| 'ban'
|
||||
| 'banCommunity'
|
||||
| 'unban'
|
||||
| 'unbanCommunity'
|
||||
| 'postRemoval'
|
||||
| 'commentRemoval'
|
||||
| 'postLock'
|
||||
@@ -25,6 +35,7 @@ export type ActionName =
|
||||
| 'postFeature'
|
||||
| 'modAdd'
|
||||
| 'modRemove'
|
||||
| 'purge'
|
||||
| 'Unknown'
|
||||
|
||||
type ModAction =
|
||||
@@ -35,6 +46,13 @@ type ModAction =
|
||||
| ModLockPostView
|
||||
| ModFeaturePostView
|
||||
| ModTransferCommunityView
|
||||
| AdminPurgeCommentView
|
||||
| AdminPurgeCommunityView
|
||||
| AdminPurgePostView
|
||||
| AdminPurgePersonView
|
||||
| ModHideCommunityView
|
||||
| ModBanView
|
||||
| ModAddView
|
||||
|
||||
export interface ModLog {
|
||||
reason?: string
|
||||
@@ -57,7 +75,9 @@ export const _toModLog = (item: ModAction): ModLog => {
|
||||
moderator: item.moderator,
|
||||
moderatee: item.banned_person,
|
||||
community: item.community,
|
||||
actionName: 'ban',
|
||||
actionName: item.mod_ban_from_community.banned
|
||||
? 'banCommunity'
|
||||
: 'unbanCommunity',
|
||||
reason: item.mod_ban_from_community.reason,
|
||||
timestamp: timestamp(item.mod_ban_from_community.when_),
|
||||
}
|
||||
@@ -118,7 +138,57 @@ export const _toModLog = (item: ModAction): ModLog => {
|
||||
moderatee: item.modded_person,
|
||||
community: item.community,
|
||||
}
|
||||
} else if ('admin_purge_post' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_post.when_),
|
||||
moderator: item.admin,
|
||||
community: item.community,
|
||||
content: 'Purged a post',
|
||||
reason: item.admin_purge_post.reason,
|
||||
}
|
||||
} else if ('admin_purge_comment' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_comment.when_),
|
||||
moderator: item.admin,
|
||||
content: 'Purged a comment',
|
||||
reason: item.admin_purge_comment.reason,
|
||||
}
|
||||
} else if ('admin_purge_community' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_community.when_),
|
||||
moderator: item.admin,
|
||||
content: 'Purged a community',
|
||||
reason: item.admin_purge_community.reason,
|
||||
}
|
||||
} else if ('admin_purge_person' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_person.when_),
|
||||
moderator: item.admin,
|
||||
content: 'Purged a user',
|
||||
reason: item.admin_purge_person.reason,
|
||||
}
|
||||
} else if ('mod_ban' in item) {
|
||||
return {
|
||||
actionName: item.mod_ban.banned ? 'ban' : 'unban',
|
||||
timestamp: timestamp(item.mod_ban.when_),
|
||||
moderator: item.moderator,
|
||||
moderatee: item.banned_person,
|
||||
reason: item.mod_ban.reason,
|
||||
link: `/u/${fullUserName(item.banned_person)}`,
|
||||
}
|
||||
} else if ('mod_add' in item) {
|
||||
return {
|
||||
actionName: item.mod_add.removed ? 'modRemove' : 'modAdd',
|
||||
timestamp: timestamp(item.mod_add.when_),
|
||||
moderator: item.moderator,
|
||||
moderatee: item.modded_person,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
actionName: 'Unknown',
|
||||
timestamp: 0,
|
||||
@@ -151,6 +221,15 @@ export async function load({ url }) {
|
||||
|
||||
...results.featured_posts,
|
||||
...results.locked_posts,
|
||||
|
||||
...results.admin_purged_comments,
|
||||
...results.admin_purged_communities,
|
||||
...results.admin_purged_posts,
|
||||
...results.admin_purged_persons,
|
||||
|
||||
...results.hidden_communities,
|
||||
...results.banned,
|
||||
...results.added,
|
||||
]
|
||||
|
||||
const moderationActions = moderation
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import type { IconSource } from 'svelte-hero-icons'
|
||||
import {
|
||||
CheckCircle,
|
||||
Fire,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
LockClosed,
|
||||
@@ -25,7 +27,28 @@
|
||||
return {
|
||||
icon: XCircle,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Ban',
|
||||
text: 'Ban (instance)',
|
||||
}
|
||||
}
|
||||
case 'banCommunity': {
|
||||
return {
|
||||
icon: XCircle,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Ban (Community)',
|
||||
}
|
||||
}
|
||||
case 'unban': {
|
||||
return {
|
||||
icon: CheckCircle,
|
||||
class: 'text-green-600 dark:text-green-400',
|
||||
text: 'Unban (instance)',
|
||||
}
|
||||
}
|
||||
case 'unbanCommunity': {
|
||||
return {
|
||||
icon: CheckCircle,
|
||||
class: 'text-green-600 dark:text-green-400',
|
||||
text: 'Unban (Community)',
|
||||
}
|
||||
}
|
||||
case 'commentRemoval': {
|
||||
@@ -84,6 +107,13 @@
|
||||
text: 'Unlocked Post',
|
||||
}
|
||||
}
|
||||
case 'purge': {
|
||||
return {
|
||||
icon: Fire,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Purge',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -33,7 +33,9 @@
|
||||
class="flex items-center gap-1 text-green-600 dark:text-green-400 font-medium"
|
||||
>
|
||||
<UserLink showInstance={true} avatar user={item.moderator} />
|
||||
<ShieldIcon filled width={16} />
|
||||
{#if !item.moderator.admin}
|
||||
<ShieldIcon filled width={16} />
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
{#if item.moderatee}
|
||||
@@ -41,15 +43,19 @@
|
||||
<UserLink showInstance={true} avatar user={item.moderatee} />
|
||||
{/if}
|
||||
{#if item.link || item.content}
|
||||
<SectionTitle class="mt-2">Submission</SectionTitle>
|
||||
<SectionTitle class="mt-2">Item</SectionTitle>
|
||||
{#if item.link && item.content}
|
||||
<Link href={item.link} highlight>
|
||||
{item.content}
|
||||
</Link>
|
||||
{:else if item.content}
|
||||
<p class="text-xs">{item.content}</p>
|
||||
<p>{item.content}</p>
|
||||
{:else if item.link}
|
||||
<Link href={item.link} highlight />
|
||||
{/if}
|
||||
{/if}
|
||||
{#if item.reason}
|
||||
<SectionTitle class="mt-2">Reason</SectionTitle>
|
||||
<p>{item.reason}</p>
|
||||
{/if}
|
||||
</Card>
|
||||
Reference in new issue
Block a user