Tweak instance type matching, add iceshrimp
This commit is contained in:
parent
6c0564e0ee
commit
297af7b905
|
@ -11,8 +11,7 @@ import Combine
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
|
|
||||||
public class InstanceFeatures: ObservableObject {
|
public class InstanceFeatures: ObservableObject {
|
||||||
private static let pleromaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; pleroma (.*)\\)", options: .caseInsensitive)
|
private static let pleromaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; (pleroma|akkoma) (.*)\\)", options: .caseInsensitive)
|
||||||
private static let akkomaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; akkoma (.*)\\)", options: .caseInsensitive)
|
|
||||||
|
|
||||||
private let _featuresUpdated = PassthroughSubject<Void, Never>()
|
private let _featuresUpdated = PassthroughSubject<Void, Never>()
|
||||||
public var featuresUpdated: some Publisher<Void, Never> { _featuresUpdated }
|
public var featuresUpdated: some Publisher<Void, Never> { _featuresUpdated }
|
||||||
|
@ -179,23 +178,20 @@ public class InstanceFeatures: ObservableObject {
|
||||||
mastoVersion = Version(string: ver)
|
mastoVersion = Version(string: ver)
|
||||||
}
|
}
|
||||||
instanceType = .mastodon(.hometown(hometownVersion), mastoVersion)
|
instanceType = .mastodon(.hometown(hometownVersion), mastoVersion)
|
||||||
} else if ver.contains("pleroma") {
|
} else if let match = InstanceFeatures.pleromaVersionRegex.firstMatch(in: ver, range: NSRange(location: 0, length: ver.utf16.count)) {
|
||||||
var pleromaVersion: Version?
|
var pleromaVersion: Version?
|
||||||
if let match = InstanceFeatures.pleromaVersionRegex.firstMatch(in: ver, range: NSRange(location: 0, length: ver.utf16.count)) {
|
let type = (ver as NSString).substring(with: match.range(at: 1))
|
||||||
pleromaVersion = Version(string: (ver as NSString).substring(with: match.range(at: 1)))
|
pleromaVersion = Version(string: (ver as NSString).substring(with: match.range(at: 2)))
|
||||||
}
|
if type == "akkoma" {
|
||||||
|
instanceType = .pleroma(.akkoma(pleromaVersion))
|
||||||
|
} else {
|
||||||
instanceType = .pleroma(.vanilla(pleromaVersion))
|
instanceType = .pleroma(.vanilla(pleromaVersion))
|
||||||
} else if ver.contains("akkoma") {
|
|
||||||
var akkomaVersion: Version?
|
|
||||||
if let match = InstanceFeatures.akkomaVersionRegex.firstMatch(in: ver, range: NSRange(location: 0, length: ver.utf16.count)) {
|
|
||||||
akkomaVersion = Version(string: (ver as NSString).substring(with: match.range(at: 1)))
|
|
||||||
}
|
}
|
||||||
instanceType = .pleroma(.akkoma(akkomaVersion))
|
|
||||||
} else if ver.contains("pixelfed") {
|
} else if ver.contains("pixelfed") {
|
||||||
instanceType = .pixelfed
|
instanceType = .pixelfed
|
||||||
} else if nodeInfo?.software.name == "gotosocial" {
|
} else if nodeInfo?.software.name == "gotosocial" {
|
||||||
instanceType = .gotosocial
|
instanceType = .gotosocial
|
||||||
} else if ver.contains("firefish") || ver.contains("calckey") {
|
} else if ver.contains("firefish") || ver.contains("iceshrimp") || ver.contains("calckey") {
|
||||||
instanceType = .firefish(nodeInfo?.software.version)
|
instanceType = .firefish(nodeInfo?.software.version)
|
||||||
} else {
|
} else {
|
||||||
instanceType = .mastodon(.vanilla, Version(string: ver))
|
instanceType = .mastodon(.vanilla, Version(string: ver))
|
||||||
|
|
Loading…
Reference in New Issue