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:
Shivaram Lingamneni 2019-02-06 04:32:04 -05:00
parent 8eefe869d0
commit ff7bbc4a9c
7 changed files with 120 additions and 3 deletions

View file

@ -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 {