2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Distinguish between different types of admin reports in the notifications screen

This commit is contained in:
shannon 2025-04-02 13:24:58 -04:00
parent d73e318c39
commit 030c3e1260
8 changed files with 89 additions and 14 deletions

View File

@ -769,6 +769,10 @@
"single_name_signed_up": "%@ signed up",
"someone_reported_account_for_rule_violation": "Someone reported %@ for rule violation.",
"someone_reported_posts_from_account_for_rule_violation": "Someone reported %@ from %@ for rule violation."
"someone_reported_account_for_spam": "Someone reported %@ for spam.",
"someone_reported_posts_from_account_for_spam": "Someone reported %@ from %@ for spam."
"someone_reported_account": "Someone reported %@.",
"someone_reported_posts_from_account": "Someone reported %@ from %@."
},
"notification_description": {
"followed_you": "followed you",

View File

@ -16,7 +16,7 @@ protocol NotificationInfo {
var authorAvatarUrls: [URL] { get }
func availableRelationshipElement() async -> RelationshipElement?
func fetchRelationshipElement() async -> RelationshipElement
var ruleViolationReport: Mastodon.Entity.Report? { get }
var adminReport: Mastodon.Entity.Report? { get }
var relationshipSeveranceEvent: Mastodon.Entity.RelationshipSeveranceEvent?
{ get }
}

View File

@ -163,15 +163,42 @@ extension GroupedNotificationType {
extension Mastodon.Entity.Report {
// "Someone reported X posts from someone else for rule violation"
// "Someone reported X posts from someone else for spam"
// "Someone reported X posts from someone else"
var summary: AttributedString {
if let targetedAccountName = targetAccount?.displayNameWithFallback {
let summaryPlainstring: String
if let postCount = flaggedStatusIDs?.count {
let postsString = L10n.Plural.Count.post(postCount)
summaryPlainstring = L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedPostsFromAccountForRuleViolation(postsString, targetedAccountName)
} else {
summaryPlainstring = L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedAccountForRuleViolation(targetedAccountName)
}
let postCountString: String? = {
if let postCount = flaggedStatusIDs?.count {
return L10n.Plural.Count.post(postCount)
} else {
return nil
}
}()
let summaryPlainstring: String = {
switch category {
case .spam:
if let postCountString {
return L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedPostsFromAccountForSpam(postCountString, targetedAccountName)
} else {
return L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedAccountForSpam(targetedAccountName)
}
case .violation:
if let postCountString {
return L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedPostsFromAccountForRuleViolation(postCountString, targetedAccountName)
} else {
return L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedAccountForRuleViolation(targetedAccountName)
}
case ._other, nil:
if let postCountString {
return L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedPostsFromAccount(postCountString, targetedAccountName)
} else {
return L10n.Scene.Notification.GroupedNotificationDescription.someoneReportedAccount(targetedAccountName)
}
}
}()
var attributedString = AttributedString(summaryPlainstring)
let boldedName = styledNameComponent(targetedAccountName, style: AttributeContainer.font(
.system(.body, weight: .bold)), emojis: targetAccount?.emojiMeta)

View File

@ -838,7 +838,7 @@ extension GroupedNotificationType {
case .adminSignUp:
self = .adminSignUp
case .adminReport:
self = .adminReport(notification.ruleViolationReport)
self = .adminReport(notification.adminReport)
case .severedRelationships:
let url = severedRelationshipsUrl(
forDomain: myAccountDomain,
@ -883,7 +883,7 @@ extension GroupedNotificationType {
case .adminSignUp:
self = .adminSignUp
case .adminReport:
self = .adminReport(notificationGroup.ruleViolationReport)
self = .adminReport(notificationGroup.adminReport)
case .severedRelationships:
let url = severedRelationshipsUrl(forDomain: myAccountDomain, notificationID: String(notificationGroup.mostRecentNotificationID))
self = .severedRelationships(

View File

@ -1012,14 +1012,30 @@ public enum L10n {
public static func singleNameSignedUp(_ p1: Any) -> String {
return L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.SingleNameSignedUp", String(describing: p1), fallback: "%@ signed up")
}
/// Someone reported %@.
public static func someoneReportedAccount(_ p1: Any) -> String {
return L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.SomeoneReportedAccount", String(describing: p1), fallback: "Someone reported %@.")
}
/// Someone reported %@ for rule violation.
public static func someoneReportedAccountForRuleViolation(_ p1: Any) -> String {
return L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.SomeoneReportedAccountForRuleViolation", String(describing: p1), fallback: "Someone reported %@ for rule violation.")
}
/// Someone reported %@ for spam.
public static func someoneReportedAccountForSpam(_ p1: Any) -> String {
return L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.SomeoneReportedAccountForSpam", String(describing: p1), fallback: "Someone reported %@ for spam.")
}
/// Someone reported %@ from %@.
public static func someoneReportedPostsFromAccount(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.SomeoneReportedPostsFromAccount", String(describing: p1), String(describing: p2), fallback: "Someone reported %@ from %@.")
}
/// Someone reported %@ from %@ for rule violation.
public static func someoneReportedPostsFromAccountForRuleViolation(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.SomeoneReportedPostsFromAccountForRuleViolation", String(describing: p1), String(describing: p2), fallback: "Someone reported %@ from %@ for rule violation.")
}
/// Someone reported %@ from %@ for spam.
public static func someoneReportedPostsFromAccountForSpam(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.SomeoneReportedPostsFromAccountForSpam", String(describing: p1), String(describing: p2), fallback: "Someone reported %@ from %@ for spam.")
}
/// Your poll has ended
public static let yourPollHasEnded = L10n.tr("Localizable", "Scene.Notification.GroupedNotificationDescription.YourPollHasEnded", fallback: "Your poll has ended")
}

View File

@ -357,6 +357,10 @@ Please retry in a few minutes.";
"Scene.Notification.GroupedNotificationDescription.SingleNameSignedUp" = "%@ signed up";
"Scene.Notification.GroupedNotificationDescription.SomeoneReportedAccountForRuleViolation" = "Someone reported %@ for rule violation.";
"Scene.Notification.GroupedNotificationDescription.SomeoneReportedPostsFromAccountForRuleViolation" = "Someone reported %@ from %@ for rule violation.";
"Scene.Notification.GroupedNotificationDescription.SomeoneReportedPostsFromAccountForSpam" = "Someone reported %@ from %@ for spam.";
"Scene.Notification.GroupedNotificationDescription.SomeoneReportedAccountForSpam" = "Someone reported %@ for spam.";
"Scene.Notification.GroupedNotificationDescription.SomeoneReportedPostsFromAccount" = "Someone reported %@ from %@.";
"Scene.Notification.GroupedNotificationDescription.SomeoneReportedAccount" = "Someone reported %@.";
"Scene.Notification.GroupedNotificationDescription.YourPollHasEnded" = "Your poll has ended";
"Scene.Notification.Headers.Boost" = "Boost";
"Scene.Notification.Headers.Edit" = "Edit";

View File

@ -25,7 +25,7 @@ extension Mastodon.Entity {
public let groupKey: String?
public let account: Account
public let status: Status?
public let ruleViolationReport: Report?
public let adminReport: Report?
public let relationshipSeveranceEvent: RelationshipSeveranceEvent?
public let accountWarning: AccountWarning?
@ -36,7 +36,7 @@ extension Mastodon.Entity {
case createdAt = "created_at"
case account
case status
case ruleViolationReport = "report"
case adminReport = "report"
case accountWarning = "moderation_warning"
case relationshipSeveranceEvent = "event"
}
@ -62,7 +62,7 @@ extension Mastodon.Entity {
public let latestPageNotificationAt: Date? // Date at which the most recent notification from this group within the current page has been created. This is only returned when paginating through notification groups.
public let sampleAccountIDs: [String] // IDs of some of the accounts who most recently triggered notifications in this group.
public let statusID: ID?
public let ruleViolationReport: Report? // Attached when type of the notification is admin.report
public let adminReport: Report? // Attached when type of the notification is admin.report
public let relationshipSeveranceEvent: RelationshipSeveranceEvent? // Attached when type of the notification is severed_relationships
public let accountWarning: AccountWarning?
@ -76,7 +76,7 @@ extension Mastodon.Entity {
case latestPageNotificationAt = "latest_page_notification_at"
case sampleAccountIDs = "sample_account_ids"
case statusID = "status_id"
case ruleViolationReport = "report"
case adminReport = "report"
case accountWarning = "moderation_warning"
case relationshipSeveranceEvent = "event"
}

View File

@ -24,6 +24,7 @@ extension Mastodon.Entity {
public let targetAccount: Account? // The account that was reported.
public let flaggedStatusIDs: [String]? // IDs of statuses that have been attached to this report for additional context.
public let comment: String? // The reason for the report.
public let category: Category? // the type of report
enum CodingKeys: String, CodingKey {
case id
@ -31,6 +32,29 @@ extension Mastodon.Entity {
case targetAccount = "target_account"
case flaggedStatusIDs = "status_ids"
case comment
case category
}
public enum Category: RawRepresentable, Codable, Sendable {
case spam
case violation
case _other(String)
public init?(rawValue: String) {
switch rawValue {
case "spam": self = .spam
case "violation": self = .violation
default: self = ._other(rawValue)
}
}
public var rawValue: RawValue {
switch self {
case .spam: return "spam"
case .violation: return "violation"
case ._other(let string): return string
}
}
}
}
}