feat: add moderation tools (#33)
* feat: Add post submission removal * feat: add comment submission removal * feat: add report viewing and resolving * misc: add notification dot * misc: add locked thread badge * feat: add thread locking * feat: add initiating message conversations * feat: add post pinning/unpinning * misc: bump version * fix: tweak lock colors * fix: update post data on pin * fix: return if reason is empty
This commit is contained in:
1 parent
53ef843cde
commit
d3aae647a8
29 files changed
+835
-67
No files matched your search
+35
-12
@@ -1,26 +1,39 @@
|
||||
import type {
|
||||
CommentReportView,
|
||||
CommentView,
|
||||
CommunityView,
|
||||
PersonView,
|
||||
PostReportView,
|
||||
PostView,
|
||||
PrivateMessage,
|
||||
PrivateMessageReportView,
|
||||
PrivateMessageView,
|
||||
} from 'lemmy-js-client'
|
||||
|
||||
type Result = PostView | CommentView | PersonView | CommunityView
|
||||
type Result =
|
||||
| PostView
|
||||
| CommentView
|
||||
| PersonView
|
||||
| CommunityView
|
||||
| PrivateMessageView
|
||||
| PostReportView
|
||||
| CommentReportView
|
||||
| PrivateMessageReportView
|
||||
|
||||
export function getItemPublished(item: Result) {
|
||||
if ('comment' in item) {
|
||||
return item.comment.published
|
||||
} else if ('post' in item) {
|
||||
return item.post.published
|
||||
}
|
||||
// reports... why
|
||||
if ('post_report' in item) return item.post_report.published
|
||||
if ('comment_report' in item) return item.comment_report.published
|
||||
if ('private_message_report' in item)
|
||||
return item.private_message_report.published
|
||||
|
||||
if ('person' in item) {
|
||||
return item.person.published
|
||||
}
|
||||
// others
|
||||
if ('private_message' in item) return item.private_message.published
|
||||
if ('comment' in item) return item.comment.published
|
||||
else if ('post' in item) return item.post.published
|
||||
|
||||
if ('community' in item) {
|
||||
return item.community.published
|
||||
}
|
||||
if ('person' in item) return item.person.published
|
||||
if ('community' in item) return item.community.published
|
||||
|
||||
return ''
|
||||
}
|
||||
@@ -35,3 +48,13 @@ export const isCommunity = (item: Result): item is CommunityView =>
|
||||
'community' in item
|
||||
|
||||
export const isUser = (item: Result): item is PersonView => 'person' in item
|
||||
|
||||
export const isPostReport = (item: Result): item is PostReportView =>
|
||||
'post_report' in item
|
||||
|
||||
export const isCommentReport = (item: Result): item is CommentReportView =>
|
||||
'comment_report' in item
|
||||
|
||||
export const isPrivateMessageReport = (
|
||||
item: Result
|
||||
): item is PrivateMessageReportView => 'private_message_report' in item
|
||||
@@ -1,6 +0,0 @@
|
||||
import type { MyUserInfo } from 'lemmy-js-client'
|
||||
|
||||
export const isMod = (me: MyUserInfo, community: number) =>
|
||||
me.moderates.map((c) => c.community.id).includes(community)
|
||||
|
||||
export const isAdmin = (me: MyUserInfo) => me.local_user_view.person.admin
|
||||
Reference in new issue
Block a user