Skip to content

Commit

Permalink
feat: update api downtime notification
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Aug 16, 2024
1 parent b0100fb commit 9759b49
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions web/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type notification struct {

func NotificationsEndpoint(httpClient *http.Client) echo.HandlerFunc {
apiDowntimeStart := time.Unix(1723827600, 0)
apiDowntimeEnd := apiDowntimeStart.Add(time.Hour * 24 * 7)
relevantEndpoints := []string{
"/v2/tokeninfo",
"/v2/account",
Expand Down Expand Up @@ -105,18 +106,20 @@ func NotificationsEndpoint(httpClient *http.Client) echo.HandlerFunc {
}

now := time.Now()
if now.After(apiDowntimeStart) {
notifications = append(notifications, notification{
Type: notificationTypeInfo,
Header: "The Guild Wars 2 API is temporarily disabled",
Content: "The official Guild Wars 2 API is temporarily disabled until about a few days after the release of Janthir Wilds. During this time, it will not be possible to add new API Tokens or verify your accounts.",
})
} else if timeUntilDowntime := apiDowntimeStart.Sub(now); timeUntilDowntime <= (time.Hour * 24 * 3) {
notifications = append(notifications, notification{
Type: notificationTypeInfo,
Header: "The Guild Wars 2 API will be temporarily disabled shortly",
Content: "The official Guild Wars 2 API will be temporarily disabled in preparation for the release of Janthir Wilds. It will be kept disabled until about a few days after the release of Janthir Wilds. During this time, it will not be possible to add new API Tokens or verify your accounts.",
})
if now.Before(apiDowntimeEnd) {
if now.After(apiDowntimeStart) {
notifications = append(notifications, notification{
Type: notificationTypeWarning,
Header: "The Guild Wars 2 API is temporarily disabled",
Content: "The official Guild Wars 2 API is temporarily disabled until 2024-08-23. During this time, it will not be possible to add new API Tokens or to verify your accounts. Applications using GW2Auth might not work properly.\nSee: [Guild Wars 2 API Disabled from August 16-23](https://en-forum.guildwars2.com/topic/149447-guild-wars-2-api-disabled-from-august-16-23)",
})
} else if timeUntilDowntime := apiDowntimeStart.Sub(now); timeUntilDowntime <= (time.Hour * 24 * 3) {
notifications = append(notifications, notification{
Type: notificationTypeInfo,
Header: "The Guild Wars 2 API will be temporarily disabled shortly",
Content: "The official Guild Wars 2 API will be temporarily disabled in preparation for the release of Janthir Wilds. It will be kept disabled until 2024-08-23. During this time, it will not be possible to add new API Tokens or verify your accounts.\nSee: [Guild Wars 2 API Disabled from August 16-23](https://en-forum.guildwars2.com/topic/149447-guild-wars-2-api-disabled-from-august-16-23)",
})
}
}

return c.JSON(http.StatusOK, notifications)
Expand Down

0 comments on commit 9759b49

Please sign in to comment.