mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-24 16:18:10 -07:00
track channel registrations per account
* limit the total number of registrations per account * when an account is unregistered, unregister all its channels
This commit is contained in:
@@ -224,6 +224,13 @@ func csRegisterHandler(server *Server, client *Client, command string, params []
|
||||
return
|
||||
}
|
||||
|
||||
account := client.Account()
|
||||
channelsAlreadyRegistered := server.accounts.ChannelsForAccount(account)
|
||||
if server.Config().Channels.Registration.MaxChannelsPerAccount <= len(channelsAlreadyRegistered) {
|
||||
csNotice(rb, client.t("You have already registered the maximum number of channels; try dropping some with /CS UNREGISTER"))
|
||||
return
|
||||
}
|
||||
|
||||
// this provides the synchronization that allows exactly one registration of the channel:
|
||||
err = channelInfo.SetRegistered(client.Account())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user