libgnunetchat

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

commit bf0bb934cc4c62c4aefedaab205ba0035747bdd4
parent 4d5a8e4212aa2b6929fc6021fc17ac560a8cfab3
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Wed, 15 Dec 2021 01:09:32 +0100

Handled unknown chats to update type and be treated as valid chats

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Minclude/gnunet_chat_lib.h | 2+-
Msrc/gnunet_chat_handle_intern.c | 23++++++++++-------------
Msrc/gnunet_chat_lib.c | 6+++++-
3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/include/gnunet_chat_lib.h b/include/gnunet_chat_lib.h @@ -681,7 +681,7 @@ GNUNET_CHAT_message_get_timestamp (const struct GNUNET_CHAT_Message *message); * @param[in] message Message * @return Contact of the messages sender */ -const struct GNUNET_CHAT_Contact* +struct GNUNET_CHAT_Contact* GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message); /** diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c @@ -284,7 +284,11 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle, handle->contexts, key ); - if (context) + struct GNUNET_CHAT_CheckHandleRoomMembers check; + + if ((context) && (GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN == context->type)) + goto check_context_type; + else if (context) return GNUNET_OK; context = context_create_from_room(handle, room); @@ -298,7 +302,7 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle, return GNUNET_SYSERR; } - struct GNUNET_CHAT_CheckHandleRoomMembers check; +check_context_type: check.ignore_key = GNUNET_MESSENGER_get_key(handle->messenger); check.contact = NULL; @@ -310,10 +314,7 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle, (GNUNET_OK == intern_provide_contact_for_member(handle, check.contact, context))) - { context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; - return GNUNET_OK; - } else if (checks >= 2) { context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP; @@ -333,17 +334,13 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle, return GNUNET_OK; group_destroy(group); - } - else - { - context->type = GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN; - // TODO: handle chats which only contain yourself currently! + GNUNET_CONTAINER_multihashmap_remove(handle->contexts, key, context); + context_destroy(context); + return GNUNET_SYSERR; } - GNUNET_CONTAINER_multihashmap_remove(handle->contexts, key, context); - context_destroy(context); - return GNUNET_SYSERR; + return GNUNET_OK; } int diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c @@ -488,6 +488,8 @@ GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context) if (!contact) return; + context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; + struct GNUNET_CHAT_Context *other = contact_find_context(contact); if ((!other) || (!(other->room))) @@ -507,6 +509,8 @@ GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context) if (!room) return; + intern_room_send_name(handle->messenger, room); + struct GNUNET_MESSENGER_Message msg; msg.header.kind = GNUNET_MESSENGER_KIND_INVITE; GNUNET_CRYPTO_get_peer_identity(handle->cfg, &(msg.body.invite.door)); @@ -797,7 +801,7 @@ GNUNET_CHAT_message_get_timestamp (const struct GNUNET_CHAT_Message *message) } -const struct GNUNET_CHAT_Contact* +struct GNUNET_CHAT_Contact* GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message) { if ((!message) || (!(message->context)))