mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
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:
@@ -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 it’s 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user