This commit is contained in:
Shivaram Lingamneni 2018-12-23 13:25:02 -05:00
parent f912f64f21
commit b6b4d365bc
3 changed files with 36 additions and 8 deletions

View file

@ -69,6 +69,7 @@ type Client struct {
hops int
hostname string
idletimer *IdleTimer
invitedTo map[string]bool
isDestroyed bool
isQuitting bool
languages []string
@ -1102,3 +1103,26 @@ func (client *Client) generateResumeToken() (token string, err error) {
return client.resumeToken, err
}
// Records that the client has been invited to join an invite-only channel
func (client *Client) Invite(casefoldedChannel string) {
client.stateMutex.Lock()
defer client.stateMutex.Unlock()
if client.invitedTo == nil {
client.invitedTo = make(map[string]bool)
}
client.invitedTo[casefoldedChannel] = true
}
// Checks that the client was invited to join a given channel
func (client *Client) CheckInvited(casefoldedChannel string) (invited bool) {
client.stateMutex.Lock()
defer client.stateMutex.Unlock()
invited = client.invitedTo[casefoldedChannel]
// joining an invited channel "uses up" your invite, so you can't rejoin on kick
delete(client.invitedTo, casefoldedChannel)
return
}