mirror of
https://github.com/ergochat/ergo.git
synced 2026-01-10 04:12:06 -08:00
fix #313
This commit is contained in:
parent
f912f64f21
commit
b6b4d365bc
3 changed files with 36 additions and 8 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue