mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
NSE user agent support (#1507)
This commit is contained in:
@@ -29,6 +29,9 @@ struct InfoPlistReader {
|
||||
/// Info.plist reader on the bundle object that contains the current executable.
|
||||
static let main = InfoPlistReader(bundle: .main)
|
||||
|
||||
/// Info.plist reader on the bundle object that contains the main app executable.
|
||||
static let app = InfoPlistReader(bundle: .app)
|
||||
|
||||
private let bundle: Bundle
|
||||
|
||||
/// Initializer
|
||||
|
||||
@@ -22,13 +22,13 @@ import DeviceKit
|
||||
#endif
|
||||
|
||||
final class UserAgentBuilder {
|
||||
class func makeASCIIUserAgent() -> String? {
|
||||
makeUserAgent()?.asciified()
|
||||
class func makeASCIIUserAgent() -> String {
|
||||
makeUserAgent()?.asciified() ?? "unknown"
|
||||
}
|
||||
|
||||
private class func makeUserAgent() -> String? {
|
||||
let clientName = InfoPlistReader.main.bundleDisplayName
|
||||
let clientVersion = InfoPlistReader.main.bundleShortVersionString
|
||||
let clientName = InfoPlistReader.app.bundleDisplayName
|
||||
let clientVersion = InfoPlistReader.app.bundleShortVersionString
|
||||
|
||||
#if os(iOS)
|
||||
return String(format: "%@/%@ (%@; iOS %@; Scale/%0.2f)",
|
||||
|
||||
@@ -114,7 +114,7 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
.basePath(path: baseDirectory.path)
|
||||
.username(username: credentials.userID)
|
||||
.homeserverUrl(url: credentials.restorationToken.session.homeserverUrl)
|
||||
.userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent() ?? "unknown")
|
||||
.userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent())
|
||||
.serverVersions(versions: ["v1.0", "v1.1", "v1.2", "v1.3", "v1.4", "v1.5"]) // FIXME: Quick and dirty fix for stopping version requests on startup https://github.com/matrix-org/matrix-rust-sdk/pull/1376
|
||||
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user