diff --git a/DB/Sources/DB/Entities/Identity.swift b/DB/Sources/DB/Entities/Identity.swift index 82994d2..97b2d34 100644 --- a/DB/Sources/DB/Entities/Identity.swift +++ b/DB/Sources/DB/Entities/Identity.swift @@ -24,6 +24,8 @@ public extension Identity { public let streamingAPI: URL public let title: String public let thumbnail: URL? + public let version: String + public let maxTootChars: Int? } struct Account: Codable, Hashable { diff --git a/DB/Sources/DB/Identity/IdentityDatabase+Migration.swift b/DB/Sources/DB/Identity/IdentityDatabase+Migration.swift index 5277481..3ac2ef2 100644 --- a/DB/Sources/DB/Identity/IdentityDatabase+Migration.swift +++ b/DB/Sources/DB/Identity/IdentityDatabase+Migration.swift @@ -9,9 +9,11 @@ extension IdentityDatabase { migrator.registerMigration("0.1.0") { db in try db.create(table: "instance", ifNotExists: true) { t in t.column("uri", .text).primaryKey(onConflict: .replace) - t.column("streamingAPI", .text) - t.column("title", .text) + t.column("streamingAPI", .text).notNull() + t.column("title", .text).notNull() t.column("thumbnail", .text) + t.column("version", .text).notNull() + t.column("maxTootChars", .integer) } try db.create(table: "identityRecord", ifNotExists: true) { t in diff --git a/DB/Sources/DB/Identity/IdentityDatabase.swift b/DB/Sources/DB/Identity/IdentityDatabase.swift index a95568f..ed4f1a1 100644 --- a/DB/Sources/DB/Identity/IdentityDatabase.swift +++ b/DB/Sources/DB/Identity/IdentityDatabase.swift @@ -70,7 +70,9 @@ public extension IdentityDatabase { uri: instance.uri, streamingAPI: instance.urls.streamingApi, title: instance.title, - thumbnail: instance.thumbnail) + thumbnail: instance.thumbnail, + version: instance.version, + maxTootChars: instance.maxTootChars) .save($0) try IdentityRecord .filter(IdentityRecord.Columns.id == id) diff --git a/Localizations/Localizable.strings b/Localizations/Localizable.strings index e0a6a92..29fd865 100644 --- a/Localizations/Localizable.strings +++ b/Localizations/Localizable.strings @@ -144,6 +144,7 @@ "preferences.notification-types.reblog" = "Reblog"; "preferences.notification-types.mention" = "Mention"; "preferences.notification-types.poll" = "Poll"; +"preferences.notification-types.status" = "Status"; "preferences.muted-users" = "Muted Users"; "preferences.startup-and-syncing" = "Startup and Syncing"; "preferences.startup-and-syncing.home-timeline" = "Home timeline"; diff --git a/Mastodon/Sources/Mastodon/Entities/Instance.swift b/Mastodon/Sources/Mastodon/Entities/Instance.swift index 080df19..5ae3e03 100644 --- a/Mastodon/Sources/Mastodon/Entities/Instance.swift +++ b/Mastodon/Sources/Mastodon/Entities/Instance.swift @@ -27,4 +27,5 @@ public struct Instance: Codable, Hashable { public let stats: Stats public let thumbnail: URL? public let contactAccount: Account? + public let maxTootChars: Int? } diff --git a/Mastodon/Sources/Mastodon/Entities/PushSubscription.swift b/Mastodon/Sources/Mastodon/Entities/PushSubscription.swift index f2523c2..83e241a 100644 --- a/Mastodon/Sources/Mastodon/Entities/PushSubscription.swift +++ b/Mastodon/Sources/Mastodon/Entities/PushSubscription.swift @@ -9,6 +9,7 @@ public struct PushSubscription: Codable { public var reblog: Bool public var mention: Bool @DecodableDefault.True public var poll: Bool + @DecodableDefault.True public var status: Bool } public let endpoint: URL @@ -22,5 +23,6 @@ public extension PushSubscription.Alerts { favourite: true, reblog: true, mention: true, - poll: DecodableDefault.True()) + poll: DecodableDefault.True(), + status: DecodableDefault.True()) } diff --git a/MastodonAPI/Sources/MastodonAPI/Endpoints/PushSubscriptionEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/PushSubscriptionEndpoint.swift index 37376e1..39d51a1 100644 --- a/MastodonAPI/Sources/MastodonAPI/Endpoints/PushSubscriptionEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/PushSubscriptionEndpoint.swift @@ -47,7 +47,8 @@ extension PushSubscriptionEndpoint: Endpoint { "favourite": alerts.favourite, "reblog": alerts.reblog, "mention": alerts.mention, - "poll": alerts.poll + "poll": alerts.poll, + "status": alerts.status ]]] case let .update(alerts): return ["data": @@ -56,7 +57,8 @@ extension PushSubscriptionEndpoint: Endpoint { "favourite": alerts.favourite, "reblog": alerts.reblog, "mention": alerts.mention, - "poll": alerts.poll]]] + "poll": alerts.poll, + "status": alerts.status]]] default: return nil } } diff --git a/Views/NotificationTypesPreferencesView.swift b/Views/NotificationTypesPreferencesView.swift index dad8ea8..f8f97fb 100644 --- a/Views/NotificationTypesPreferencesView.swift +++ b/Views/NotificationTypesPreferencesView.swift @@ -18,6 +18,8 @@ struct NotificationTypesPreferencesView: View { isOn: $viewModel.pushSubscriptionAlerts.mention) Toggle("preferences.notification-types.poll", isOn: $viewModel.pushSubscriptionAlerts.poll) + Toggle("preferences.notification-types.status", + isOn: $viewModel.pushSubscriptionAlerts.status) } .navigationTitle("preferences.notification-types") .alertItem($viewModel.alertItem)