mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +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
|
// on our way out, unregister all the account's channels and delete them from the db
|
||||||
defer func() {
|
defer func() {
|
||||||
for _, channelName := range registeredChannels {
|
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
|
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() {
|
defer func() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -237,18 +243,13 @@ func (cm *ChannelManager) SetUnregistered(channelName string, account string) (e
|
|||||||
cm.Lock()
|
cm.Lock()
|
||||||
defer cm.Unlock()
|
defer cm.Unlock()
|
||||||
entry := cm.chans[cfname]
|
entry := cm.chans[cfname]
|
||||||
if entry == nil {
|
if entry != nil {
|
||||||
return errNoSuchChannel
|
|
||||||
}
|
|
||||||
info = entry.channel.ExportRegistration(0)
|
|
||||||
if info.Founder != account {
|
|
||||||
return errChannelNotOwnedByAccount
|
|
||||||
}
|
|
||||||
entry.channel.SetUnregistered(account)
|
entry.channel.SetUnregistered(account)
|
||||||
delete(cm.registeredChannels, cfname)
|
delete(cm.registeredChannels, cfname)
|
||||||
if skel, err := Skeleton(entry.channel.Name()); err == nil {
|
if skel, err := Skeleton(entry.channel.Name()); err == nil {
|
||||||
delete(cm.registeredSkeletons, skel)
|
delete(cm.registeredSkeletons, skel)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +231,7 @@ func (reg *ChannelRegistry) LoadChannel(nameCasefolded string) (info RegisteredC
|
|||||||
|
|
||||||
info = RegisteredChannel{
|
info = RegisteredChannel{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
NameCasefolded: nameCasefolded,
|
||||||
RegisteredAt: time.Unix(regTimeInt, 0).UTC(),
|
RegisteredAt: time.Unix(regTimeInt, 0).UTC(),
|
||||||
Founder: founder,
|
Founder: founder,
|
||||||
Topic: topic,
|
Topic: topic,
|
||||||
|
Loading…
Reference in New Issue
Block a user