commit ba41943e84b221a6c31edb16576f0086690ab7b9
parent ad36b87e01920553c277616b40ba9989f169c3cc
Author: Jacki <jacki@thejackimonster.de>
Date: Fri, 27 Jun 2025 22:12:33 +0200
Fix group creation on accepting invitation to it, add function to retrieve invitation intend
Diffstat:
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/include/gnunet/gnunet_chat_lib.h b/include/gnunet/gnunet_chat_lib.h
@@ -1909,6 +1909,17 @@ enum GNUNET_GenericReturnValue
GNUNET_CHAT_invitation_is_rejected (const struct GNUNET_CHAT_Invitation *invitation);
/**
+ * Returns whether the intend from a given
+ * <i>invitation</i>. is to open a direct chat or
+ * a group chat.
+ *
+ * @param[in] invitation Chat invitation
+ * @return #GNUNET_YES if it is a direct chat request, #GNUNET_NO otherwise
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_CHAT_invitation_is_direct (const struct GNUNET_CHAT_Invitation *invitation);
+
+/**
* Returns the discourse id of a given chat <i>discourse</i>.
*
* @param[in] discourse Chat discourse
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
@@ -2982,13 +2982,32 @@ GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation)
if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
handle->contexts, &(invitation->key.hash), context,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
+ goto destroy_context;
+
+ if (GNUNET_CHAT_CONTEXT_TYPE_GROUP != context->type)
{
- context_destroy(context);
- GNUNET_MESSENGER_close_room(room);
+ context_write_records(context);
+ return;
+ }
+
+ struct GNUNET_CHAT_Group *group;
+ group = group_create_from_context(handle, context);
+
+ if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(
+ handle->groups, &(invitation->key.hash), group,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
+ {
+ context_write_records(context);
return;
}
- context_write_records(context);
+ group_destroy(group);
+
+ GNUNET_CONTAINER_multihashmap_remove(
+ handle->contexts, &(invitation->key.hash), context);
+
+destroy_context:
+ context_destroy(context);
}
@@ -3055,6 +3074,20 @@ GNUNET_CHAT_invitation_is_rejected (const struct GNUNET_CHAT_Invitation *invitat
}
+enum GNUNET_GenericReturnValue
+GNUNET_CHAT_invitation_is_direct (const struct GNUNET_CHAT_Invitation *invitation)
+{
+ GNUNET_CHAT_VERSION_ASSERT();
+
+ if ((invitation->key.code.public_bit) ||
+ (invitation->key.code.group_bit) ||
+ (invitation->key.code.feed_bit))
+ return GNUNET_NO;
+ else
+ return GNUNET_YES;
+}
+
+
const struct GNUNET_CHAT_DiscourseId*
GNUNET_CHAT_discourse_get_id (const struct GNUNET_CHAT_Discourse *discourse)
{