Enable reblog with visibility on Pleroma
This commit is contained in:
parent
95e120afd6
commit
d141ed7d03
|
@ -10,8 +10,11 @@ import Foundation
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
|
|
||||||
struct InstanceFeatures {
|
struct InstanceFeatures {
|
||||||
|
private static let pleromaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; Pleroma (.*)\\)")
|
||||||
|
|
||||||
private(set) var instanceType = InstanceType.mastodon
|
private(set) var instanceType = InstanceType.mastodon
|
||||||
private(set) var version: Version?
|
private(set) var version: Version?
|
||||||
|
private(set) var pleromaVersion: Version?
|
||||||
private(set) var maxStatusChars = 500
|
private(set) var maxStatusChars = 500
|
||||||
|
|
||||||
var localOnlyPosts: Bool {
|
var localOnlyPosts: Bool {
|
||||||
|
@ -43,7 +46,8 @@ struct InstanceFeatures {
|
||||||
}
|
}
|
||||||
|
|
||||||
var reblogVisibility: Bool {
|
var reblogVisibility: Bool {
|
||||||
instanceType == .mastodon && hasVersion(2, 8, 0)
|
(instanceType == .mastodon && hasVersion(2, 8, 0))
|
||||||
|
|| (instanceType == .pleroma && hasVersion(2, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
mutating func update(instance: Instance, nodeInfo: NodeInfo?) {
|
mutating func update(instance: Instance, nodeInfo: NodeInfo?) {
|
||||||
|
@ -62,6 +66,10 @@ struct InstanceFeatures {
|
||||||
|
|
||||||
version = Version(string: ver)
|
version = Version(string: ver)
|
||||||
|
|
||||||
|
if let match = InstanceFeatures.pleromaVersionRegex.firstMatch(in: ver, range: NSRange(location: 0, length: ver.utf16.count)) {
|
||||||
|
pleromaVersion = Version(string: (ver as NSString).substring(with: match.range(at: 1)))
|
||||||
|
}
|
||||||
|
|
||||||
maxStatusChars = instance.maxStatusCharacters ?? 500
|
maxStatusChars = instance.maxStatusCharacters ?? 500
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +103,8 @@ extension InstanceFeatures {
|
||||||
|
|
||||||
extension InstanceFeatures {
|
extension InstanceFeatures {
|
||||||
struct Version: Equatable, Comparable {
|
struct Version: Equatable, Comparable {
|
||||||
|
private static let regex = try! NSRegularExpression(pattern: "^(\\d+)\\.(\\d+)\\.(\\d+).*$")
|
||||||
|
|
||||||
let major: Int
|
let major: Int
|
||||||
let minor: Int
|
let minor: Int
|
||||||
let patch: Int
|
let patch: Int
|
||||||
|
@ -106,8 +116,7 @@ extension InstanceFeatures {
|
||||||
}
|
}
|
||||||
|
|
||||||
init?(string: String) {
|
init?(string: String) {
|
||||||
let regex = try! NSRegularExpression(pattern: "^(\\d+)\\.(\\d+)\\.(\\d+).*$")
|
guard let match = Version.regex.firstMatch(in: string, range: NSRange(location: 0, length: string.utf16.count)),
|
||||||
guard let match = regex.firstMatch(in: string, range: NSRange(location: 0, length: string.utf16.count)),
|
|
||||||
match.numberOfRanges == 4 else {
|
match.numberOfRanges == 4 else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue