|
| 1 | +// |
| 2 | +// ToolsOzoneModerationCancelScheduledActions.swift |
| 3 | +// ATProtoKit |
| 4 | +// |
| 5 | +// Created by Christopher Jr Riley on 2025-11-18. |
| 6 | +// |
| 7 | + |
| 8 | +import Foundation |
| 9 | +#if canImport(FoundationNetworking) |
| 10 | +import FoundationNetworking |
| 11 | +#endif |
| 12 | + |
| 13 | +extension ToolsOzoneLexicon.Moderation { |
| 14 | + |
| 15 | + /// A definition model for cancelling any pending scheduled moderation actions for the specified |
| 16 | + /// user accounts. |
| 17 | + /// |
| 18 | + /// - Note: According to the AT Protocol specifications: "Cancel all pending scheduled moderation actions for specified subjects" |
| 19 | + /// |
| 20 | + /// - SeeAlso: This is based on the [`tools.ozone.moderation.cancelScheduledActions`][github] lexicon. |
| 21 | + /// |
| 22 | + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/cancelScheduledActions.json |
| 23 | + public struct CancelScheduledActions: Sendable, Codable { |
| 24 | + |
| 25 | + /// Results of the cancelled pending actions. |
| 26 | + public struct CancellationResults: Sendable, Codable { |
| 27 | + |
| 28 | + /// An array of decentralized identifiers (DIDs) that had all of their actions |
| 29 | + /// successfully completed. |
| 30 | + /// |
| 31 | + /// - Note: According to the AT Protocol specifications: "DIDs for which all pending scheduled |
| 32 | + /// actions were successfully cancelled." |
| 33 | + public let successfulActions: [String] |
| 34 | + |
| 35 | + /// An array of error details for each failed action. |
| 36 | + /// |
| 37 | + /// - Note: According to the AT Protocol specifications: "DIDs for which cancellation failed |
| 38 | + /// with error details." |
| 39 | + public let failedActions: [FailedCancellation] |
| 40 | + |
| 41 | + enum CodingKeys: String, CodingKey { |
| 42 | + case successfulActions = "succeeded" |
| 43 | + case failedActions = "failed" |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + /// Error details for each failed action. |
| 48 | + public struct FailedCancellation: Sendable, Codable { |
| 49 | + |
| 50 | + /// The decentralized identifier (DID) of the user account associated with the failed action. |
| 51 | + public let did: String |
| 52 | + |
| 53 | + /// The error details. |
| 54 | + public let error: String |
| 55 | + |
| 56 | + /// The error code of the failed action. Optional. |
| 57 | + public let errorCode: String? |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + /// A request body model for cancelling any pending scheduled moderation actions for the specified |
| 62 | + /// user accounts. |
| 63 | + /// |
| 64 | + /// - Note: According to the AT Protocol specifications: "Cancel all pending scheduled moderation actions for specified subjects" |
| 65 | + /// |
| 66 | + /// - SeeAlso: This is based on the [`tools.ozone.moderation.cancelScheduledActions`][github] lexicon. |
| 67 | + /// |
| 68 | + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/cancelScheduledActions.json |
| 69 | + public struct CancelScheduledActionsRequestBody: Sendable, Codable { |
| 70 | + |
| 71 | + /// An array of decentralized identifiers (DIDs) for which the cancellations will occur on. |
| 72 | + /// |
| 73 | + /// - Note: According to the AT Protocol specifications: "Array of DID subjects to cancel scheduled |
| 74 | + /// actions for." |
| 75 | + public let subjects: [String] |
| 76 | + |
| 77 | + /// A comment to attach to the cancellation. Optional. |
| 78 | + /// |
| 79 | + /// - Note: According to the AT Protocol specifications: "Optional comment describing the reason |
| 80 | + /// for cancellation." |
| 81 | + public let comment: String? |
| 82 | + |
| 83 | + public init(subjects: [String], comment: String?) { |
| 84 | + self.subjects = subjects |
| 85 | + self.comment = comment |
| 86 | + } |
| 87 | + |
| 88 | + public init(from decoder: any Decoder) throws { |
| 89 | + let container = try decoder.container(keyedBy: CodingKeys.self) |
| 90 | + |
| 91 | + self.subjects = try container.decode([String].self, forKey: .subjects) |
| 92 | + self.comment = try container.decodeIfPresent(String.self, forKey: .comment) |
| 93 | + } |
| 94 | + |
| 95 | + public func encode(to encoder: any Encoder) throws { |
| 96 | + var container = encoder.container(keyedBy: CodingKeys.self) |
| 97 | + |
| 98 | + try container.truncatedEncode(self.subjects, forKey: .subjects, upToArrayLength: 100) |
| 99 | + try container.encodeIfPresent(self.comment, forKey: .comment) |
| 100 | + } |
| 101 | + |
| 102 | + enum CodingKeys: CodingKey { |
| 103 | + case subjects |
| 104 | + case comment |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | +// /// An output model for cancelling any pending scheduled moderation actions for the specified |
| 109 | +// /// user accounts. |
| 110 | +// /// |
| 111 | +// /// - Note: According to the AT Protocol specifications: "Cancel all pending scheduled moderation actions for specified subjects" |
| 112 | +// /// |
| 113 | +// /// - SeeAlso: This is based on the [`tools.ozone.moderation.cancelScheduledActions`][github] lexicon. |
| 114 | +// /// |
| 115 | +// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/cancelScheduledActions.json |
| 116 | +// public struct CancelScheduledActionsOutput: Sendable, Codable { |
| 117 | +// |
| 118 | +// /// |
| 119 | +// } |
| 120 | +} |
0 commit comments