Allow for multiple FreshRSS accounts with the same username — since a given username might be reused across instances. Fix #4377.

This commit is contained in:
Brent Simmons
2024-10-27 11:57:29 -07:00
parent 4bdbe23e69
commit 77910eb9a4

View File

@@ -165,15 +165,33 @@ import Core
NotificationCenter.default.post(name: .UserDidDeleteAccount, object: self, userInfo: userInfo)
}
public func duplicateServiceAccount(type: AccountType, username: String?) -> Bool {
public func duplicateServiceAccount(type: AccountType, username: String?, apiURL: String? = nil) -> Bool {
guard type != .onMyMac else {
return false
}
for account in accounts {
if account.accountType == type && username == account.username {
return true
if type == .freshRSS {
guard let apiURL, let endpointURL = URL(string: apiURL) else {
return false
}
for account in accounts {
// A person might use the same username with different instances of FreshRSS,
// so its necessary to check the endpointURL.
// https://github.com/Ranchero-Software/NetNewsWire/issues/4377
if account.accountType == type && username == account.username && account.endpointURL == endpointURL {
return true
}
}
}
else {
for account in accounts {
if account.accountType == type && username == account.username {
return true
}
}
}
return false
}