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 notificaitons on incoming Fez messages.
-
Required. Registers routes to the incoming router.
Declaration
Swift
func registerRoutes(_ app: Application) throws
-
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
-
globalNotificationHandler(_:
Asynchronous) 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
-
getActiveAnnouncementIDs(on:
Asynchronous) Declaration
Swift
func getActiveAnnouncementIDs(on req: Request) async throws -> [Int]
-
Declaration
Swift
func getNewAlertWordCounts(hash: [String : RESPValue]) -> [UserNotificationAlertwordData]
-
getModeratorNotifications(for:
Asynchronouson: ) 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?
-
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’sUserNotificationData
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)
-
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
-
getSingleAnnouncement(_:
Asynchronous) 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
-
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.
-
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.