AlertController

struct AlertController : APIRouteCollection

The collection of alert endpoints, with routes for: - getting server time,, - getting public address-style announcements,, - getting notifications on alertwords, - getting notifications on incoming Fez messages.

Hashtags

  • getHashtagsHandler(_:) Asynchronous

    GET /api/v3/notification/hashtags

    Retrieve info on hashtags that have been used.

    Throws

    A 5xx response should be reported as a likely bug, please and thank you.

    Declaration

    Swift

    func getHashtagsHandler(_ req: Request) async throws -> [String]

    Parameters

    searchString

    Partial Hashtag string. Must have at least 1 character.

    Return Value

Notifications

  • GET /api/v3/notification/global GET /api/v3/notification/user

    Retrieve info on the number of each type of notification supported by Swiftarr.

    Throws

    A 5xx response should be reported as a likely bug, please and thank you.

    Declaration

    Swift

    func globalNotificationHandler(_ req: Request) async throws -> UserNotificationData

    Return Value

    UserNotificationData

  • GET /api/v3/notification/log

    Returns the logged-in user’s history of pushed notifications, most recent first. Lets a client recover a notification it missed (e.g. a push the user swiped away before reading).

    URL Query Parameters:

    • start=INT - Index into the user’s notification history to start from. Default is 0.
    • limit=INT - Max number of entries to return. Default is 50.

    Throws

    A 5xx response should be reported as a likely bug, please and thank you.

    See more

    Declaration

    Swift

    func notificationLogHandler(_ req: Request) async throws -> Paginated<NotificationLogData>
  • Declaration

    Swift

    func getActiveAnnouncementIDs(on req: Request) async throws -> [Int]
  • Declaration

    Swift

    func getNewAlertWordCounts(hash: [String : RESPValue]) -> [UserNotificationAlertwordData]
  • Returns a ModeratorNotificationData structure containing counts for open reports, seamails to @moderator with unread messages, and (if user is in TwitarrTeam) seamails to @TwitarrTeam with unread messages. If the user is not a moderator, returns nil.

    Declaration

    Swift

    func getModeratorNotifications(for user: UserCacheData, on req: Request) async throws -> UserNotificationData
    	.ModeratorNotificationData?
  • Returns a CommunitySupportNotificationData structure containing counts of open Community Support reports, seamails to @CommunitySupport with unread messages, and unread @CommunitySupport forum mentions. Returns nil unless the user holds the Community Support role or is TwitarrTeam or above–this has to be separate from getModeratorNotifications, which is hard-gated on moderator access.

    Declaration

    Swift

    func getCommunitySupportNotifications(for user: UserCacheData, on req: Request) async throws -> UserNotificationData
    	.CommunitySupportNotificationData?
  • WS /api/v3/notification/socket

    Creates a notification socket for the user. The client of this socket will receive SocketNotificationData updates, generally when an event happens that would change a value in the user’s UserNotificationData struct.

    This socket only sends SocketNotificationData messages from the server to the client; there are no client-initiated messages defined for this socket.

    Declaration

    Swift

    func createNotificationSocket(_ req: Request, _ ws: WebSocket) async

Announcements

  • createAnnouncement(_:) Asynchronous

    POST /api/v3/notification/announcement/create

    Create a new announcement. Requires TwitarrTeam access and above. When a new announcement is created the notification endpoints will start indicating the new announcement to all users.

    Declaration

    Swift

    func createAnnouncement(_ req: Request) async throws -> HTTPStatus

    Parameters

    requestBody

    Return Value

    HTTPStatus 201 on success.

  • getAnnouncements(_:) Asynchronous

    GET /api/v3/notification/announcements

    Returns all active announcements, sorted by creation time, by default.

    URL Query Parameters

    • ?inactives=true Also return expired and deleted announcements. TwitarrTeam and above only.

    The purpose of the inactives flag is to allow for finding an expired announcement and re-activating it by changing its expire time. Doing so does not re-alert users who have already read it.

    Declaration

    Swift

    func getAnnouncements(_ req: Request) async throws -> [AnnouncementData]

    Return Value

    Array of AnnouncementData

  • GET /api/v3/notification/announcement/ID

    Returns a single announcement, identified by its ID. TwitarrTeam and above only. Others should just use /api/v3/notification/announcements. Will return AnnouncementData for deleted announcements.

    Announcements shouldn’t be large, and there shouldn’t be many of them active at once (Less than 1KB each, if there’s more than 5 active at once people likely won’t read them). This endpoint really exists to support admins editing announcements.

    Throws

    403 error if the user doesn’t have TwitarrTeam or higher access. 404 if no announcement with the given ID is found.

    Declaration

    Swift

    func getSingleAnnouncement(_ req: Request) async throws -> AnnouncementData

    Parameters

    announcementID

    The announcement to find

    Return Value

    AnnouncementData

  • editAnnouncement(_:) Asynchronous

    POST /api/v3/notification/announcement/ID/edit

    Edits an existing announcement. Editing a deleted announcement will un-delete it. Editing an announcement does not change any user’s notification status for that announcement: if a user has seen the announcement already, editing it will not cause the user to be notified that they should read it again.

    Throws

    403 error if the user is not permitted to edit.

    Declaration

    Swift

    func editAnnouncement(_ req: Request) async throws -> AnnouncementData

    Parameters

    announcementID

    The announcement to edit. Must exist.

    requestBody

    Return Value

    The updated AnnouncementCreateData

  • deleteAnnouncement(_:) Asynchronous

    POST /api/v3/notification/announcement/ID/delete DELETE /api/v3/notification/announcement/ID

    Deletes an existing announcement. Editing a deleted announcement will un-delete it TwitarrTeam and above only.

    Throws

    403 error if the user is not permitted to delete.

    Declaration

    Swift

    func deleteAnnouncement(_ req: Request) async throws -> HTTPStatus

    Parameters

    announcementIDParam

    The announcement to delete.

    Return Value

    204 NoContent on success.

Daily Themes

  • getDailyThemes(_:) Asynchronous

    GET /api/v3/notification/dailythemes

    Returns information about all the daily themes currently registered.

    Throws

    403 error if the user is not permitted to delete.

    Declaration

    Swift

    func getDailyThemes(_ req: Request) async throws -> [DailyThemeData]

    Return Value

    An array of DailyThemeData on success.