Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterJ93 committed Apr 25, 2024
2 parents 9cda638 + ab25f73 commit 29f793f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ let package = Package(
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "ATProtoKit",
dependencies: [
"SwiftSoup",
.product(name: "Logging", package: "swift-log")
])
dependencies: [
"SwiftSoup",
.product(name: "Logging", package: "swift-log")
]
)
// .testTarget(
// name: "ATProtoKitTests",
// dependencies: ["ATProtoKit"]),
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ dependencies: [
]
```

Then under `targets`:
```swift
targets: [
.target(
// name: ...,
dependencies: [
.product(name: "ATProtoKit", package: "atprotokit")
]
)
]
```

## Roadmap
The Projects page isn't set up yet, so it'll be a while before you can see the progress for this project. However, some of the goals include:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ public enum AdminEventViewUnion: Codable {
case moderationEventMute(OzoneModerationEventMute)
/// An unmute event.
case moderationEventUnmute(OzoneModerationEventUnmute)
/// A mute reporter event.
case moderationEventMuteReporter(OzoneModerationEventMuteReporter)
/// An unmute reporter event.
case moderationEventUnmuteReporter(OzoneModerationEventUnmuteReporter)
/// An email event.
case moderationEventEmail(OzoneModerationEventEmail)
/// A resolve appeal event.
Expand Down Expand Up @@ -348,6 +352,10 @@ public enum AdminEventViewUnion: Codable {
self = .moderationEventMute(value)
} else if let value = try? container.decode(OzoneModerationEventUnmute.self) {
self = .moderationEventUnmute(value)
} else if let value = try? container.decode(OzoneModerationEventMuteReporter.self) {
self = .moderationEventMuteReporter(value)
} else if let value = try? container.decode(OzoneModerationEventUnmuteReporter.self) {
self = .moderationEventUnmuteReporter(value)
} else if let value = try? container.decode(OzoneModerationEventEmail.self) {
self = .moderationEventEmail(value)
} else if let value = try? container.decode(OzoneModerationEventResolveAppeal.self) {
Expand Down Expand Up @@ -382,6 +390,10 @@ public enum AdminEventViewUnion: Codable {
try container.encode(moderationEventMute)
case .moderationEventUnmute(let moderationEventUnmute):
try container.encode(moderationEventUnmute)
case .moderationEventMuteReporter(let moderationEventMuteReporter):
try container.encode(moderationEventMuteReporter)
case .moderationEventUnmuteReporter(let moderationEventUnmuteReporter):
try container.encode(moderationEventUnmuteReporter)
case .moderationEventEmail(let moderationEventEmail):
try container.encode(moderationEventEmail)
case .moderationEventResolveAppeal(let moderationEventResolveAppeal):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,36 @@ public struct OzoneModerationEventUnmute: Codable {
public var comment: String? = nil
}

/// A data model definition for a mute reporter event.
///
/// - Note: According to the AT Protocol specifications: "Mute incoming reports from an account."
///
/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon.
///
/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json
public struct OzoneModerationEventMuteReporter: Codable {
/// Indicates how long the account should remain muted (in hours).
///
/// - Note: According to the AT Protocol specifications: "Indicates how long the account should remain muted."
public let durationInHours: Int
/// Any additional comments about the event. Optional.
public let comment: String?
}

/// A data model definition for an unmute reporter event.
///
/// - Note: According to the AT Protocol specifications: "Unmute incoming reports from an account."
///
/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon.
///
/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json
public struct OzoneModerationEventUnmuteReporter: Codable {
/// Any additional comments about the event.
///
/// - Note: According to the AT Protocol specifications: "Describe reasoning behind the reversal."
public let comment: String?
}

/// A data model for a definition of an email event.
///
/// - Note: According to the AT Protocol specifications: "Keep a log of outgoing email to a user."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extension ATProtoAdmin {
/// - reviewedAfter: States that the moderator statuses displayed should be after a specified review date. Optional.
/// - reviewedBefore: States that the moderator statuses displayed should be before a specified review date. Optional.
/// - shouldIncludeMuted: Indicates whether muted subjects should be included in the results. Optional. Defaults to `false`.
/// - isOnlyMuted: Indicates whether only muted subjects and reporters will be returned.
/// - reviewState: Specify when fetching subjects in a certain state. Optional.
/// - ignoreSubjects: An array of records and repositories to ignore. Optional.
/// - lastReviewedBy: Specifies the decentralized identifier (DID) of the moderator whose reviewed statuses are queried. Optional.
Expand All @@ -41,8 +42,8 @@ extension ATProtoAdmin {
/// - cursor: The mark used to indicate the starting point for the next set of results. Optional.
/// - Returns: A `Result`, containing either an ``AdminQueryModerationStatusesOutput`` if successful, or an `Error` if not.
public func queryStatuses(_ subject: String?, comment: String?, reportedAfter: Date?, reportedBefore: Date?, reviewedAfter: Date?,
reviewedBefore: Date?, shouldIncludeMuted: Bool? = false, reviewState: String?, ignoreSubjects: [String]?,
lastReviewedBy: String?, sortField: AdminQueryModerationStatusesSortField? = .lastReportedAt,
reviewedBefore: Date?, shouldIncludeMuted: Bool? = false, isOnlyMuted: Bool?, reviewState: String?,
ignoreSubjects: [String]?, lastReviewedBy: String?, sortField: AdminQueryModerationStatusesSortField? = .lastReportedAt,
sortDirection: AdminQueryModerationStatusesSortDirection? = .descending, isTakenDown: Bool?,
isAppealed: Bool?, limit: Int? = 50, tags: [String]?, excludeTags: [String]?,
cursor: String?) async throws -> Result<AdminQueryModerationStatusesOutput, Error> {
Expand Down Expand Up @@ -83,6 +84,11 @@ extension ATProtoAdmin {
queryItems.append(("includeMuted", "\(shouldIncludeMuted)"))
}

// isOnlyMuted (onlyMuted)
if let isOnlyMuted {
queryItems.append(("onlyMuted", "\(isOnlyMuted)"))
}

// reviewState
if let reviewState {
queryItems.append(("reviewState", reviewState))
Expand Down

0 comments on commit 29f793f

Please sign in to comment.