Skip to content

Commit

Permalink
resolves #264, moderator pin actions are now logged (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
cohoe authored Feb 25, 2024
1 parent 7bc8ff8 commit c347520
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/swiftarr/Controllers/ForumController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ struct ForumController: APIRouteCollection {
}
forum.pinned = true;
try await forum.save(on: req.db)
try await forum.logIfModeratorAction(.pin, moderatorID: cacheUser.userID, on: req)
return .created
}

Expand All @@ -982,6 +983,7 @@ struct ForumController: APIRouteCollection {
}
forum.pinned = false;
try await forum.save(on: req.db)
try await forum.logIfModeratorAction(.unpin, moderatorID: cacheUser.userID, on: req)
return .noContent
}

Expand Down Expand Up @@ -1416,6 +1418,7 @@ struct ForumController: APIRouteCollection {
}
post.pinned = true;
try await post.save(on: req.db)
try await post.logIfModeratorAction(.pin, moderatorID: cacheUser.userID, on: req)
return .created
}

Expand Down Expand Up @@ -1444,6 +1447,7 @@ struct ForumController: APIRouteCollection {
}
post.pinned = false;
try await post.save(on: req.db)
try await post.logIfModeratorAction(.unpin, moderatorID: cacheUser.userID, on: req)
return .noContent
}
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/swiftarr/Enumerations/ModeratorActionType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public enum ModeratorActionType: String, Codable {
case lock
/// The moderator has unlocked a piece of content.
case unlock
/// The moderator has pinned a forum post or thread.
case pin
/// The moderator has unpinned a forum post or thread.
case unpin

/// The mod set the `userAccessLevel` of a user to `.unverified`
case accessLevelUnverified
Expand Down

0 comments on commit c347520

Please sign in to comment.