Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub OpenAPI.yaml #282

Merged
merged 12 commits into from
Jan 4, 2025
2 changes: 1 addition & 1 deletion Lambdas/GHHooks/EventHandler/Handlers/IssueHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct IssueHandler: Sendable {
}

/// Returns the `closed-by` user if the issue is closed at all.
func maybeGetClosedByUser() async throws -> (id: Int, uiName: String)? {
func maybeGetClosedByUser() async throws -> (id: Int64, uiName: String)? {
if issue.closedAt == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion Lambdas/GHHooks/EventHandler/Handlers/PRHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private enum Status: String {
}

init(pr: PullRequest) {
if pr.mergedBy != nil {
if pr.mergedAt != nil {
self = .merged
} else if pr.closedAt != nil {
self = .closed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ struct ProjectBoardHandler {
).created
}

func move(toColumnID columnID: Int, cardID: Int) async throws {
func move(toColumnID columnID: Int, cardID: Int64) async throws {
_ = try await self.context.githubClient.projectsMoveCard(
path: .init(cardId: cardID),
path: .init(cardId: Int(cardID)),
body: .json(.init(position: "top", columnId: columnID))
).created
}

func delete(cardID: Int) async throws {
func delete(cardID: Int64) async throws {
_ = try await self.context.githubClient.projectsDeleteCard(
path: .init(cardId: cardID)
path: .init(cardId: Int(cardID))
).noContent
}

Expand All @@ -130,7 +130,7 @@ struct ProjectBoardHandler {
try await self.getCards(in: project.columnID(of: column))
}

func move(cardID: Int) async throws {
func move(cardID: Int64) async throws {
try await self.move(toColumnID: project.columnID(of: targetColumn), cardID: cardID)
}

Expand Down
18 changes: 8 additions & 10 deletions Lambdas/GHHooks/EventHandler/Handlers/ReleaseMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ struct ReleaseMaker {

enum Configuration {
/// The postgres-nio repository ID.
static let repositoryIDDenyList: Set<Int> = [150_622_661]
static let repositoryIDDenyList: Set<Int64> = [150_622_661]
/// Needs the Penny installation to be installed on the org,
/// which is not possible without making Penny app public.
/// The Vapor organization ID.
static let organizationIDAllowList: Set<Int> = [17_364_220]
static let organizationIDAllowList: Set<Int64> = [17_364_220]
static let releaseNoticePrefix = "**These changes are now available in"
}

Expand Down Expand Up @@ -289,7 +289,7 @@ struct ReleaseMaker {
return sorted
}

func isNewContributor(codeOwners: CodeOwners, existingContributors: Set<Int>) -> Bool {
func isNewContributor(codeOwners: CodeOwners, existingContributors: Set<Int64>) -> Bool {
pr.authorAssociation != .owner && !pr.user.isBot && !codeOwners.contains(user: pr.user)
&& !existingContributors.contains(pr.user.id)
}
Expand Down Expand Up @@ -320,9 +320,9 @@ struct ReleaseMaker {
return json
}

func getExistingContributorIDs() async throws -> Set<Int> {
func getExistingContributorIDs() async throws -> Set<Int64> {
var page = 1
var contributorIds: [Int] = []
var contributorIds: [Int64] = []
/// Hack: Vapor has around this amount of contributors and we know it, so better
/// to reserve enough capacity for it up-front.
contributorIds.reserveCapacity(250)
Expand All @@ -338,7 +338,7 @@ struct ReleaseMaker {
return Set(contributorIds)
}

func getExistingContributorIDs(page: Int) async throws -> (ids: [Int], hasNext: Bool) {
func getExistingContributorIDs(page: Int) async throws -> (ids: [Int64], hasNext: Bool) {
logger.debug(
"Will fetch current contributors",
metadata: [
Expand All @@ -364,14 +364,12 @@ struct ReleaseMaker {
/// If the header contains `rel="next"` then we'll have a next page to fetch.
let hasNext =
switch ok.headers.link {
case let .case1(string):
case let .some(string):
string.contains(#"rel="next""#)
case let .case2(strings):
strings.contains { $0.contains(#"rel="next""#) }
case .none:
false
}
let ids = json.compactMap(\.id)
let ids = json.compactMap(\.id).map(Int64.init)
logger.debug(
"Fetched some contributors",
metadata: [
Expand Down
12 changes: 6 additions & 6 deletions Lambdas/GHHooks/EventHandler/Handlers/TicketReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ struct TicketReporter {

enum Configuration {
/// The dependabot[bot] user ID.
static let userIDDenyList: Set<Int> = [49_699_333]
static let userIDDenyList: Set<Int64> = [49_699_333]
}

private static let ticketQueue = SerialProcessor()

var context: HandlerContext
let embed: Embed
let createdAt: Date
let repoID: Int
let repoID: Int64
let number: Int
let authorID: Int
let authorID: Int64
var ticketKey: String {
"\(repoID)_\(number)"
}
Expand All @@ -34,9 +34,9 @@ struct TicketReporter {
context: HandlerContext,
embed: Embed,
createdAt: Date,
repoID: Int,
repoID: Int64,
number: Int,
authorID: Int
authorID: Int64
) {
self.context = context
self.embed = embed
Expand Down Expand Up @@ -134,7 +134,7 @@ struct TicketReporter {
}

extension Constants.Channels {
fileprivate static func reportingChannel(repoID: Int, createdAt: Date) -> Self {
fileprivate static func reportingChannel(repoID: Int64, createdAt: Date) -> Self {
/// The change to use `.documentation` was made only after this timestamp.
if createdAt.timeIntervalSince1970 < 1_696_067_000 {
return .issuesAndPRs
Expand Down
10 changes: 5 additions & 5 deletions Lambdas/GHHooks/MessageLookupRepo/DynamoMessageRepo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ struct DynamoMessageRepo: MessageLookupRepo {
self.logger = logger
}

private func makeTicketID(repoID: Int, number: Int) -> String {
private func makeTicketID(repoID: Int64, number: Int) -> String {
"\(repoID)_\(number)"
}

func getMessageID(repoID: Int, number: Int) async throws -> String {
func getMessageID(repoID: Int64, number: Int) async throws -> String {
let item = try await self.getItem(repoID: repoID, number: number)
if item.isUnavailable {
throw Errors.unavailable
}
return item.messageID
}

private func getItem(repoID: Int, number: Int) async throws -> Item {
private func getItem(repoID: Int64, number: Int) async throws -> Item {
let id = makeTicketID(repoID: repoID, number: number)
let item = try await self.get(id: id)
return item
Expand All @@ -69,13 +69,13 @@ struct DynamoMessageRepo: MessageLookupRepo {
/// for a ticket to Discord, but a moderator deletes that messages, then there is an update
/// to the ticket, but the previous message is unavailable to edit anymore, so Penny should
/// just ignore updates to messages of that ticket.
func markAsUnavailable(repoID: Int, number: Int) async throws {
func markAsUnavailable(repoID: Int64, number: Int) async throws {
var item = try await self.getItem(repoID: repoID, number: number)
item._isUnavailable = true
try await save(item: item)
}

func saveMessageID(messageID: String, repoID: Int, number: Int) async throws {
func saveMessageID(messageID: String, repoID: Int64, number: Int) async throws {
let id = makeTicketID(repoID: repoID, number: number)
let item = Item(id: id, messageID: messageID)
try await save(item: item)
Expand Down
6 changes: 3 additions & 3 deletions Lambdas/GHHooks/MessageLookupRepo/MessageLookupRepo.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
protocol MessageLookupRepo: Sendable {
func getMessageID(repoID: Int, number: Int) async throws -> String
func markAsUnavailable(repoID: Int, number: Int) async throws
func saveMessageID(messageID: String, repoID: Int, number: Int) async throws
func getMessageID(repoID: Int64, number: Int) async throws -> String
func markAsUnavailable(repoID: Int64, number: Int) async throws
func saveMessageID(messageID: String, repoID: Int64, number: Int) async throws
}
6 changes: 3 additions & 3 deletions Lambdas/GitHubAPI/Aliases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ package typealias PullRequestReviewComment = Components.Schemas.PullRequestRevie
package typealias PullRequestReview = Components.Schemas.PullRequestReview
package typealias DiffEntry = Components.Schemas.DiffEntry
package typealias Commit = Components.Schemas.Commit
package typealias SimpleCommit = Components.Schemas.SimpleCommit
package typealias Committer = Components.Schemas.SimpleCommit.CommitterPayload
package typealias SimpleCommit = Components.Schemas.Commit
package typealias Committer = Components.Schemas.Commit.CommitterPayload
package typealias Enterprise = Components.Schemas.Enterprise
package typealias Installation = Components.Schemas.SimpleInstallation
package typealias Installation = Components.Schemas.Installation
package typealias Tag = Components.Schemas.Tag
package typealias ProjectCard = Components.Schemas.ProjectCard
package typealias TimelineIssueEvents = Components.Schemas.TimelineIssueEvents
Loading
Loading