APIRouteCollection

protocol APIRouteCollection

Guards

Notification Management

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

    Declaration

    Swift

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

    Swift

    func handleUnreadMessage(
    	req: Request,
    	msgID: UUID,
    	inbox: Request.Redis.MailInbox,
    	users: [UUID],
    	group: inout ThrowingTaskGroup<Void, Error>
    ) -> [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
  • storeNextFollowedEvent(userID:on:) Extension method, asynchronous

    Declaration

    Swift

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

    Declaration

    Swift

    func storeNextJoinedLFG(userID: UUID, on req: Request) async throws -> (Date, UUID)?
  • Returns the file system path for the given image filename. Makes sure all image directories in the path exist.

    Currently, this fn returns paths in the form: /images///.jpg where “xx” is the first 2 characters of the filename.

    Declaration

    Swift

    func getImagePath(for image: String, format: String? = nil, usage: ImageUsage, size: ImageSizeGroup, on req: Request) throws -> URL
  • processImages(_:usage: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, on req: Request) async throws -> [String]

    Parameters

    images

    The images in ImageUploadData format.

    usage

    The type of model using the image content.

    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.

  • 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.