libgnunetchat

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

commit 13b1e7f8e5d289b8da96a3d03e3e825a55944e7e
parent 828af2a9a5c39996b791bfb9af48cdd1bedf509f
Author: Jacki <jacki@thejackimonster.de>
Date:   Wed,  3 Jan 2024 14:02:04 +0100

Add function to check for invitation status

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

Diffstat:
Minclude/gnunet/gnunet_chat_lib.h | 9+++++++++
Msrc/gnunet_chat_invitation.h | 4++--
Msrc/gnunet_chat_lib.c | 14++++++++++++++
3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/gnunet/gnunet_chat_lib.h b/include/gnunet/gnunet_chat_lib.h @@ -1260,6 +1260,15 @@ GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file, void GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation); +/** + * Returns if a given <i>invitation</i> is accepted. + * + * @param[in] invitation Chat invitation + * @return #GNUNET_YES if accepted, #GNUNET_NO otherwise + */ +enum GNUNET_GenericReturnValue +GNUNET_CHAT_invitation_is_accepted (const struct GNUNET_CHAT_Invitation *invitation); + /**@}*/ #endif /* GNUNET_CHAT_LIB_H_ */ diff --git a/src/gnunet_chat_invitation.h b/src/gnunet_chat_invitation.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -48,7 +48,7 @@ struct GNUNET_CHAT_Invitation */ struct GNUNET_CHAT_Invitation* invitation_create_from_message (struct GNUNET_CHAT_Context *context, - const struct GNUNET_MESSENGER_MessageInvite *message); + const struct GNUNET_MESSENGER_MessageInvite *message); /** * Destroys a chat <i>invitation</i> and frees its memory. diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c @@ -1900,3 +1900,17 @@ GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation) handle_send_room_name(invitation->context->handle, room); } + +enum GNUNET_GenericReturnValue +GNUNET_CHAT_invitation_is_accepted (const struct GNUNET_CHAT_Invitation *invitation) +{ + GNUNET_CHAT_VERSION_ASSERT(); + + if (!invitation) + return GNUNET_NO; + + return GNUNET_CONTAINER_multihashmap_contains( + invitation->context->handle->contexts, + &(invitation->key) + ); +}