APIRouteCollection

protocol APIRouteCollection : APICollection

Guards

Notification Management

  • addNotifications(users:type:info:creatorID:on:) Extension method, asynchronous

    Declaration

    Swift

    func addNotifications(users: [UUID], type: NotificationType, info: String, creatorID: UUID? = nil, on req: Request)
    	async throws
  • Declaration

    Swift

    func bookkeepUserAddedToChat(
    	req: Request,
    	msgID: UUID,
    	chatType: FezType,
    	users: [UUID],
    	group: inout ThrowingTaskGroup<Void, Error>
    ) -> [UUID]
  • Declaration

    Swift

    func bookkeepNewChatMessage(
    	req: Request,
    	msgID: UUID,
    	chatType: FezType,
    	users: [UUID],
    	group: inout ThrowingTaskGroup<Void, Error>,
    	creatorID: UUID? = nil
    ) -> [UUID]
  • Declaration

    Swift

    func subtractNotifications(users: [UUID], type: NotificationType, subtractCount: Int = 1, on req: Request)
    	async throws
  • deleteFezNotifications(userIDs:fez:on:) Extension method, asynchronous

    Declaration

    Swift

    func deleteFezNotifications(userIDs: [UUID], fez: FriendlyFez, on req: Request) async throws
  • markNotificationViewed(user:type:on:) Extension method, asynchronous

    Declaration

    Swift

    func markNotificationViewed(user: UserCacheData, type: NotificationType, on req: Request) async throws
  • markNotificationViewed(for:type:on:) Extension method, asynchronous

    Declaration

    Swift

    func markNotificationViewed(for users: [UserCacheData], type: NotificationType, on req: Request) async throws
  • storeNextFollowedEvent(userID:on:) Extension method, asynchronous

    Declaration

    Swift

    func storeNextFollowedEvent(userID: UUID, on req: Request) async throws -> (Date, UUID)?
  • storeNextJoinedAppointment(userID:on:) Extension method, asynchronous

    Declaration

    Swift

    func storeNextJoinedAppointment(userID: UUID, on req: Request) async throws -> (Date, UUID)?
  • loadImageFromData(_:) Extension method

    Loads an image from data and returns the image, its type, and original orientation.

    Declaration

    Swift

    static func loadImageFromData(_ data: Data) throws -> (image: GDImage, type: ImportableFormat, orientation: Int32)

    Parameters

    data

    The image data to load

    Return Value

    A tuple containing the loaded image, its format type, and original orientation value

  • Creates a thumbnail from an image with proper orientation handling and exports it. Silently skips thumbnail creation if resize fails (returns nil), matching the original behavior.

    Throws

    Errors from export or file write operations

    Declaration

    Swift

    static func createThumbnail(from image: GDImage, preserving orientation: Int32, as outputType: ImportableFormat, to thumbPath: URL, on req: Request) throws

    Parameters

    image

    The source image to create a thumbnail from

    orientation

    The original orientation value to preserve

    outputType

    The format to export the thumbnail as

    thumbPath

    The file path where the thumbnail should be saved

    req

    The incoming Request, used for logging

  • processImages(_:usage:maxImages:on:) Extension method, asynchronous

    Takes an an array of ImageUploadData as input. Some of the input elements may be new image Data that needs procssing; some of the input elements may refer to already-processed images in our image store. Once all the ImageUploadData elements are processed, returns a [String] containing the filenames where al the images are stored. The use case here is for editing existing content with image attachments in a way that prevents re-uploading of photos that are already on the server.

    • req: The incoming Request, on which this processing must run.

    Declaration

    Swift

    func processImages(_ images: [ImageUploadData], usage: ImageUsage, maxImages: Int = 4, on req: Request) async throws -> [String]

    Parameters

    images

    The images in ImageUploadData format.

    usage

    The type of model using the image content.

    maxImages

    Maximum number of images allowed. Defaults to 4 for backward compatibility.

    Return Value

    The generated names of the stored files.

  • processImage(data:usage:on:) Extension method, asynchronous

    Takes an optional image in Data form as input, produces full and thumbnail JPEG vrsions, places both the thumbnail and full image in their respective directories, and returns the generated name of the file on success, an empty string otherwise.

    • req: The incoming Request, on which this processing must run.

    Declaration

    Swift

    func processImage(data: Data?, usage: ImageUsage, on req: Request) async throws -> String?

    Parameters

    data

    The uploaded image in Data format.

    usage

    The type of model using the image content.

    Return Value

    The generated name of the stored file, or nil.

  • regenerateThumbnail(for:on:) Extension method, asynchronous

    Declaration

    Swift

    func regenerateThumbnail(for imageSource: URL, on req: Request) async throws
  • archiveImage(_:on:) Extension method

    Archives an image that is no longer needed other than for accountability tracking, by removing the full-sized image and moving the thumbnail into the archive/ subdirectory of the provided base image directory.

    This is a synchronous operation, until such time as we can use SwiftNIO 2’s asynchronous file I/O.

    Declaration

    Swift

    func archiveImage(_ image: String, on req: Request)

    Parameters

    image

    The filename of the image.

    imageDir

    The base image directory path for the image’s context.