Skip to content

Commit

Permalink
Mod Mail Reports (#1519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjmarf authored Dec 22, 2024
1 parent b6b60e2 commit cafa13f
Show file tree
Hide file tree
Showing 26 changed files with 755 additions and 176 deletions.
22 changes: 21 additions & 1 deletion Mlem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
0300309D2C4163C9009A65FF /* CommentTreeTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0300309C2C4163C9009A65FF /* CommentTreeTracker.swift */; };
030030A12C416B0B009A65FF /* RefreshPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030030A02C416B0B009A65FF /* RefreshPopupView.swift */; };
030050D32D109B7E002B1E99 /* ReportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030050D22D109B7E002B1E99 /* ReportView.swift */; };
030050D52D10AE30002B1E99 /* Report+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030050D42D10AE30002B1E99 /* Report+Extensions.swift */; };
03036C742C71408700C6DA1D /* CounterAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03036C732C71408700C6DA1D /* CounterAppearance.swift */; };
03036C762C71427B00C6DA1D /* InteractionBarCounterLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03036C752C71427B00C6DA1D /* InteractionBarCounterLabelView.swift */; };
03036C832C727D0500C6DA1D /* InteractionBarEditorView+Logic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03036C822C727D0500C6DA1D /* InteractionBarEditorView+Logic.swift */; };
Expand Down Expand Up @@ -82,6 +84,7 @@
033FCB2A2C5E3933007B7CD1 /* AlternateIconCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033FCB232C5E3933007B7CD1 /* AlternateIconCell.swift */; };
033FCB3E2C5E7FA9007B7CD1 /* View+OutdatedFeedPopup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033FCB3D2C5E7FA9007B7CD1 /* View+OutdatedFeedPopup.swift */; };
034690932D0F4D720073E664 /* RemovableProviding+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 034690922D0F4D720073E664 /* RemovableProviding+Extensions.swift */; };
034690992D105DFD0073E664 /* InboxView+Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 034690982D105DFD0073E664 /* InboxView+Types.swift */; };
034B947F2C091EDD00039AF4 /* ProfileHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 034B947E2C091EDD00039AF4 /* ProfileHeaderView.swift */; };
034B94812C09306D00039AF4 /* CommunityOrPersonStub+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 034B94802C09306D00039AF4 /* CommunityOrPersonStub+Extensions.swift */; };
034B94832C09340A00039AF4 /* MarkdownConfiguration+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 034B94822C09340A00039AF4 /* MarkdownConfiguration+Extensions.swift */; };
Expand Down Expand Up @@ -258,6 +261,8 @@
03DAEA772C64074E0064DE64 /* SubscriptionListItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03DAEA762C64074E0064DE64 /* SubscriptionListItemView.swift */; };
03E0EF432CA73D7A002CB66C /* PostPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0EF422CA73D7A002CB66C /* PostPage.swift */; };
03E0EF452CA74036002CB66C /* CommentPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0EF442CA74036002CB66C /* CommentPage.swift */; };
03E46ACB2D1216CE002589DB /* PostViewLinkType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E46ACA2D1216CE002589DB /* PostViewLinkType.swift */; };
03E46ACD2D121C19002589DB /* HeadlinePostBodyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E46ACC2D121C19002589DB /* HeadlinePostBodyView.swift */; };
03E46AD22D130681002589DB /* VotesListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E46AD12D130681002589DB /* VotesListView.swift */; };
03E46AD42D130728002589DB /* ScoringOperation+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E46AD32D130728002589DB /* ScoringOperation+Extensions.swift */; };
03E614E42C0BCC7B00F692A4 /* Post1Providing+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E614E32C0BCC7B00F692A4 /* Post1Providing+Extensions.swift */; };
Expand Down Expand Up @@ -443,6 +448,8 @@
/* Begin PBXFileReference section */
0300309C2C4163C9009A65FF /* CommentTreeTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentTreeTracker.swift; sourceTree = "<group>"; };
030030A02C416B0B009A65FF /* RefreshPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshPopupView.swift; sourceTree = "<group>"; };
030050D22D109B7E002B1E99 /* ReportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportView.swift; sourceTree = "<group>"; };
030050D42D10AE30002B1E99 /* Report+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Report+Extensions.swift"; sourceTree = "<group>"; };
03036C732C71408700C6DA1D /* CounterAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CounterAppearance.swift; sourceTree = "<group>"; };
03036C752C71427B00C6DA1D /* InteractionBarCounterLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InteractionBarCounterLabelView.swift; sourceTree = "<group>"; };
03036C822C727D0500C6DA1D /* InteractionBarEditorView+Logic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InteractionBarEditorView+Logic.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -514,6 +521,7 @@
033FCB252C5E3933007B7CD1 /* IconSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconSettingsView.swift; sourceTree = "<group>"; };
033FCB3D2C5E7FA9007B7CD1 /* View+OutdatedFeedPopup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+OutdatedFeedPopup.swift"; sourceTree = "<group>"; };
034690922D0F4D720073E664 /* RemovableProviding+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RemovableProviding+Extensions.swift"; sourceTree = "<group>"; };
034690982D105DFD0073E664 /* InboxView+Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InboxView+Types.swift"; sourceTree = "<group>"; };
034B947E2C091EDD00039AF4 /* ProfileHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileHeaderView.swift; sourceTree = "<group>"; };
034B94802C09306D00039AF4 /* CommunityOrPersonStub+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CommunityOrPersonStub+Extensions.swift"; sourceTree = "<group>"; };
034B94822C09340A00039AF4 /* MarkdownConfiguration+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MarkdownConfiguration+Extensions.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -690,6 +698,8 @@
03DAEA762C64074E0064DE64 /* SubscriptionListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionListItemView.swift; sourceTree = "<group>"; };
03E0EF422CA73D7A002CB66C /* PostPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostPage.swift; sourceTree = "<group>"; };
03E0EF442CA74036002CB66C /* CommentPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentPage.swift; sourceTree = "<group>"; };
03E46ACA2D1216CE002589DB /* PostViewLinkType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostViewLinkType.swift; sourceTree = "<group>"; };
03E46ACC2D121C19002589DB /* HeadlinePostBodyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlinePostBodyView.swift; sourceTree = "<group>"; };
03E46AD12D130681002589DB /* VotesListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VotesListView.swift; sourceTree = "<group>"; };
03E46AD32D130728002589DB /* ScoringOperation+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ScoringOperation+Extensions.swift"; sourceTree = "<group>"; };
03E614E32C0BCC7B00F692A4 /* Post1Providing+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Post1Providing+Extensions.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1103,6 +1113,7 @@
isa = PBXGroup;
children = (
0369B3552BFA6824001EFEDF /* InboxView.swift */,
034690982D105DFD0073E664 /* InboxView+Types.swift */,
0353948A2CA076D000795AA5 /* InboxView+Views.swift */,
);
path = Inbox;
Expand Down Expand Up @@ -1563,6 +1574,7 @@
0382A7F12C0A758E00C79DDA /* ProfileDateView.swift */,
030030A02C416B0B009A65FF /* RefreshPopupView.swift */,
032C32152C36F65500595286 /* ReplyView.swift */,
030050D22D109B7E002B1E99 /* ReportView.swift */,
03531EEF2C2DA291004A3464 /* Search */,
032C32092C34495D00595286 /* SelectTextView.swift */,
03500C252BF694A800CAA076 /* Toast */,
Expand Down Expand Up @@ -1634,6 +1646,7 @@
CDA683F72C77E577000C4486 /* NsfwBlurBehavior.swift */,
039F58832C7A7F2C00C61658 /* CommentJumpButtonLocation.swift */,
0320B6622C8F8D5A00D38548 /* InstanceSort.swift */,
03E46ACA2D1216CE002589DB /* PostViewLinkType.swift */,
);
path = Enums;
sourceTree = "<group>";
Expand Down Expand Up @@ -1801,6 +1814,7 @@
CD8DCAF82C5E92E8003E4DD7 /* Profile1Providing+Extensions.swift */,
036ED6822D0C483B0018E5EA /* Profile2Providing+Extensions.swift */,
0320B6532C8B65EB00D38548 /* Captcha+Extensions.swift */,
030050D42D10AE30002B1E99 /* Report+Extensions.swift */,
03E46AD32D130728002589DB /* ScoringOperation+Extensions.swift */,
);
path = "Content Models";
Expand Down Expand Up @@ -1895,6 +1909,7 @@
CDE021AC2BFA43380052FD61 /* FeedPostView.swift */,
CDB2EC7C2BFADAB300DBC0EF /* CompactPostView.swift */,
CDB2EC7E2BFADACC00DBC0EF /* HeadlinePostView.swift */,
03E46ACC2D121C19002589DB /* HeadlinePostBodyView.swift */,
CDB2EC802BFADADF00DBC0EF /* LargePostView.swift */,
03B431BB2C455838001A1EB5 /* LargePostBodyView.swift */,
CDBFCB6B2C054AA7008CD468 /* TilePostView.swift */,
Expand Down Expand Up @@ -2237,6 +2252,7 @@
035EDEF12C2DE94B00F51144 /* DefaultTextInputType.swift in Sources */,
039F588C2C7B574E00C61658 /* AdvancedSettingsView.swift in Sources */,
0320B6672C93504600D38548 /* SignUpView+Logic.swift in Sources */,
03E46ACD2D121C19002589DB /* HeadlinePostBodyView.swift in Sources */,
039F58882C7B531800C61658 /* SquircleLabelStyle.swift in Sources */,
035EDEF22C2DE94B00F51144 /* _assignIfNotEqual.swift in Sources */,
035EDEF32C2DE94B00F51144 /* SearchBar.swift in Sources */,
Expand All @@ -2255,6 +2271,7 @@
03E46AD42D130728002589DB /* ScoringOperation+Extensions.swift in Sources */,
03CCDAA02BF2795300C0C851 /* LoginPage.swift in Sources */,
032C32082C34469900595286 /* SelectableContentProviding+Extensions.swift in Sources */,
03E46ACB2D1216CE002589DB /* PostViewLinkType.swift in Sources */,
037658DF2BE7D9EF00F4DD4D /* Community1Providing+Extensions.swift in Sources */,
032C32182C36F70300595286 /* ReplyBarConfiguration.swift in Sources */,
CDD4A0A02C8B985D0001AD1A /* ImportExportSettingsPage.swift in Sources */,
Expand Down Expand Up @@ -2379,6 +2396,8 @@
CD8DCAF92C5E92E8003E4DD7 /* Profile1Providing+Extensions.swift in Sources */,
CDB2EC8A2BFAEFDF00DBC0EF /* ThumbnailImageView.swift in Sources */,
0397D4932C6CE87E002C6CDC /* PostEditorTargetView.swift in Sources */,
034690992D105DFD0073E664 /* InboxView+Types.swift in Sources */,
030050D52D10AE30002B1E99 /* Report+Extensions.swift in Sources */,
CD57AFA32D03761500AB3956 /* WebpView.swift in Sources */,
0369B3562BFA6824001EFEDF /* InboxView.swift in Sources */,
CD4D59162B87B38C00B82964 /* UIApplication+Extensions.swift in Sources */,
Expand Down Expand Up @@ -2473,6 +2492,7 @@
036ED6792D0AF3740018E5EA /* PinnedSortTracker.swift in Sources */,
0353948D2CA080EB00795AA5 /* FeedWelcomeView.swift in Sources */,
03049A202C650A8100FF6889 /* FormReadout.swift in Sources */,
030050D32D109B7E002B1E99 /* ReportView.swift in Sources */,
0397D49A2C6EA6EE002C6CDC /* InteractionBarEditorView.swift in Sources */,
0300309D2C4163C9009A65FF /* CommentTreeTracker.swift in Sources */,
032C321A2C36F75800595286 /* Reply1Providing+Extensions.swift in Sources */,
Expand Down Expand Up @@ -2979,7 +2999,7 @@
repositoryURL = "https://github.com/mlemgroup/MlemMiddleware";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.54.0;
minimumVersion = 0.55.0;
};
};
CDE4AC402CA3706400981010 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mlemgroup/MlemMiddleware",
"state" : {
"revision" : "68b8e0a50744164f64486397da4d5f114d040117",
"version" : "0.54.0"
"revision" : "dede345d6a2063d08fd94922cfafffb8e63359f0",
"version" : "0.55.0"
}
},
{
Expand Down
12 changes: 12 additions & 0 deletions Mlem/App/Enums/PostViewLinkType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// PostViewLinkType.swift
// Mlem
//
// Created by Sjmarf on 2024-12-17.
//

import Foundation

enum PostViewNavigationLink {
case creator, community
}
2 changes: 1 addition & 1 deletion Mlem/App/Models/Session/UserSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UserSession: Session {
}
)

