Add additional usernames indexing

This commit is contained in:
Ilya Laktyushin
2022-10-25 01:49:10 +03:00
parent 4844818014
commit 4d1335d8c6
9 changed files with 51 additions and 34 deletions

View File

@@ -222,8 +222,12 @@ func _internal_toggleAddressNameActive(account: Account, domain: AddressNameDoma
switch domain {
case .account:
return account.network.request(Api.functions.account.toggleUsername(username: name, active: active ? .boolTrue : .boolFalse), automaticFloodWait: false)
|> mapError { _ -> ToggleAddressNameActiveError in
return .generic
|> mapError { error -> ToggleAddressNameActiveError in
if error.errorDescription == "USERNAMES_ACTIVE_TOO_MUCH" {
return .activeLimitReached
} else {
return .generic
}
}
|> mapToSignal { result -> Signal<Void, ToggleAddressNameActiveError> in
return account.postbox.transaction { transaction -> Void in
@@ -276,8 +280,12 @@ func _internal_toggleAddressNameActive(account: Account, domain: AddressNameDoma
case let .peer(peerId):
if let peer = transaction.getPeer(peerId), let inputChannel = apiInputChannel(peer) {
return account.network.request(Api.functions.channels.toggleUsername(channel: inputChannel, username: name, active: active ? .boolTrue : .boolFalse), automaticFloodWait: false)
|> mapError { _ -> ToggleAddressNameActiveError in
return .generic
|> mapError { error -> ToggleAddressNameActiveError in
if error.errorDescription == "USERNAMES_ACTIVE_TOO_MUCH" {
return .activeLimitReached
} else {
return .generic
}
}
|> mapToSignal { result -> Signal<Void, ToggleAddressNameActiveError> in
return account.postbox.transaction { transaction -> Void in