Anonymous avatar Anonymous committed a29e4b9

Clean up +J to work nicely and properly.

Comments (0)

Files changed (3)

modules/core/m_kick.c

 	char *comment;
 	const char *name;
 	char *p = NULL;
-	char *text = rb_strdup("");
 	const char *user;
 	static char buf[BUFSIZE];
 	int is_override = 0;
 			      use_id(source_p), chptr->chname, use_id(who), comment);
 		remove_user_from_channel(msptr);
 
-		rb_sprintf(text, "K%s",who->name);
-
 		/* we don't need to track NOREJOIN stuff unless it's our client being kicked */
 		if(MyClient(source_p) && chptr->mode.mode & MODE_NOREJOIN)
-			channel_metadata_time_add(chptr, text, rb_current_time());
+			channel_metadata_time_add(chptr, "KICKNOREJOIN", rb_current_time(), who->id);
 	}
 	else if (MyClient(source_p))
 		sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
 	hook_data_channel moduledata;
 	struct Metadata *md;
 	struct DictionaryIter iter;
-	char *text = rb_strdup("");
 
 	s_assert(source_p->localClient != NULL);
 
 	if((is_banned(chptr, source_p, NULL, src_host, src_iphost)) == CHFL_BAN)
 		return (ERR_BANNEDFROMCHAN);
 
-	rb_sprintf(text, "K%s",source_p->name);
-
-	if(md = channel_metadata_find(chptr, text))
+	DICTIONARY_FOREACH(md, &iter, chptr->metadata)
 	{
-		if(md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time())
-		{
+		if(!strcmp(md->name, "KICKNOREJOIN") && !strcmp(md->value, source_p->id) && (md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time()))
 			return ERR_KICKNOREJOIN;
-		}
-		/* cleanup the channel's kicknorejoin metadata. */
-		DICTIONARY_FOREACH(md, &iter, chptr->metadata)
-		{
-			text = rb_strdup(md->name);
-			if((text[0] == 'K') && (md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time()))  
-				channel_metadata_delete(chptr, md->name, 1);
-		}
-			
+		/* cleanup any stale KICKNOREJOIN metadata we find while we're at it */
+		if(!strcmp(md->name, "KICKNOREJOIN") && !(md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time()))  
+			channel_metadata_delete(chptr, md->name, 0);
 	}
 
 	if(chptr->mode.mode & MODE_INVITEONLY)
 #include "s_newconf.h"
 #include "logger.h"
 #include "chmode.h"
+#include "irc_dictionary.h";
 
 /* bitmasks for error returns, so we send once per call */
 #define SM_ERR_NOTS             0x00000001	/* No TS on channel */
 {
 
 	int override = 0;
+	struct Metadata *md;
+	struct DictionaryIter iter;
 	
 	if(alevel != CHFL_CHANOP && alevel != CHFL_OWNER && alevel != CHFL_HALFOP)
 	{
 	}
 	else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
 	{
+		/* cleanup KICKNOREJOIN metadata on -J */
+		if(c == 'J')
+		{
+			DICTIONARY_FOREACH(md, &iter, chptr->metadata)
+			{
+				if(!strcmp(md->name, "KICKNOREJOIN"))  
+					channel_metadata_delete(chptr, md->name, 0);
+			}
+		}
+
 		chptr->mode.mode &= ~mode_type;
 
 		mode_changes[mode_count].letter = c;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.