IRCv3: Fix pre-registration PRIVMSG not going to the status window

Thu, 31 Oct 2024 23:44:26 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 31 Oct 2024 23:44:26 -0500
changeset 43025
2d3b2ed42f87
parent 43024
8a7be63f83e4
child 43026
9ced9177d54b

IRCv3: Fix pre-registration PRIVMSG not going to the status window

Also stop announcing new members in the status window as well.

Testing Done:
Connected to a local inspircd instance and verified that ident lookup went to the status window and that join messages were no longer being sent.

Reviewed at https://reviews.imfreedom.org/r/3615/

protocols/ircv3/purpleircv3messagehandlers.c file | annotate | diff | comparison | revisions
--- a/protocols/ircv3/purpleircv3messagehandlers.c	Thu Oct 31 23:38:46 2024 -0500
+++ b/protocols/ircv3/purpleircv3messagehandlers.c	Thu Oct 31 23:44:26 2024 -0500
@@ -33,7 +33,8 @@
  *****************************************************************************/
 static void
 purple_ircv3_add_contact_to_conversation(PurpleContact *contact,
-                                         PurpleConversation *conversation)
+                                         PurpleConversation *conversation,
+                                         gboolean announce)
 {
 	PurpleContactInfo *info = PURPLE_CONTACT_INFO(contact);
 	PurpleConversationMember *member = NULL;
@@ -45,11 +46,15 @@
 	if(!PURPLE_IS_CONVERSATION_MEMBER(member)) {
 		char *message = NULL;
 
-		message = g_strdup_printf(_("%s has joined %s"),
-		                          purple_contact_info_get_sid(info),
-		                          purple_conversation_get_title_for_display(conversation));
-		purple_conversation_members_add_member(members, info, TRUE, message);
-		g_free(message);
+		if(announce) {
+			message = g_strdup_printf(_("%s has joined %s"),
+			                          purple_contact_info_get_sid(info),
+			                          purple_conversation_get_title_for_display(conversation));
+		}
+
+		purple_conversation_members_add_member(members, info, announce,
+		                                       message);
+		g_clear_pointer(&message, g_free);
 	}
 }
 
@@ -86,7 +91,7 @@
 
 	conversation = purple_ircv3_connection_find_or_create_conversation(connection,
 	                                                                   conversation_name);
-	purple_ircv3_add_contact_to_conversation(contact, conversation);
+	purple_ircv3_add_contact_to_conversation(contact, conversation, TRUE);
 
 	return TRUE;
 }
@@ -289,7 +294,7 @@
 	conversation = purple_ircv3_connection_find_or_create_conversation(connection,
 	                                                                   target);
 
-	purple_ircv3_add_contact_to_conversation(contact, conversation);
+	purple_ircv3_add_contact_to_conversation(contact, conversation, FALSE);
 
 	/* Handle typing notifications. */
 	value = ibis_tags_lookup(tags, IBIS_TAG_TYPING);
@@ -330,6 +335,7 @@
 	IbisTags *tags = NULL;
 	GStrv params = NULL;
 	const char *target = NULL;
+	gboolean announce = TRUE;
 
 	params = ibis_message_get_params(ibis_message);
 	ctcp_message = ibis_message_get_ctcp_message(ibis_message);
@@ -361,14 +367,16 @@
 
 	if(!ibis_client_get_registered(client)) {
 		conversation = purple_ircv3_connection_get_status_conversation(connection);
+		announce = FALSE;
 	} else if(IBIS_IS_CTCP_MESSAGE(ctcp_message)) {
 		conversation = purple_ircv3_connection_get_status_conversation(connection);
+		announce = FALSE;
 	} else {
 		conversation = purple_ircv3_connection_find_or_create_conversation(connection,
 		                                                                   target);
 	}
 
-	purple_ircv3_add_contact_to_conversation(contact, conversation);
+	purple_ircv3_add_contact_to_conversation(contact, conversation, announce);
 
 	if(IBIS_IS_CTCP_MESSAGE(ctcp_message)) {
 		if(ibis_ctcp_message_is_command(ctcp_message, IBIS_CTCP_ACTION)) {

mercurial