updates.
[silc.git] / apps / silcd / command_reply.c
index cb124b426389e937c302554f6e68862c2e407f7c..9b18d11afb11e7eccc6b295c8d8384b705a91319 100644 (file)
@@ -172,7 +172,7 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
   if (!client) {
     /* If router did not find such Client ID in its lists then this must
        be bogus client or some router in the net is buggy. */
-    if (server->server_type == SILC_ROUTER)
+    if (server->server_type != SILC_SERVER)
       return FALSE;
 
     /* Take hostname out of nick string if it includes it. */
@@ -299,7 +299,7 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
   if (!client) {
     /* If router did not find such Client ID in its lists then this must
        be bogus client or some router in the net is buggy. */
-    if (server->server_type == SILC_ROUTER)
+    if (server->server_type != SILC_SERVER)
       return FALSE;
 
     /* Take hostname out of nick string if it includes it. */
@@ -424,7 +424,7 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
     if (!client) {
       /* If router did not find such Client ID in its lists then this must
         be bogus client or some router in the net is buggy. */
-      if (server->server_type == SILC_ROUTER)
+      if (server->server_type != SILC_SERVER)
        goto error;
 
       /* Take nickname */
@@ -495,8 +495,8 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
                                                   server_id, FALSE, NULL);
     if (!server_entry) {
       /* If router did not find such Server ID in its lists then this must
-        be bogus client or some router in the net is buggy. */
-      if (server->server_type == SILC_ROUTER)
+        be bogus server or some router in the net is buggy. */
+      if (server->server_type != SILC_SERVER)
        goto error;
       
       /* We don't have that server anywhere, add it. */
@@ -529,9 +529,9 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
       channel = silc_idlist_find_channel_by_id(server->global_list, channel_id,
                                               NULL);
     if (!channel) {
-      /* If router did not find such Server ID in its lists then this must
-        be bogus client or some router in the net is buggy. */
-      if (server->server_type == SILC_ROUTER)
+      /* If router did not find such Channel ID in its lists then this must
+        be bogus channel or some router in the net is buggy. */
+      if (server->server_type != SILC_SERVER)
        goto error;
       
       /* We don't have that server anywhere, add it. */
@@ -798,6 +798,13 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
                    (created == 0 ? "existing" : "created"), channel_name,
                    silc_id_render(id, SILC_ID_CHANNEL)));
 
+    /* If the channel is found from global list we must move it to the
+       local list. */
+    entry = silc_idlist_find_channel_by_name(server->global_list, 
+                                            channel_name, &cache);
+    if (entry)
+      silc_idlist_del_channel(server->global_list, entry);
+
     /* Add the channel to our local list. */
     entry = silc_idlist_add_channel(server->local_list, strdup(channel_name), 
                                    SILC_CHANNEL_MODE_NONE, id, 
@@ -883,8 +890,7 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
  out:
   SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_JOIN);
   SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_JOIN);
-  if (client_id)
-    silc_free(client_id);
+  silc_free(client_id);
   silc_server_command_reply_free(cmd);
 
   if (client_id_list)
@@ -925,7 +931,7 @@ SILC_SERVER_CMD_REPLY_FUNC(users)
     if (!channel) {
       SilcBuffer idp;
 
-      if (server->server_type == SILC_ROUTER)
+      if (server->server_type != SILC_SERVER)
        goto out;
 
       idp = silc_id_payload_encode(channel_id, SILC_ID_CHANNEL);