aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-12-15 01:09:32 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-12-15 01:09:32 +0100
commitbf0bb934cc4c62c4aefedaab205ba0035747bdd4 (patch)
treeb06c5e94691aa6009ea53dc131b62da7dcc834e0
parent4d5a8e4212aa2b6929fc6021fc17ac560a8cfab3 (diff)
downloadlibgnunetchat-bf0bb934cc4c62c4aefedaab205ba0035747bdd4.tar.gz
libgnunetchat-bf0bb934cc4c62c4aefedaab205ba0035747bdd4.zip
Handled unknown chats to update type and be treated as valid chats
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--include/gnunet_chat_lib.h2
-rw-r--r--src/gnunet_chat_handle_intern.c23
-rw-r--r--src/gnunet_chat_lib.c6
3 files changed, 16 insertions, 15 deletions
diff --git a/include/gnunet_chat_lib.h b/include/gnunet_chat_lib.h
index f775161..b4a8075 100644
--- 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);
681 * @param[in] message Message 681 * @param[in] message Message
682 * @return Contact of the messages sender 682 * @return Contact of the messages sender
683 */ 683 */
684const struct GNUNET_CHAT_Contact* 684struct GNUNET_CHAT_Contact*
685GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message); 685GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message);
686 686
687/** 687/**
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
index 7538814..9f69611 100644
--- 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,
284 handle->contexts, key 284 handle->contexts, key
285 ); 285 );
286 286
287 if (context) 287 struct GNUNET_CHAT_CheckHandleRoomMembers check;
288
289 if ((context) && (GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN == context->type))
290 goto check_context_type;
291 else if (context)
288 return GNUNET_OK; 292 return GNUNET_OK;
289 293
290 context = context_create_from_room(handle, room); 294 context = context_create_from_room(handle, room);
@@ -298,7 +302,7 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle,
298 return GNUNET_SYSERR; 302 return GNUNET_SYSERR;
299 } 303 }
300 304
301 struct GNUNET_CHAT_CheckHandleRoomMembers check; 305check_context_type:
302 check.ignore_key = GNUNET_MESSENGER_get_key(handle->messenger); 306 check.ignore_key = GNUNET_MESSENGER_get_key(handle->messenger);
303 check.contact = NULL; 307 check.contact = NULL;
304 308
@@ -310,10 +314,7 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle,
310 (GNUNET_OK == intern_provide_contact_for_member(handle, 314 (GNUNET_OK == intern_provide_contact_for_member(handle,
311 check.contact, 315 check.contact,
312 context))) 316 context)))
313 {
314 context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; 317 context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT;
315 return GNUNET_OK;
316 }
317 else if (checks >= 2) 318 else if (checks >= 2)
318 { 319 {
319 context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP; 320 context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP;
@@ -333,17 +334,13 @@ request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle,
333 return GNUNET_OK; 334 return GNUNET_OK;
334 335
335 group_destroy(group); 336 group_destroy(group);
336 }
337 else
338 {
339 context->type = GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN;
340 337
341 // TODO: handle chats which only contain yourself currently! 338 GNUNET_CONTAINER_multihashmap_remove(handle->contexts, key, context);
339 context_destroy(context);
340 return GNUNET_SYSERR;
342 } 341 }
343 342
344 GNUNET_CONTAINER_multihashmap_remove(handle->contexts, key, context); 343 return GNUNET_OK;
345 context_destroy(context);
346 return GNUNET_SYSERR;
347} 344}
348 345
349int 346int
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 4091053..fae83d2 100644
--- 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)
488 if (!contact) 488 if (!contact)
489 return; 489 return;
490 490
491 context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT;
492
491 struct GNUNET_CHAT_Context *other = contact_find_context(contact); 493 struct GNUNET_CHAT_Context *other = contact_find_context(contact);
492 494
493 if ((!other) || (!(other->room))) 495 if ((!other) || (!(other->room)))
@@ -507,6 +509,8 @@ GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context)
507 if (!room) 509 if (!room)
508 return; 510 return;
509 511
512 intern_room_send_name(handle->messenger, room);
513
510 struct GNUNET_MESSENGER_Message msg; 514 struct GNUNET_MESSENGER_Message msg;
511 msg.header.kind = GNUNET_MESSENGER_KIND_INVITE; 515 msg.header.kind = GNUNET_MESSENGER_KIND_INVITE;
512 GNUNET_CRYPTO_get_peer_identity(handle->cfg, &(msg.body.invite.door)); 516 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)
797} 801}
798 802
799 803
800const struct GNUNET_CHAT_Contact* 804struct GNUNET_CHAT_Contact*
801GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message) 805GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message)
802{ 806{
803 if ((!message) || (!(message->context))) 807 if ((!message) || (!(message->context)))