Change topic only if it really changed.
[silc.git] / apps / silcd / packet_receive.c
index 87f8b70f082d61ad3b50a025a15e510c5b72c108..111f3b019ceaa1a0c536c41ec3070476a5cf485d 100644 (file)
@@ -371,6 +371,16 @@ void silc_server_notify(SilcServer server,
     }
     silc_free(client_id);
 
+    /* Get the topic */
+    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+    if (!tmp) {
+      silc_free(channel_id);
+      goto out;
+    }
+
+    if (channel->topic && !strcmp(channel->topic, tmp))
+      goto out;
+
     if (!channel_id) {
       channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
                                  packet->dst_id_type);
@@ -390,13 +400,6 @@ void silc_server_notify(SilcServer server,
       }
     }
 
-    /* Get the topic */
-    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
-    if (!tmp) {
-      silc_free(channel_id);
-      goto out;
-    }
-
     /* Get user's channel entry and check that topic set is allowed. */
     if (!silc_server_client_on_channel(client, channel, &chl))
       goto out;
@@ -404,7 +407,7 @@ void silc_server_notify(SilcServer server,
        channel->mode & SILC_CHANNEL_MODE_TOPIC)
       goto out;
 
-    /* Set the topic for channel */    
+    /* Change the topic */
     silc_free(channel->topic);
     channel->topic = strdup(tmp);