mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
Persist realname for always-on clients
This commit is contained in:
parent
7d596add87
commit
6f8711da3b
5 changed files with 51 additions and 10 deletions
|
|
@ -39,7 +39,8 @@ const (
|
|||
keyAccountChannels = "account.channels %s" // channels registered to the account
|
||||
keyAccountJoinedChannels = "account.joinedto %s" // channels a persistent client has joined
|
||||
keyAccountLastSeen = "account.lastseen %s"
|
||||
keyAccountModes = "account.modes %s" // user modes for the always-on client as a string
|
||||
keyAccountModes = "account.modes %s" // user modes for the always-on client as a string
|
||||
keyAccountRealname = "account.realname %s" // client realname stored as string
|
||||
|
||||
keyVHostQueueAcctToId = "vhostQueue %s"
|
||||
vhostRequestIdx = "vhostQueue"
|
||||
|
|
@ -127,7 +128,13 @@ func (am *AccountManager) createAlwaysOnClients(config *Config) {
|
|||
account, err := am.LoadAccount(accountName)
|
||||
if err == nil && account.Verified &&
|
||||
persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, account.Settings.AlwaysOn) {
|
||||
am.server.AddAlwaysOnClient(account, am.loadChannels(accountName), am.loadLastSeen(accountName), am.loadModes(accountName))
|
||||
am.server.AddAlwaysOnClient(
|
||||
account,
|
||||
am.loadChannels(accountName),
|
||||
am.loadLastSeen(accountName),
|
||||
am.loadModes(accountName),
|
||||
am.loadRealname(accountName),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -650,6 +657,30 @@ func (am *AccountManager) loadLastSeen(account string) (lastSeen map[string]time
|
|||
return
|
||||
}
|
||||
|
||||
func (am *AccountManager) saveRealname(account string, realname string) {
|
||||
key := fmt.Sprintf(keyAccountRealname, account)
|
||||
am.server.store.Update(func(tx *buntdb.Tx) error {
|
||||
if realname != "" {
|
||||
tx.Set(key, realname, nil)
|
||||
} else {
|
||||
tx.Delete(key)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (am *AccountManager) loadRealname(account string) (realname string) {
|
||||
key := fmt.Sprintf(keyAccountRealname, account)
|
||||
am.server.store.Update(func(tx *buntdb.Tx) error {
|
||||
realname, _ = tx.Get(key)
|
||||
return nil
|
||||
})
|
||||
if realname == "" {
|
||||
return ""
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (am *AccountManager) addRemoveCertfp(account, certfp string, add bool, hasPrivs bool) (err error) {
|
||||
certfp, err = utils.NormalizeCertfp(certfp)
|
||||
if err != nil {
|
||||
|
|
@ -874,6 +905,9 @@ func (am *AccountManager) Verify(client *Client, account string, code string) er
|
|||
am.server.RandomlyRename(currentClient)
|
||||
}
|
||||
}
|
||||
if client.AlwaysOn() {
|
||||
client.markDirty(IncludeRealname)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue