diff --git a/Mastodon/Scene/Report/Report/ReportViewModel.swift b/Mastodon/Scene/Report/Report/ReportViewModel.swift index f94a92d3..fdd90a77 100644 --- a/Mastodon/Scene/Report/Report/ReportViewModel.swift +++ b/Mastodon/Scene/Report/Report/ReportViewModel.swift @@ -165,7 +165,25 @@ extension ReportViewModel { accountID: user.id, statusIDs: statusIDs, comment: comment, - forward: true + forward: true, + category: { + switch self.reportReasonViewModel.selectReason { + case .dislike: return nil + case .spam: return .spam + case .violateRule: return .violation + case .other: return .other + case .none: return nil + } + }(), + ruleIDs: { + switch self.reportReasonViewModel.selectReason { + case .violateRule: + guard let rule = self.reportServerRulesViewModel.selectRule else { return nil } + return [rule.id] + default: + return nil + } + }() ) } diff --git a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Report.swift b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Report.swift index 6ba8c3cf..08ca3e92 100644 --- a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Report.swift +++ b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Report.swift @@ -69,23 +69,40 @@ public extension Mastodon.API.Reports { public var statusIDs: [Mastodon.Entity.Status.ID]? public var comment: String? public let forward: Bool? + + public let category: Category? + public let ruleIDs: [Mastodon.Entity.Instance.Rule.ID]? enum CodingKeys: String, CodingKey { case accountID = "account_id" case statusIDs = "status_ids" case comment case forward + case category + case ruleIDs = "rule_ids" + + } + + public enum Category: String, Codable { + case spam + case violation + case other } public init( accountID: Mastodon.Entity.Account.ID, statusIDs: [Mastodon.Entity.Status.ID]?, comment: String?, - forward: Bool?) { + forward: Bool?, + category: Category?, + ruleIDs: [Mastodon.Entity.Instance.Rule.ID]? + ) { self.accountID = accountID self.statusIDs = statusIDs self.comment = comment self.forward = forward + self.category = category + self.ruleIDs = ruleIDs } } } diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift index 5d649a84..353601cd 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift @@ -106,7 +106,9 @@ extension Mastodon.Entity.Instance { extension Mastodon.Entity.Instance { public struct Rule: Codable, Hashable { - public let id: String + public typealias ID = String + + public let id: ID public let text: String } }