Task {
Task { @MainActor in
do {
try await self.api.fetchSiteVersion(task: Task {
let (person, instance, blocks) = try await self.api.getMyPerson()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ extension Comment1Providing {
func allMenuActions(
expanded: Bool = false,
feedback: Set<FeedbackType> = [.haptic, .toast],
commentTreeTracker: CommentTreeTracker? = nil
commentTreeTracker: CommentTreeTracker? = nil,
report: Report? = nil
) -> [any Action] {
basicMenuActions(feedback: feedback, commentTreeTracker: commentTreeTracker)
if canModerate {
ActionGroup(
appearance: .init(label: "Moderation...", color: Palette.main.moderation, icon: Icons.moderation),
displayMode: Settings.main.moderatorActionGrouping == .divider || expanded ? .section : .disclosure
) {
moderatorMenuActions(feedback: feedback)
moderatorMenuActions(feedback: feedback, report: report)
}
}
}
Expand Down Expand Up @@ -96,7 +97,10 @@ extension Comment1Providing {
}

@ActionBuilder
func moderatorMenuActions(feedback: Set<FeedbackType> = [.haptic, .toast]) -> [any Action] {
func moderatorMenuActions(
feedback: Set<FeedbackType> = [.haptic, .toast],
report: Report? = nil
) -> [any Action] {
if api.isAdmin || (api.fetchedVersion ?? .infinity) > .v19_4 {
viewVotesAction()
}
Expand All @@ -110,6 +114,11 @@ extension Comment1Providing {
purgeCreatorAction()
}
}
if let report {
ActionGroup {
report.menuActions()
}
}
}

func shouldShowLoadingSymbol(for barConfiguration: CommentBarConfiguration? = nil) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,26 @@ extension Message1Providing {
}

@ActionBuilder
func menuActions(feedback: Set<FeedbackType> = [.haptic, .toast]) -> [any Action] {
func allMenuActions(
feedback: Set<FeedbackType> = [.haptic, .toast],
report: Report? = nil
) -> [any Action] {
basicMenuActions(feedback: feedback)
if api.isAdmin {
ActionGroup(
appearance: .init(label: "Moderation...", color: Palette.main.moderation, icon: Icons.moderation),
displayMode: Settings.main.moderatorActionGrouping == .divider ? .section : .disclosure
) {
moderatorMenuActions(feedback: feedback, report: report)
}
}
}

@ActionBuilder
func basicMenuActions(
feedback: Set<FeedbackType> = [.haptic, .toast],
report: Report? = nil
) -> [any Action] {
if !isOwnMessage {
replyAction()
markReadAction(feedback: feedback)
Expand All @@ -35,11 +54,25 @@ extension Message1Providing {
if isOwnMessage {
deleteAction(feedback: feedback)
} else {
reportAction()
if report == nil {
reportAction()
}
blockCreatorAction(feedback: feedback)
}
}

@ActionBuilder
func moderatorMenuActions(
feedback: Set<FeedbackType> = [.haptic, .toast],
report: Report? = nil
) -> [any Action] {
if let report {
ActionGroup {
report.menuActions()
}
}
}

// These actions are also defined in Interactable1Providing... another protocol for these may be a good idea

func replyAction() -> BasicAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ extension Post1Providing {
feedback: Set<FeedbackType> = [.haptic, .toast],
showAllActions: Bool = true,
navigation: NavigationLayer?,
report: Report? = nil,
commentTreeTracker: CommentTreeTracker? = nil
) -> [any Action] {
basicMenuActions(feedback: feedback, commentTreeTracker: commentTreeTracker)
Expand All @@ -141,7 +142,7 @@ extension Post1Providing {
appearance: .init(label: "Moderation...", color: Palette.main.moderation, icon: Icons.moderation),
displayMode: Settings.main.moderatorActionGrouping == .divider || expanded ? .section : .disclosure
) {
moderatorMenuActions(feedback: feedback, navigation: navigation, showAllActions: showAllActions)
moderatorMenuActions(feedback: feedback, navigation: navigation, report: report, showAllActions: showAllActions)
}
}
}
Expand Down Expand Up @@ -183,6 +184,7 @@ extension Post1Providing {
func moderatorMenuActions(
feedback: Set<FeedbackType> = [.haptic, .toast],
navigation: NavigationLayer?,
report: Report? = nil,
showAllActions: Bool = true
) -> [any Action] {
if showAllActions || Settings.main.showAllModActions {
Expand All @@ -205,6 +207,11 @@ extension Post1Providing {
purgeCreatorAction()
}
}
if let report {
ActionGroup {
report.menuActions()
}
}
}

// swiftlint:disable:next cyclomatic_complexity
Expand Down
37 changes: 37 additions & 0 deletions Mlem/App/Utility/Extensions/Content Models/Report+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Report+Extensions.swift
// Mlem
//
// Created by Sjmarf on 2024-12-16.
//

import MlemMiddleware

extension Report {
func toggleResolved(feedback: Set<FeedbackType>) {
if feedback.contains(.haptic) {
HapticManager.main.play(haptic: .success, priority: .low)
}
toggleResolved()
}

@ActionBuilder
func menuActions(
feedback: Set<FeedbackType> = [.haptic]
) -> [any Action] {
resolveAction(feedback: feedback)
}

func resolveAction(feedback: Set<FeedbackType> = []) -> BasicAction {
.init(
id: "resolve\(cacheId)",
appearance: .init(
label: resolved ? "Unresolve" : "Resolve",
color: resolved ? Palette.main.negative : Palette.main.positive,
icon: resolved ? Icons.failureCircle : Icons.successCircle,
swipeIcon2: resolved ? Icons.failureCircleFill : Icons.successCircleFill
),
callback: api.canInteract ? { self.toggleResolved(feedback: feedback) } : nil
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension EnvironmentValues {
@Entry var postContext: (any Post1Providing)?
@Entry var commentContext: (any Comment1Providing)?
@Entry var communityContext: (any Community1Providing)?
@Entry var reportContext: Report?

@Entry var parentFrameWidth: CGFloat = .zero
@Entry var isRootView: Bool = false
Expand Down
Loading

0 comments on commit cafa13f

Please sign in to comment.