Browse Source

fix #1756

A default channel mode of +i would block channel creation; fix this by treating
initial joins as SAJOINs.

Note that it's nontrivial to detect initial join in (*Channel).Join, because
having 0 members does not necessarily indicate a new channel.
tags/v2.8.0-rc1
Shivaram Lingamneni 2 years ago
parent
commit
6851901e20
1 changed files with 8 additions and 6 deletions
  1. 8
    6
      irc/channelmanager.go

+ 8
- 6
irc/channelmanager.go View File

@@ -117,12 +117,13 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin
117 117
 		return errNoSuchChannel, ""
118 118
 	}
119 119
 
120
-	channel, err := func() (*Channel, error) {
120
+	channel, err, newChannel := func() (*Channel, error, bool) {
121
+		var newChannel bool
121 122
 		cm.Lock()
122 123
 		defer cm.Unlock()
123 124
 
124 125
 		if cm.purgedChannels.Has(casefoldedName) {
125
-			return nil, errChannelPurged
126
+			return nil, errChannelPurged, false
126 127
 		}
127 128
 		entry := cm.chans[casefoldedName]
128 129
 		if entry == nil {
@@ -130,11 +131,11 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin
130 131
 			// enforce OpOnlyCreation
131 132
 			if !registered && server.Config().Channels.OpOnlyCreation &&
132 133
 				!(isSajoin || client.HasRoleCapabs("chanreg")) {
133
-				return nil, errInsufficientPrivs
134
+				return nil, errInsufficientPrivs, false
134 135
 			}
135 136
 			// enforce confusables
136 137
 			if !registered && (cm.chansSkeletons.Has(skeleton) || cm.registeredSkeletons.Has(skeleton)) {
137
-				return nil, errConfusableIdentifier
138
+				return nil, errConfusableIdentifier, false
138 139
 			}
139 140
 			entry = &channelManagerEntry{
140 141
 				channel:      NewChannel(server, name, casefoldedName, registered),
@@ -149,9 +150,10 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin
149 150
 				entry.skeleton = skeleton
150 151
 			}
151 152
 			cm.chans[casefoldedName] = entry
153
+			newChannel = true
152 154
 		}
153 155
 		entry.pendingJoins += 1
154
-		return entry.channel, nil
156
+		return entry.channel, nil, newChannel
155 157
 	}()
156 158
 
157 159
 	if err != nil {
@@ -159,7 +161,7 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin
159 161
 	}
160 162
 
161 163
 	channel.EnsureLoaded()
162
-	err, forward = channel.Join(client, key, isSajoin, rb)
164
+	err, forward = channel.Join(client, key, isSajoin || newChannel, rb)
163 165
 
164 166
 	cm.maybeCleanup(channel, true)
165 167
 

Loading…
Cancel
Save