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.
-
Required. Registers routes to the incoming router.
Declaration
Swift
func registerRoutes(_ app: Application) throws
-
getHashtagsHandler(_:Asynchronous) GET /api/v3/notification/hashtagsRetrieve 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
searchStringPartial Hashtag string. Must have at least 1 character.
Return Value
-
globalNotificationHandler(_:Asynchronous) GET /api/v3/notification/globalGET /api/v3/notification/userRetrieve 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 -> UserNotificationDataReturn 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? -
createNotificationSocket(_:Asynchronous_: ) WS /api/v3/notification/socketCreates a notification socket for the user. The client of this socket will receive
SocketNotificationDataupdates, generally when an event happens that would change a value in the user’sUserNotificationDatastruct.This socket only sends
SocketNotificationDatamessages 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
-
createAnnouncement(_:Asynchronous) POST /api/v3/notification/announcement/createCreate 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 -> HTTPStatusParameters
requestBodyReturn Value
HTTPStatus201 on success. -
getAnnouncements(_:Asynchronous) GET /api/v3/notification/announcementsReturns all active announcements, sorted by creation time, by default.
URL Query Parameters
?inactives=trueAlso 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/IDReturns 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 -> AnnouncementDataParameters
announcementIDThe announcement to find
Return Value
-
editAnnouncement(_:Asynchronous) POST /api/v3/notification/announcement/ID/editEdits 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 -> AnnouncementDataParameters
announcementIDThe announcement to edit. Must exist.
requestBodyReturn Value
The updated
AnnouncementCreateData -
deleteAnnouncement(_:Asynchronous) POST /api/v3/notification/announcement/ID/deleteDELETE /api/v3/notification/announcement/IDDeletes 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 -> HTTPStatusParameters
announcementIDParamThe announcement to delete.
Return Value
204 NoContent on success.
-
getDailyThemes(_:Asynchronous) GET /api/v3/notification/dailythemesReturns 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
DailyThemeDataon success.
View on GitHub