mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
allow auto-ops (halfop and higher) to bypass channel join restrictions
This commit is contained in:
parent
a4b3fb0e83
commit
7c36ec3f9d
@ -346,6 +346,9 @@ func (channel *Channel) IsEmpty() bool {
|
|||||||
|
|
||||||
// Join joins the given client to this channel (if they can be joined).
|
// Join joins the given client to this channel (if they can be joined).
|
||||||
func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *ResponseBuffer) {
|
func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *ResponseBuffer) {
|
||||||
|
account := client.Account()
|
||||||
|
nickMaskCasefolded := client.NickMaskCasefolded()
|
||||||
|
|
||||||
channel.stateMutex.RLock()
|
channel.stateMutex.RLock()
|
||||||
chname := channel.name
|
chname := channel.name
|
||||||
chcfname := channel.nameCasefolded
|
chcfname := channel.nameCasefolded
|
||||||
@ -354,6 +357,7 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
|
|||||||
limit := channel.userLimit
|
limit := channel.userLimit
|
||||||
chcount := len(channel.members)
|
chcount := len(channel.members)
|
||||||
_, alreadyJoined := channel.members[client]
|
_, alreadyJoined := channel.members[client]
|
||||||
|
persistentMode := channel.accountToUMode[account]
|
||||||
channel.stateMutex.RUnlock()
|
channel.stateMutex.RUnlock()
|
||||||
|
|
||||||
if alreadyJoined {
|
if alreadyJoined {
|
||||||
@ -361,9 +365,9 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
account := client.Account()
|
// the founder can always join (even if they disabled auto +q on join);
|
||||||
nickMaskCasefolded := client.NickMaskCasefolded()
|
// anyone who automatically receives halfop or higher can always join
|
||||||
hasPrivs := isSajoin || (founder != "" && founder == account)
|
hasPrivs := isSajoin || (founder != "" && founder == account) || (persistentMode != 0 && persistentMode != modes.Voice)
|
||||||
|
|
||||||
if !hasPrivs && limit != 0 && chcount >= limit {
|
if !hasPrivs && limit != 0 && chcount >= limit {
|
||||||
rb.Add(nil, client.server.name, ERR_CHANNELISFULL, chname, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "l"))
|
rb.Add(nil, client.server.name, ERR_CHANNELISFULL, chname, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "l"))
|
||||||
@ -404,7 +408,7 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
|
|||||||
if newChannel {
|
if newChannel {
|
||||||
givenMode = modes.ChannelOperator
|
givenMode = modes.ChannelOperator
|
||||||
} else {
|
} else {
|
||||||
givenMode = channel.accountToUMode[account]
|
givenMode = persistentMode
|
||||||
}
|
}
|
||||||
if givenMode != 0 {
|
if givenMode != 0 {
|
||||||
channel.members[client].SetMode(givenMode, true)
|
channel.members[client].SetMode(givenMode, true)
|
||||||
|
Loading…
Reference in New Issue
Block a user