- /* Test if the user has reached his maximum channel count */
- if ((Conf_MaxJoins > 0) && (Channel_CountForUser(Client) >= Conf_MaxJoins))
- return IRC_WriteStrClient(Client, ERR_TOOMANYCHANNELS_MSG,
- Client_ID(Client), channame);
- if (!chan) {
- /*
- * New Channel: first user will be channel operator
- * unless this is a modeless channel.
- */
+ /* Test if the user has reached the channel limit */
+ if ((Conf_MaxJoins > 0) &&
+ (Channel_CountForUser(Client) >= Conf_MaxJoins))
+ return IRC_WriteStrClient(Client,
+ ERR_TOOMANYCHANNELS_MSG,
+ Client_ID(Client), channame);
+ if (chan) {
+ /* Already existing channel: check if the
+ * client is allowed to join */
+ if (!join_allowed(Client, chan, channame, key))
+ break;
+ } else {
+ /* New channel: first user will become channel
+ * operator unless this is a modeless channel */