Settings
final class Settings : Encodable
A (hopefully) thread-safe singleton that provides modifiable global settings.
-
Wraps settings properties, making them thread-safe. All access to the internalValue should be done through the wrapper because of the thread-safety thing.
See moreDeclaration
Swift
@propertyWrapper class SettingsValue<T> : Encodable where T : Encodable
-
Wraps settings properties, making them thread-safe. Contains methods for loading/storing values from a Redis hash. Use this for settings that should be database-backed.
See moreDeclaration
Swift
@propertyWrapper class StoredSettingsValue<T>: SettingsValue<T>, StoredSetting where T: Encodable & RESPValueConvertible
-
The shared instance for this singleton.
Declaration
Swift
static let shared: Settings
-
DispatchQueue to use for thread-safety synchronization.
Declaration
Swift
fileprivate static let settingsQueue: <<error type>>
-
The ID of the blocked user placeholder.
Declaration
Swift
@Settings .SettingsValue var blockedUserID: UUID { get set }
-
The ID of the FriendlyFez user placeholder.
Declaration
Swift
@Settings .SettingsValue var friendlyFezID: UUID { get set }
-
Sets a minimum access level to use the full server. Logged-in users who don’t have this access level will get errors for most routes, but won’t redirect to login.
Declaration
Swift
@Settings .StoredSettingsValue var minAccessLevel: UserAccessLevel { get set }
-
If TRUE, those that don’t have full server access (due to
minAccessLevel
) can create accounts, log in, and edit their user profile in an alternate, restricted UI. If FALSE, account creation is disabled and only users with certain elevated user access levels may log in.Declaration
Swift
@Settings .StoredSettingsValue var enablePreregistration: Bool { get set }
-
Each key-value pair identifies an application and a set of features disabled for that application. Either the app or the featureset may contain ‘.all’.
Declaration
Swift
@Settings .StoredSettingsValue var disabledFeatures: DisabledFeaturesGroup { get set }
-
The name of the onboard Wifi network. Delivered to cients in the notification endpoint.
Declaration
Swift
@Settings .StoredSettingsValue var shipWifiSSID: String { get set }
-
The URL to use when checking for automatic schedule updates. Genearlly a sched.com URL of the form
https://jococruise2024.sched.com/all.ics
Should always point to an URL that returns an iCalendar formatted file.Declaration
Swift
@Settings .StoredSettingsValue var scheduleUpdateURL: String { get set }
-
The maximum number of alt accounts per primary user account.
Declaration
Swift
@Settings .StoredSettingsValue var maxAlternateAccounts: Int { get set }
-
The maximum number of twartts allowed per request.
Declaration
Swift
@Settings .StoredSettingsValue var maximumTwarrts: Int { get set }
-
The maximum number of twartts allowed per request.
Declaration
Swift
@Settings .StoredSettingsValue var maximumForums: Int { get set }
-
The maximum number of twartts allowed per request.
Declaration
Swift
@Settings .StoredSettingsValue var maximumForumPosts: Int { get set }
-
Largest image we allow to be uploaded, in bytes.
Declaration
Swift
@Settings .StoredSettingsValue var maxImageSize: Int { get set }
-
How long a single user must wait between photostream uploads, in seconds.
Declaration
Swift
@Settings .StoredSettingsValue var photostreamUploadRateLimit: TimeInterval { get set }
-
The number of reports to trigger forum auto-quarantine.
Declaration
Swift
@Settings .StoredSettingsValue var forumAutoQuarantineThreshold: Int { get set }
-
The number of reports to trigger post/twarrt auto-quarantine.
Declaration
Swift
@Settings .StoredSettingsValue var postAutoQuarantineThreshold: Int { get set }
-
The number of reports to trigger user auto-quarantine.
Declaration
Swift
@Settings .StoredSettingsValue var userAutoQuarantineThreshold: Int { get set }
-
A Date set to midnight on the day the cruise ship leaves port, in the timezone the ship leaves from. Used by the Events Controller for date arithimetic. The default here should get overwritten in configure.swift. This is purely for convenience to set the start date via configure.swift. This setting should not be referenced anywhere. That’s what
cruiseStartDate()
below is for. This must align with cruiseStartDayOfWeek set immediately below.Declaration
Swift
@Settings .SettingsValue var cruiseStartDateComponents: DateComponents { get set }
-
The day of week when the cruise embarks, expressed as number as Calendar’s .weekday uses them: Range 1…7, Sunday == 1. Doing DateComponents(year: 2024, month: 3, day: 9).weekday! didnt work here. Hmm….
Declaration
Swift
@Settings .SettingsValue var cruiseStartDayOfWeek: Int { get set }
-
The length in days of the cruise, includes partial days. A cruise that embarks on Saturday and returns the next Saturday should have a value of 8.
Declaration
Swift
@Settings .SettingsValue var cruiseLengthInDays: Int { get set }
-
TimeZone representative of where we departed port from. This should equal the TZ that Sched.com uses to list Events.
Declaration
Swift
@Settings .SettingsValue var portTimeZone: TimeZone { get set }
-
Struct representing a set of TimeZoneChange’s for this cruise. This setting can then be referenced elsewhere in the application.
Declaration
Swift
@Settings .SettingsValue var timeZoneChanges: TimeZoneChangeSet { get set }
-
Number of minutes before an event to trigger notifications. Some day this should be set per-user based on their preferences. But since we don’t have the concept of “User Settings” yet we set a sane default instead. This is a StoredSettingsValue so that it can be modified in real time. This is a Double because that’s what most range comparison operations desire. Though it does make this a bit more complex on the Server Settings views and [Site]AdminController because we expose them as Ints to the UI. This is to prevent anyone from using truly whacky values.
Declaration
Swift
@Settings .StoredSettingsValue var upcomingEventNotificationSeconds: Double { get set }
-
Number of seconds after an upcoming event starts to no longer consider it happening. The desired default value means 5 minutes after an event starts notifications/banners will stop. However at this time, the AlertController does honor this and cycles the UserNotificationData.nextFollowedEventTime immediately afterward. Until that changes, this should be 0. This also might entirely go away? Here for consistency throughout the app, but possibly irrelevant.
Declaration
Swift
@Settings .SettingsValue var upcomingEventPastSeconds: Double { get set }
-
Configuration of the upcoming event notifications.
Declaration
Swift
@Settings .StoredSettingsValue var upcomingEventNotificationSetting: EventNotificationSetting { get set }
-
Configuration of the upcoming LFG notifications.
Declaration
Swift
@Settings .StoredSettingsValue var upcomingLFGNotificationSetting: EventNotificationSetting { get set }
-
Enable Late Day Flip where the site UI shows the next days schedule after 3:00AM rather than after Midnight. For example, with this setting enabled opening the schedule at 2:00AM on Thursday will show you Wednesday’s schedule by default. If this setting is disabled, at 2:00AM on Thursday you would see Thursdays schedule by default.
Declaration
Swift
@Settings .SettingsValue var enableLateDayFlip: Bool { get set }
-
The set of image file types that we can parse with the GD library. I believe GD hard-codes these values on install based on what ./configure finds. If our server app is moved to a new machine after it’s built, the valid input types will likely differ.
Declaration
Swift
@Settings .SettingsValue var validImageInputTypes: [String] { get set }
-
The set of image file types that we can create with the GD library. I believe GD hard-codes these values on install based on what ./configure finds. If our server app is moved to a new machine after it’s built, the valid input types will likely differ.
Declaration
Swift
@Settings .SettingsValue var validImageOutputTypes: [String] { get set }
-
If FALSE, animated images are converted into static jpegs upon upload. Does not affect already uploaded images.
Declaration
Swift
@Settings .StoredSettingsValue var allowAnimatedImages: Bool { get set }
-
Set the size of automatically generated image thumbnails. This is the height value in pixels.
Declaration
Swift
@Settings .SettingsValue var imageThumbnailSize: Int { get set }
-
Root dir for files used by Swiftarr. The front-end’s CSS, JS, static image files, all the Leaf templates are in here, as are all the seeds files used for database migrations by the backend.. The Resources and Seeds dirs get copied into this dir from the root of the git repo by the build system.
Declaration
Swift
@Settings .SettingsValue var staticFilesRootPath: URL { get set }
-
User uploaded images will be inside this dir.
Declaration
Swift
@Settings .SettingsValue var userImagesRootPath: URL { get set }
-
This is the EXTERNALLY VISIBLE URL for the server. If a user asks “What should I type into my browser to get to Twitarr?” you could tell them this. The server uses this to generate URLs referring to itself. Be wary of using this for web UI URLs; it could cause cross-origin problems in browsers.
Declaration
Swift
@Settings .SettingsValue var canonicalServerURLComponents: URLComponents { get set }
-
Canonical hostnames for the Twitarr server. The server uses this to find links to itself inside posts.
Declaration
Swift
@Settings .SettingsValue var canonicalHostnames: [String] { get set }
-
Base URL that the web UI uses to call API level endpoints.
Declaration
Swift
@Settings .SettingsValue var apiUrlComponents: URLComponents { get set }
-
Path to the ‘admin’ directory, inside the ‘seeds’ directory. Certain seed files can be upload by admin here, and ingested while the server is running.
Declaration
Swift
var adminDirectoryPath: URL { get }
-
Path to the ‘admin’ directory, inside the ‘seeds’ directory. Certain seed files can be upload by admin here, and ingested while the server is running.
Declaration
Swift
var seedsDirectoryPath: URL { get }
-
Declaration
Swift
func cruiseStartDate() -> Date
-
Calendar to use for calculating dates (like what day it is). The returned calendar has the correct timezone for the given date.
Declaration
Swift
func calendarForDate(_ date: Date) -> Calendar
-
Declaration
Swift
func getPortCalendar() -> Calendar
-
Declaration
Swift
func getDateInCruiseWeek() -> Date
-
Declaration
Swift
func getCurrentFilterDate() -> Date
-
Declaration
Swift
func getScheduleReferenceDate(_ settingType: EventNotificationSetting) -> Date
-
readStoredSettings(app:
Asynchronous) Declaration
Swift
func readStoredSettings(app: Application) async throws
-
storeSettings(on:
Asynchronous) Declaration
Swift
func storeSettings(on req: Request) async throws