libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit ad36b87e01920553c277616b40ba9989f169c3cc
parent ec93d39f8b98bc5e0112c7207e329bdb1ebf3d51
Author: Jacki <jacki@thejackimonster.de>
Date:   Tue, 17 Jun 2025 03:10:49 +0200

Fix accepting invitation to enter a room properly

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Msrc/gnunet_chat_lib.c | 30+++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c @@ -2954,13 +2954,41 @@ GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation) if (!invitation) return; + struct GNUNET_CHAT_Handle *handle; + handle = invitation->context->handle; + + if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains( + handle->contexts, &(invitation->key.hash))) + return; + struct GNUNET_PeerIdentity door; GNUNET_PEER_resolve(invitation->door, &door); - GNUNET_MESSENGER_enter_room( + struct GNUNET_MESSENGER_Room *room; + room = GNUNET_MESSENGER_enter_room( invitation->context->handle->messenger, &door, &(invitation->key) ); + + if (!room) + return; + + struct GNUNET_CHAT_Context *context; + context = context_create_from_room(handle, room); + + if (!context) + return; + + if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( + handle->contexts, &(invitation->key.hash), context, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) + { + context_destroy(context); + GNUNET_MESSENGER_close_room(room); + return; + } + + context_write_records(context); }