commit 1d1129fb6c72cdd6902ace7a1a19dfcdf95a37ba
parent 0aa918a8861ad8e8260309e0e0961cfb0b1b1c26
Author: Jacki <jacki@thejackimonster.de>
Date: Sat, 20 Jan 2024 08:09:19 +0100
Implement changes regarding a message recipient
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
3 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/include/gnunet/gnunet_chat_lib.h b/include/gnunet/gnunet_chat_lib.h
@@ -1097,6 +1097,15 @@ struct GNUNET_CHAT_Contact*
GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message);
/**
+ * Returns the contact of the recipient from a given <i>message</i>.
+ *
+ * @param[in] message Message
+ * @return Contact of the messages recipient or NULL
+ */
+struct GNUNET_CHAT_Contact*
+GNUNET_CHAT_message_get_recipient (const struct GNUNET_CHAT_Message *message);
+
+/**
* Returns #GNUNET_YES if the message was sent by the related chat handle,
* otherwise it returns #GNUNET_NO.
*
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
@@ -807,6 +807,7 @@ void
on_handle_message (void *cls,
struct GNUNET_MESSENGER_Room *room,
const struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Contact *recipient,
const struct GNUNET_MESSENGER_Message *msg,
const struct GNUNET_HashCode *hash,
enum GNUNET_MESSENGER_MessageFlags flags)
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
@@ -1615,6 +1615,26 @@ GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message)
}
+struct GNUNET_CHAT_Contact*
+GNUNET_CHAT_message_get_recipient (const struct GNUNET_CHAT_Message *message)
+{
+ GNUNET_CHAT_VERSION_ASSERT();
+
+ if ((!message) || (GNUNET_CHAT_FLAG_NONE != message->flag) ||
+ (!(message->context)) || (!(message->context->room)))
+ return NULL;
+
+ const struct GNUNET_MESSENGER_Contact *recipient = GNUNET_MESSENGER_get_recipient(
+ message->context->room, &(message->hash)
+ );
+
+ if (!recipient)
+ return NULL;
+
+ return handle_get_contact_from_messenger(message->context->handle, recipient);
+}
+
+
enum GNUNET_GenericReturnValue
GNUNET_CHAT_message_is_sent (const struct GNUNET_CHAT_Message *message)
{