mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
Read accounts and grouped nicks in same transaction.
This commit is contained in:
parent
73bea0168d
commit
b363a01a6f
@ -1050,21 +1050,23 @@ func (am *AccountManager) AuthenticateByPassphrase(client *Client, accountName s
|
|||||||
|
|
||||||
// AllNicks returns the uncasefolded nicknames for all accounts, including additional (grouped) nicks.
|
// AllNicks returns the uncasefolded nicknames for all accounts, including additional (grouped) nicks.
|
||||||
func (am *AccountManager) AllNicks() (result []string) {
|
func (am *AccountManager) AllNicks() (result []string) {
|
||||||
// Account names
|
|
||||||
accountNamePrefix := fmt.Sprintf(keyAccountName, "")
|
accountNamePrefix := fmt.Sprintf(keyAccountName, "")
|
||||||
|
accountAdditionalNicksPrefix := fmt.Sprintf(keyAccountAdditionalNicks, "")
|
||||||
|
|
||||||
am.server.store.View(func(tx *buntdb.Tx) error {
|
am.server.store.View(func(tx *buntdb.Tx) error {
|
||||||
return tx.AscendGreaterOrEqual("", accountNamePrefix, func(key, value string) bool {
|
// Account names
|
||||||
|
err := tx.AscendGreaterOrEqual("", accountNamePrefix, func(key, value string) bool {
|
||||||
if !strings.HasPrefix(key, accountNamePrefix) {
|
if !strings.HasPrefix(key, accountNamePrefix) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
result = append(result, value)
|
result = append(result, value)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
})
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Additional nicknames
|
// Additional nicks
|
||||||
accountAdditionalNicksPrefix := fmt.Sprintf(keyAccountAdditionalNicks, "")
|
|
||||||
am.server.store.View(func(tx *buntdb.Tx) error {
|
|
||||||
return tx.AscendGreaterOrEqual("", accountAdditionalNicksPrefix, func(key, value string) bool {
|
return tx.AscendGreaterOrEqual("", accountAdditionalNicksPrefix, func(key, value string) bool {
|
||||||
if !strings.HasPrefix(key, accountAdditionalNicksPrefix) {
|
if !strings.HasPrefix(key, accountAdditionalNicksPrefix) {
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user