libgnunetchat

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

commit 0cdae5ab6c61f15f0dfb745d2322578438b300c5
parent 294fca9f935eb0ea184b75dba469fc48e9e436a4
Author: Jacki <jacki@thejackimonster.de>
Date:   Mon, 17 Jun 2024 18:10:56 +0200

Add update flag on subscriptions if message extends it

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

Diffstat:
Msrc/gnunet_chat_discourse.c | 10++++++++--
Msrc/gnunet_chat_discourse.h | 4+++-
Msrc/gnunet_chat_handle_intern.c | 7++++++-
3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/gnunet_chat_discourse.c b/src/gnunet_chat_discourse.c @@ -71,7 +71,7 @@ discourse_destroy (struct GNUNET_CHAT_Discourse *discourse) GNUNET_free(discourse); } -void +enum GNUNET_GenericReturnValue discourse_subscribe (struct GNUNET_CHAT_Discourse *discourse, struct GNUNET_CHAT_Contact *contact, const struct GNUNET_TIME_Absolute timestamp, @@ -85,12 +85,16 @@ discourse_subscribe (struct GNUNET_CHAT_Discourse *discourse, ); if (GNUNET_TIME_absolute_cmp(end, <, GNUNET_TIME_absolute_get())) - return; + return GNUNET_SYSERR; struct GNUNET_CHAT_DiscourseSubscription *sub; for (sub = discourse->head; sub; sub = sub->next) if (sub->contact == contact) break; + + const enum GNUNET_GenericReturnValue update = ( + sub? GNUNET_YES : GNUNET_NO + ); if (!sub) { @@ -119,6 +123,8 @@ discourse_subscribe (struct GNUNET_CHAT_Discourse *discourse, discourse_remove_subscription, sub ); + + return update; } void diff --git a/src/gnunet_chat_discourse.h b/src/gnunet_chat_discourse.h @@ -88,8 +88,10 @@ discourse_destroy (struct GNUNET_CHAT_Discourse *discourse); * @param[in,out] contact Chat contact * @param[in] timestamp Timestamp * @param[in] time Time window + * @return #GNUNET_YES on updating an existing subscription, + * #GNUNET_SYSERR on failure, otherwise #GNUNET_NO */ -void +enum GNUNET_GenericReturnValue discourse_subscribe (struct GNUNET_CHAT_Discourse *discourse, struct GNUNET_CHAT_Contact *contact, const struct GNUNET_TIME_Absolute timestamp, diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c @@ -910,6 +910,8 @@ skip_msg_handing: } } + enum GNUNET_GenericReturnValue subscribtion_update = GNUNET_NO; + if (GNUNET_MESSENGER_FLAG_SUBSCRIPTION_UNSUBSCRIBE & message->msg->body.subscribe.flags) discourse_unsubscribe( discourse, @@ -918,12 +920,15 @@ skip_msg_handing: GNUNET_TIME_relative_ntoh(message->msg->body.subscribe.time) ); else - discourse_subscribe( + subscribtion_update = discourse_subscribe( discourse, contact, GNUNET_TIME_absolute_ntoh(message->msg->header.timestamp), GNUNET_TIME_relative_ntoh(message->msg->body.subscribe.time) ); + + if (GNUNET_YES == subscribtion_update) + message->flags |= GNUNET_MESSENGER_FLAG_UPDATE; break; }