From 04db359a6d0f6d8630c2439fb26b7420ecc48582 Mon Sep 17 00:00:00 2001 From: Will Storey Date: Thu, 9 Aug 2018 13:49:46 -0700 Subject: [PATCH] Handle topic info numeric separately from topic & topic numeric As we called the same function for the topic info numeric, we ended up losing the topic as that numeric does not include it. We now call a different function to handle this case more carefully. Fixes #903. --- src/irc/core/channel-events.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 4b74b322..e533a6f0 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -28,6 +28,9 @@ #include "irc-servers.h" #include "irc-channels.h" +static void set_topic_info(CHANNEL_REC *const, char const *const, + time_t const); + static void check_join_failure(IRC_SERVER_REC *server, const char *channel) { CHANNEL_REC *chanrec; @@ -141,14 +144,36 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, } chanrec->topic = recoded; + set_topic_info(chanrec, setby, settime); + + signal_emit("channel topic changed", 1, chanrec); +} + +static void channel_change_topic_info(IRC_SERVER_REC *server, + const char *channel, const char *setby, time_t settime) +{ + CHANNEL_REC *chanrec; + + chanrec = channel_find(SERVER(server), channel); + if (chanrec == NULL) return; + + g_free_and_null(chanrec->topic_by); + chanrec->topic_time = 0; + + set_topic_info(chanrec, setby, settime); + + signal_emit("channel topic changed", 1, chanrec); +} + +static void set_topic_info(CHANNEL_REC *const chanrec, char const *const setby, + time_t const settime) +{ chanrec->topic_by = g_strdup(setby); if (chanrec->topic_by != NULL) { /* ensure invariant topic_time > 0 <=> topic_by != NULL. this could be triggered by a topic command without sender */ chanrec->topic_time = settime; } - - signal_emit("channel topic changed", 1, chanrec); } static void event_topic_get(IRC_SERVER_REC *server, const char *data) @@ -188,7 +213,7 @@ static void event_topic_info(IRC_SERVER_REC *server, const char *data) &topicby, &topictime); t = (time_t) atol(topictime); - channel_change_topic(server, channel, NULL, topicby, t); + channel_change_topic_info(server, channel, topicby, t); g_free(params); }