mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
fix #889
This commit is contained in:
parent
3363076689
commit
811da03ab5
@ -1098,7 +1098,10 @@ func (am *AccountManager) Unregister(account string, erase bool) error {
|
||||
// on our way out, unregister all the account's channels and delete them from the db
|
||||
defer func() {
|
||||
for _, channelName := range registeredChannels {
|
||||
am.server.channels.SetUnregistered(channelName, casefoldedAccount)
|
||||
err := am.server.channels.SetUnregistered(channelName, casefoldedAccount)
|
||||
if err != nil {
|
||||
am.server.logger.Error("internal", "couldn't unregister channel", channelName, err.Error())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -226,7 +226,13 @@ func (cm *ChannelManager) SetUnregistered(channelName string, account string) (e
|
||||
return err
|
||||
}
|
||||
|
||||
var info RegisteredChannel
|
||||
info, err := cm.server.channelRegistry.LoadChannel(cfname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.Founder != account {
|
||||
return errChannelNotOwnedByAccount
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err == nil {
|
||||
@ -237,17 +243,12 @@ func (cm *ChannelManager) SetUnregistered(channelName string, account string) (e
|
||||
cm.Lock()
|
||||
defer cm.Unlock()
|
||||
entry := cm.chans[cfname]
|
||||
if entry == nil {
|
||||
return errNoSuchChannel
|
||||
}
|
||||
info = entry.channel.ExportRegistration(0)
|
||||
if info.Founder != account {
|
||||
return errChannelNotOwnedByAccount
|
||||
}
|
||||
entry.channel.SetUnregistered(account)
|
||||
delete(cm.registeredChannels, cfname)
|
||||
if skel, err := Skeleton(entry.channel.Name()); err == nil {
|
||||
delete(cm.registeredSkeletons, skel)
|
||||
if entry != nil {
|
||||
entry.channel.SetUnregistered(account)
|
||||
delete(cm.registeredChannels, cfname)
|
||||
if skel, err := Skeleton(entry.channel.Name()); err == nil {
|
||||
delete(cm.registeredSkeletons, skel)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -231,6 +231,7 @@ func (reg *ChannelRegistry) LoadChannel(nameCasefolded string) (info RegisteredC
|
||||
|
||||
info = RegisteredChannel{
|
||||
Name: name,
|
||||
NameCasefolded: nameCasefolded,
|
||||
RegisteredAt: time.Unix(regTimeInt, 0).UTC(),
|
||||
Founder: founder,
|
||||
Topic: topic,
|
||||
|
Loading…
Reference in New Issue
Block a user