From bac272a2db0d0b9c4afcb6cb7e401f471703993f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 10 May 2023 10:45:08 -0400 Subject: [PATCH] Detect gotosocial and calckey instances --- .../Sources/InstanceFeatures/InstanceFeatures.swift | 9 +++++++++ Tusker/Views/Toast/ToastConfiguration.swift | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift b/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift index cdbcf5ad..a146f89e 100644 --- a/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift +++ b/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift @@ -120,8 +120,11 @@ public class InstanceFeatures: ObservableObject { public func update(instance: Instance, nodeInfo: NodeInfo?) { let ver = instance.version.lowercased() + // check glitch first b/c it still reports "mastodon" as the software in nodeinfo if ver.contains("glitch") { instanceType = .mastodon(.glitch, Version(string: ver)) + } else if nodeInfo?.software.name == "mastodon" { + instanceType = .mastodon(.vanilla, Version(string: ver)) } else if nodeInfo?.software.name == "hometown" { var mastoVersion: Version? var hometownVersion: Version? @@ -157,6 +160,10 @@ public class InstanceFeatures: ObservableObject { instanceType = .pleroma(.akkoma(akkomaVersion)) } else if ver.contains("pixelfed") { instanceType = .pixelfed + } else if nodeInfo?.software.name == "gotosocial" { + instanceType = .gotosocial + } else if ver.contains("calckey") { + instanceType = .calckey(nodeInfo?.software.version) } else { instanceType = .mastodon(.vanilla, Version(string: ver)) } @@ -194,6 +201,8 @@ extension InstanceFeatures { case mastodon(MastodonType, Version?) case pleroma(PleromaType) case pixelfed + case gotosocial + case calckey(String?) var isMastodon: Bool { if case .mastodon(_, _) = self { diff --git a/Tusker/Views/Toast/ToastConfiguration.swift b/Tusker/Views/Toast/ToastConfiguration.swift index d50852f3..581ef236 100644 --- a/Tusker/Views/Toast/ToastConfiguration.swift +++ b/Tusker/Views/Toast/ToastConfiguration.swift @@ -149,6 +149,13 @@ private func captureError(_ error: Client.Error, in mastodonController: Mastodon } case .pixelfed: event.tags!["instance_type"] = "pixelfed" + case .gotosocial: + event.tags!["instance_type"] = "gotosocial" + case .calckey(let calckeyVersion): + event.tags!["instance_type"] = "calckey" + if let calckeyVersion { + event.tags!["calckey_version"] = calckeyVersion + } } SentrySDK.capture(event: event)