mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
NSE user agent support (#1507)
This commit is contained in:
parent
a11325bcb4
commit
8188fd2d2a
@ -148,6 +148,7 @@
|
||||
339D847497C51F2B36E3666B /* FixedIconSizeLabelStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3518637393394901BF5BFAC3 /* FixedIconSizeLabelStyle.swift */; };
|
||||
33CAC1226DFB8B5D8447D286 /* GZIP in Frameworks */ = {isa = PBXBuildFile; productRef = 1BCD21310B997A6837B854D6 /* GZIP */; };
|
||||
340D39DB87F3800D53A6A621 /* EmojiPickerScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00245D40CD90FD71D6A05239 /* EmojiPickerScreen.swift */; };
|
||||
34357B287357BC0B9715DD51 /* UserAgentBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F2529D434C750ED78ADF1ED /* UserAgentBuilder.swift */; };
|
||||
3467FEE8210D301FF1B77001 /* UserIndicatorControllerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7893780A1FD6E3F38B3E9049 /* UserIndicatorControllerMock.swift */; };
|
||||
3471204F2CC05D4821C35F23 /* landscape_test_image.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 7A5D2323D7B6BF4913EB7EED /* landscape_test_image.jpg */; };
|
||||
34C752A73717C691582DC6C7 /* UnsupportedRoomTimelineItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1B8500C152BC59445647DA8 /* UnsupportedRoomTimelineItem.swift */; };
|
||||
@ -185,6 +186,7 @@
|
||||
41DFDD212D1BE57CA50D783B /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 0DD568A494247444A4B56031 /* Kingfisher */; };
|
||||
41F553349AF44567184822D8 /* APNSPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94D670124FC3E84F23A62CCF /* APNSPayload.swift */; };
|
||||
4219391CD2351E410554B3E8 /* AggregratedReaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B858A61F2A570DFB8DE570A7 /* AggregratedReaction.swift */; };
|
||||
422E8D182CA688D4565CD1E1 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B21E611DADDEF00307E7AC /* String.swift */; };
|
||||
4295E5F850897710A51AE114 /* GeoURI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190EC7285D3CFEF0D3011BCF /* GeoURI.swift */; };
|
||||
42A5A42ACF063EEE6B1980D2 /* ReportContentScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81B17B1F29448D1B9049B11C /* ReportContentScreenViewModel.swift */; };
|
||||
42B084FDE621FBEE433AF444 /* LegalInformationScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4176C3E20C772DE8D182863C /* LegalInformationScreen.swift */; };
|
||||
@ -419,6 +421,7 @@
|
||||
9219640F4D980CFC5FE855AD /* target.yml in Resources */ = {isa = PBXBuildFile; fileRef = 536E72DCBEEC4A1FE66CFDCE /* target.yml */; };
|
||||
92D9088B901CEBB1A99ECA4E /* RoomMemberProxyMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FD673E24FBFCFDF398716A /* RoomMemberProxyMock.swift */; };
|
||||
93875ADD456142D20823ED24 /* ServerSelectionViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDAA4472821985BF868CC21C /* ServerSelectionViewModelTests.swift */; };
|
||||
93A549135E6C027A0D823BFE /* DeviceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 385D4C28F9DC5CF53BD9ECDB /* DeviceKit */; };
|
||||
93BA4A81B6D893271101F9F0 /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = 9C73F37731C9FDED1BB24C1C /* Collections */; };
|
||||
9408CE8B8865C0C8DD4C9869 /* NoticeRoomTimelineItemContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD51B4D5173F7FC886F5360 /* NoticeRoomTimelineItemContent.swift */; };
|
||||
9462C62798F47E39DCC182D2 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA89A2DD51B6BBE1DA55E263 /* Application.swift */; };
|
||||
@ -756,6 +759,7 @@
|
||||
FA4296218444C48BC890F46B /* RoomMemberDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B35311C7FED04B0E1B80C2 /* RoomMemberDetails.swift */; };
|
||||
FA5A7E32B1920FCB4EEDC1BA /* RoomDetailsScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6493AC9979CEB1410302BFE3 /* RoomDetailsScreenCoordinator.swift */; };
|
||||
FA9C427FFB11B1AA2DCC5602 /* RoomProxyProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47111410B6E659A697D472B5 /* RoomProxyProtocol.swift */; };
|
||||
FB0A9D06FC9122E37992D962 /* LayoutDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C14D83B2B7CD5501A0089EFC /* LayoutDirection.swift */; };
|
||||
FB53CD9B74A15B3B94F9F788 /* CreateRoomModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B849D2FF2CC12BA411A1651 /* CreateRoomModels.swift */; };
|
||||
FB9A1DD83EF641A75ABBCE69 /* WaitlistScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C796FC1DFDBCDD5573D0360F /* WaitlistScreenViewModelTests.swift */; };
|
||||
FBCCF1EA25A071324FCD8544 /* TimelineItemDebugView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7023EB4F3B7C7D1FBA68638B /* TimelineItemDebugView.swift */; };
|
||||
@ -1559,6 +1563,7 @@
|
||||
67D6E0700A9C1E676F6231F8 /* Collections in Frameworks */,
|
||||
D63974A88CF2BC721F109C77 /* Compound in Frameworks */,
|
||||
DF05F9C9D3D977EB77E13692 /* DesignKit in Frameworks */,
|
||||
93A549135E6C027A0D823BFE /* DeviceKit in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -3891,6 +3896,7 @@
|
||||
AD544C0FA48DFFB080920061 /* Collections */,
|
||||
DCA3C4A997AD28E6918D4CE5 /* Compound */,
|
||||
A593735D882778FD2C9A185B /* DesignKit */,
|
||||
385D4C28F9DC5CF53BD9ECDB /* DeviceKit */,
|
||||
);
|
||||
productName = NSE;
|
||||
productReference = 0D8F620C8B314840D8602E3F /* NSE.appex */;
|
||||
@ -4146,6 +4152,7 @@
|
||||
EBE13FAB4E29738AC41BD3E5 /* InfoPlistReader.swift in Sources */,
|
||||
8691186F9B99BCDDB7CACDD8 /* KeychainController.swift in Sources */,
|
||||
A440D4BC02088482EC633A88 /* KeychainControllerProtocol.swift in Sources */,
|
||||
FB0A9D06FC9122E37992D962 /* LayoutDirection.swift in Sources */,
|
||||
AD2A81B65A9F6163012086F1 /* MXLog.swift in Sources */,
|
||||
8C454500B8073E1201F801A9 /* MXLogger.swift in Sources */,
|
||||
8B76191B9DDD1AC90A6E3A35 /* MediaFileHandleProxy.swift in Sources */,
|
||||
@ -4165,6 +4172,7 @@
|
||||
414F50CFCFEEE2611127DCFB /* RestorationToken.swift in Sources */,
|
||||
7354D094A4C59B555F407FA1 /* RustTracing.swift in Sources */,
|
||||
6C5A2C454E6C198AB39ED760 /* SharedUserDefaultsKeys.swift in Sources */,
|
||||
422E8D182CA688D4565CD1E1 /* String.swift in Sources */,
|
||||
ECA636DAF071C611FDC2BB57 /* Strings+Untranslated.swift in Sources */,
|
||||
6EC7A40A537CFB3D526A111C /* Strings.swift in Sources */,
|
||||
719E7AAD1F8E68F68F30FECD /* Task.swift in Sources */,
|
||||
@ -4172,6 +4180,7 @@
|
||||
518C93DC6516D3D018DE065F /* UNNotificationRequest.swift in Sources */,
|
||||
06B55882911B4BF5B14E9851 /* URL.swift in Sources */,
|
||||
D98B5EE8C4F5A2CE84687AE8 /* UTType.swift in Sources */,
|
||||
34357B287357BC0B9715DD51 /* UserAgentBuilder.swift in Sources */,
|
||||
3B28408450BCAED911283AA2 /* UserPreference.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -5639,6 +5648,11 @@
|
||||
package = 6582B5AF3F104B0F7E031E7D /* XCRemoteSwiftPackageReference "SwiftState" */;
|
||||
productName = SwiftState;
|
||||
};
|
||||
385D4C28F9DC5CF53BD9ECDB /* DeviceKit */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = D5F7D47BBAAE0CF1DDEB3034 /* XCRemoteSwiftPackageReference "DeviceKit" */;
|
||||
productName = DeviceKit;
|
||||
};
|
||||
4003BC24B24C9E63D3304177 /* DeviceKit */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = D5F7D47BBAAE0CF1DDEB3034 /* XCRemoteSwiftPackageReference "DeviceKit" */;
|
||||
|
@ -57,8 +57,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/matrix-org/emojibase-bindings",
|
||||
"state" : {
|
||||
"revision" : "603693b5909e98e9a616420cbdf7a357828ab030",
|
||||
"version" : "1.0.0"
|
||||
"revision" : "6ca06fefac9329fece851a2a4df7979b1699970a",
|
||||
"version" : "1.0.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -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 {
|
||||
|
@ -30,6 +30,7 @@ final class NSEUserSession {
|
||||
baseClient = try ClientBuilder()
|
||||
.basePath(path: URL.sessionsBaseDirectory.path)
|
||||
.username(username: credentials.userID)
|
||||
.userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent())
|
||||
.build()
|
||||
|
||||
try baseClient.restoreSession(session: credentials.restorationToken.session)
|
||||
|
@ -38,6 +38,7 @@ targets:
|
||||
- package: Collections
|
||||
- package: Compound
|
||||
- package: DesignKit
|
||||
- package: DeviceKit
|
||||
|
||||
info:
|
||||
path: ../SupportingFiles/Info.plist
|
||||
@ -91,3 +92,6 @@ targets:
|
||||
- path: ../../ElementX/Sources/Other/UserPreference.swift
|
||||
- path: ../../ElementX/Sources/Other/SharedUserDefaultsKeys.swift
|
||||
- path: ../../ElementX/Sources/Other/SwiftUI/Views/PlaceholderAvatarImage.swift
|
||||
- path: ../../ElementX/Sources/Other/UserAgentBuilder.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/String.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/LayoutDirection.swift
|
||||
|
@ -25,11 +25,11 @@ class UserAgentBuilderTests: XCTestCase {
|
||||
|
||||
func testContainsClientName() {
|
||||
let userAgent = UserAgentBuilder.makeASCIIUserAgent()
|
||||
XCTAssert(userAgent?.contains(InfoPlistReader.main.bundleDisplayName) == true, "\(userAgent ?? "nil") does not contain client name")
|
||||
XCTAssert(userAgent.contains(InfoPlistReader.main.bundleDisplayName) == true, "\(userAgent) does not contain client name")
|
||||
}
|
||||
|
||||
func testContainsClientVersion() {
|
||||
let userAgent = UserAgentBuilder.makeASCIIUserAgent()
|
||||
XCTAssert(userAgent?.contains(InfoPlistReader.main.bundleShortVersionString) == true, "\(userAgent ?? "nil") does not contain client version")
|
||||
XCTAssert(userAgent.contains(InfoPlistReader.main.bundleShortVersionString) == true, "\(userAgent) does not contain client version")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user