Skip to content

Commit

Permalink
report docs "tickets" to docs channel, not to issues-and-prs
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Sep 30, 2023
1 parent 16d6113 commit 4676372
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Lambdas/GHHooks/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ enum Constants {
case issueAndPRs = "1123702585006768228"
case release = "431926479752921098"
case thanks = "443074453719744522"
case documentation = "484454139506458634"

var id: ChannelSnowflake {
self.rawValue
}

static func reportingChannel(repoID: Int) -> Self {
switch repoID {
case 64560805:
return .documentation
default:
return .issueAndPRs
}
}
}

enum Roles: RoleSnowflake {
Expand Down
14 changes: 11 additions & 3 deletions Lambdas/GHHooks/EventHandler/Handlers/TicketReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ struct TicketReporter {
let embed: Embed
let repoID: Int
let number: Int
var channel: Constants.Channels {
/// The change to use `.reportingChannel(repoID:)` was made only after this timestamp.
if Date().timeIntervalSince1970 < 1_696_067_000 {
return .issueAndPRs
} else {
return .reportingChannel(repoID: repoID)
}
}

func reportCreation() async throws {
let response = try await context.discordClient.createMessage(
channelId: Constants.Channels.issueAndPRs.id,
channelId: self.channel.id,
payload: .init(embeds: [embed])
).decode()
try await context.messageLookupRepo.saveMessageID(
Expand Down Expand Up @@ -48,7 +56,7 @@ struct TicketReporter {
)

let response = try await context.discordClient.createMessage(
channelId: Constants.Channels.issueAndPRs.id,
channelId: self.channel.id,
payload: .init(embeds: [embed])
).decode()

Expand All @@ -61,7 +69,7 @@ struct TicketReporter {
}

let response = try await context.discordClient.updateMessage(
channelId: Constants.Channels.issueAndPRs.id,
channelId: self.channel.id,
messageId: messageID,
payload: .init(embeds: [embed])
)
Expand Down

0 comments on commit 4676372

Please sign in to comment.