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 { profile } from '$lib/auth.js'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient } from '$lib/lemmy.js'
|
||||||
import type {
|
import type {
|
||||||
|
AdminPurgeCommentView,
|
||||||
|
AdminPurgeCommunityView,
|
||||||
|
AdminPurgePersonView,
|
||||||
|
AdminPurgePostView,
|
||||||
Community,
|
Community,
|
||||||
ModAddCommunityView,
|
ModAddCommunityView,
|
||||||
|
ModAddView,
|
||||||
ModBanFromCommunityView,
|
ModBanFromCommunityView,
|
||||||
|
ModBanView,
|
||||||
ModFeaturePostView,
|
ModFeaturePostView,
|
||||||
|
ModHideCommunityView,
|
||||||
ModLockPostView,
|
ModLockPostView,
|
||||||
ModRemoveCommentView,
|
ModRemoveCommentView,
|
||||||
ModRemovePostView,
|
ModRemovePostView,
|
||||||
@@ -17,6 +24,9 @@ import { get } from 'svelte/store'
|
|||||||
|
|
||||||
export type ActionName =
|
export type ActionName =
|
||||||
| 'ban'
|
| 'ban'
|
||||||
|
| 'banCommunity'
|
||||||
|
| 'unban'
|
||||||
|
| 'unbanCommunity'
|
||||||
| 'postRemoval'
|
| 'postRemoval'
|
||||||
| 'commentRemoval'
|
| 'commentRemoval'
|
||||||
| 'postLock'
|
| 'postLock'
|
||||||
@@ -25,6 +35,7 @@ export type ActionName =
|
|||||||
| 'postFeature'
|
| 'postFeature'
|
||||||
| 'modAdd'
|
| 'modAdd'
|
||||||
| 'modRemove'
|
| 'modRemove'
|
||||||
|
| 'purge'
|
||||||
| 'Unknown'
|
| 'Unknown'
|
||||||
|
|
||||||
type ModAction =
|
type ModAction =
|
||||||
@@ -35,6 +46,13 @@ type ModAction =
|
|||||||
| ModLockPostView
|
| ModLockPostView
|
||||||
| ModFeaturePostView
|
| ModFeaturePostView
|
||||||
| ModTransferCommunityView
|
| ModTransferCommunityView
|
||||||
|
| AdminPurgeCommentView
|
||||||
|
| AdminPurgeCommunityView
|
||||||
|
| AdminPurgePostView
|
||||||
|
| AdminPurgePersonView
|
||||||
|
| ModHideCommunityView
|
||||||
|
| ModBanView
|
||||||
|
| ModAddView
|
||||||
|
|
||||||
export interface ModLog {
|
export interface ModLog {
|
||||||
reason?: string
|
reason?: string
|
||||||
@@ -57,7 +75,9 @@ export const _toModLog = (item: ModAction): ModLog => {
|
|||||||
moderator: item.moderator,
|
moderator: item.moderator,
|
||||||
moderatee: item.banned_person,
|
moderatee: item.banned_person,
|
||||||
community: item.community,
|
community: item.community,
|
||||||
actionName: 'ban',
|
actionName: item.mod_ban_from_community.banned
|
||||||
|
? 'banCommunity'
|
||||||
|
: 'unbanCommunity',
|
||||||
reason: item.mod_ban_from_community.reason,
|
reason: item.mod_ban_from_community.reason,
|
||||||
timestamp: timestamp(item.mod_ban_from_community.when_),
|
timestamp: timestamp(item.mod_ban_from_community.when_),
|
||||||
}
|
}
|
||||||
@@ -118,7 +138,57 @@ export const _toModLog = (item: ModAction): ModLog => {
|
|||||||
moderatee: item.modded_person,
|
moderatee: item.modded_person,
|
||||||
community: item.community,
|
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 {
|
return {
|
||||||
actionName: 'Unknown',
|
actionName: 'Unknown',
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
@@ -151,6 +221,15 @@ export async function load({ url }) {
|
|||||||
|
|
||||||
...results.featured_posts,
|
...results.featured_posts,
|
||||||
...results.locked_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
|
const moderationActions = moderation
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { IconSource } from 'svelte-hero-icons'
|
import type { IconSource } from 'svelte-hero-icons'
|
||||||
import {
|
import {
|
||||||
|
CheckCircle,
|
||||||
|
Fire,
|
||||||
Icon,
|
Icon,
|
||||||
InformationCircle,
|
InformationCircle,
|
||||||
LockClosed,
|
LockClosed,
|
||||||
@@ -25,7 +27,28 @@
|
|||||||
return {
|
return {
|
||||||
icon: XCircle,
|
icon: XCircle,
|
||||||
class: 'text-red-600 dark:text-red-400',
|
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': {
|
case 'commentRemoval': {
|
||||||
@@ -84,6 +107,13 @@
|
|||||||
text: 'Unlocked Post',
|
text: 'Unlocked Post',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 'purge': {
|
||||||
|
return {
|
||||||
|
icon: Fire,
|
||||||
|
class: 'text-red-600 dark:text-red-400',
|
||||||
|
text: 'Purge',
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -33,7 +33,9 @@
|
|||||||
class="flex items-center gap-1 text-green-600 dark:text-green-400 font-medium"
|
class="flex items-center gap-1 text-green-600 dark:text-green-400 font-medium"
|
||||||
>
|
>
|
||||||
<UserLink showInstance={true} avatar user={item.moderator} />
|
<UserLink showInstance={true} avatar user={item.moderator} />
|
||||||
<ShieldIcon filled width={16} />
|
{#if !item.moderator.admin}
|
||||||
|
<ShieldIcon filled width={16} />
|
||||||
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if item.moderatee}
|
{#if item.moderatee}
|
||||||
@@ -41,15 +43,19 @@
|
|||||||
<UserLink showInstance={true} avatar user={item.moderatee} />
|
<UserLink showInstance={true} avatar user={item.moderatee} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if item.link || item.content}
|
{#if item.link || item.content}
|
||||||
<SectionTitle class="mt-2">Submission</SectionTitle>
|
<SectionTitle class="mt-2">Item</SectionTitle>
|
||||||
{#if item.link && item.content}
|
{#if item.link && item.content}
|
||||||
<Link href={item.link} highlight>
|
<Link href={item.link} highlight>
|
||||||
{item.content}
|
{item.content}
|
||||||
</Link>
|
</Link>
|
||||||
{:else if item.content}
|
{:else if item.content}
|
||||||
<p class="text-xs">{item.content}</p>
|
<p>{item.content}</p>
|
||||||
{:else if item.link}
|
{:else if item.link}
|
||||||
<Link href={item.link} highlight />
|
<Link href={item.link} highlight />
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if item.reason}
|
||||||
|
<SectionTitle class="mt-2">Reason</SectionTitle>
|
||||||
|
<p>{item.reason}</p>
|
||||||
|
{/if}
|
||||||
</Card>
|
</Card>
|
||||||
Reference in new issue
Block a user