X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-channel.c;h=af0f06681568289512438c91d868507fda2840d5;hb=44acf41cc172e8131c3a987d430b9f948afd26ad;hp=586d46cabd8c7f3ebd341442ab41f1208de45314;hpb=ec0b405d9d75045e521136ff28e42d7212f14834;p=ngircd-alex.git diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c index 586d46ca..af0f0668 100644 --- a/src/ngircd/irc-channel.c +++ b/src/ngircd/irc-channel.c @@ -89,10 +89,9 @@ join_allowed(CLIENT *Client, CLIENT *target, CHANNEL *chan, } /* Is the channel protected by a key? */ - if (strchr(channel_modes, 'k') && - strcmp(Channel_Key(chan), key ? key : "")) - { - IRC_WriteStrClient(Client, ERR_BADCHANNELKEY_MSG, Client_ID(Client), channame); + if (!Channel_CheckKey(chan, target, key ? key : "")) { + IRC_WriteStrClient(Client, ERR_BADCHANNELKEY_MSG, + Client_ID(Client), channame); return false; } /* Are there already too many members? */ @@ -156,16 +155,24 @@ join_forward(CLIENT *Client, CLIENT *target, CHANNEL *chan, else modes[0] = '\0'; - /* forward to other servers */ - snprintf(str, sizeof(str), "%s%s", channame, modes); - IRC_WriteStrServersPrefixFlag_CB(Client, target, '\0', cb_join_forward, str); + /* forward to other servers (if it is not a local channel) */ + if (!Channel_IsLocal(chan)) { + snprintf(str, sizeof(str), "%s%s", channame, modes); + IRC_WriteStrServersPrefixFlag_CB(Client, target, '\0', + cb_join_forward, str); + } /* tell users in this channel about the new client */ - IRC_WriteStrChannelPrefix(Client, chan, target, false, "JOIN :%s", channame); - if (modes[1]) - IRC_WriteStrChannelPrefix(Client, chan, target, false, "MODE %s +%s %s", - channame, &modes[1], Client_ID(target)); -} + IRC_WriteStrChannelPrefix(Client, chan, target, false, + "JOIN :%s", channame); + + /* syncronize channel modes */ + if (modes[1]) { + IRC_WriteStrChannelPrefix(Client, chan, target, false, + "MODE %s +%s %s", channame, + &modes[1], Client_ID(target)); + } +} /* join_forward */ static bool @@ -296,7 +303,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req ) if (!chan) { /* channel is new; it has been created above */ chan = Channel_Search(channame); assert(chan != NULL); - if (*channame == '+') { /* modeless channel... */ + if (Channel_IsModeless(chan)) { Channel_ModeAdd(chan, 't'); /* /TOPIC not allowed */ Channel_ModeAdd(chan, 'n'); /* no external msgs */ } @@ -423,12 +430,18 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req ) Client_TypeText(from), Client_Mask(from), Channel_Name(chan), Req->argv[1][0] ? Req->argv[1] : ""); - /* im Channel bekannt machen und an Server weiterleiten */ - IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] ); - IRC_WriteStrChannelPrefix( Client, chan, from, false, "TOPIC %s :%s", Req->argv[0], Req->argv[1] ); + /* Update channel and forward new topic to other servers */ + if (!Channel_IsLocal(chan)) + IRC_WriteStrServersPrefix(Client, from, "TOPIC %s :%s", + Req->argv[0], Req->argv[1]); + IRC_WriteStrChannelPrefix(Client, chan, from, false, "TOPIC %s :%s", + Req->argv[0], Req->argv[1]); - if( Client_Type( Client ) == CLIENT_USER ) return IRC_WriteStrClientPrefix( Client, Client, "TOPIC %s :%s", Req->argv[0], Req->argv[1] ); - else return CONNECTED; + if (Client_Type(Client) == CLIENT_USER) + return IRC_WriteStrClientPrefix(Client, Client, "TOPIC %s :%s", + Req->argv[0], Req->argv[1]); + else + return CONNECTED; } /* IRC_TOPIC */