commit 7ee0dab6e99668df6f33293d9efbfd147c82191f
parent 56b4e95cd59010900c1bc92005b277123b37f69d
Author: Jacki <jacki@thejackimonster.de>
Date: Sun, 28 Apr 2024 21:01:59 +0200
Ignore lobbies in account management
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
4 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
@@ -28,6 +28,7 @@
#include "gnunet_chat_group.h"
#include "gnunet_chat_handle.h"
#include "gnunet_chat_invitation.h"
+#include "gnunet_chat_lobby.h"
#include "gnunet_chat_message.h"
#include "gnunet_chat_tagging.h"
#include "gnunet_chat_ticket.h"
@@ -283,6 +284,9 @@ on_handle_gnunet_identity (void *cls,
{
GNUNET_assert(cls);
+ if ((name) && (GNUNET_YES == util_is_lobby_name(name)))
+ return;
+
struct GNUNET_CHAT_Handle* handle = cls;
if ((!ctx) || (!ego))
diff --git a/src/gnunet_chat_lobby_intern.c b/src/gnunet_chat_lobby_intern.c
@@ -34,16 +34,7 @@ cont_lobby_write_records (void *cls,
lobby->query = NULL;
- const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(
- lobby->context->room
- );
-
- char *name;
- util_lobby_name(key, &name);
-
- handle_delete_account(lobby->handle, name);
-
- GNUNET_free(name);
+ handle_delete_lobby(lobby->handle, lobby);
if (GNUNET_EC_NONE == ec)
{
diff --git a/src/gnunet_chat_util.c b/src/gnunet_chat_util.c
@@ -23,11 +23,15 @@
*/
#include "gnunet_chat_util.h"
+
+#include <gnunet/gnunet_common.h>
#include <gnunet/gnunet_messenger_service.h>
static const char label_prefix_of_contact [] = "contact";
static const char label_prefix_of_group [] = "group";
+static const char identity_prefix_of_lobby [] = "gnunet_chat_lobby";
+
void
util_shorthash_from_member (const struct GNUNET_MESSENGER_Contact *member,
struct GNUNET_ShortHashCode *shorthash)
@@ -341,6 +345,8 @@ util_get_context_label (enum GNUNET_CHAT_ContextType type,
const struct GNUNET_HashCode *hash,
char **label)
{
+ GNUNET_assert((hash) && (label));
+
const char *type_string = "chat";
switch (type)
@@ -372,6 +378,8 @@ enum GNUNET_CHAT_ContextType
util_get_context_label_type (const char *label,
const struct GNUNET_HashCode *hash)
{
+ GNUNET_assert((hash) && (label));
+
enum GNUNET_CHAT_ContextType type = GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN;
char *low = util_get_lower(GNUNET_h2s(hash));
@@ -396,11 +404,14 @@ int
util_lobby_name (const struct GNUNET_HashCode *hash,
char **name)
{
+ GNUNET_assert((hash) && (name));
+
char *low = util_get_lower(GNUNET_h2s(hash));
int result = GNUNET_asprintf (
name,
- "chat_lobby_%s",
+ "%s_%s",
+ identity_prefix_of_lobby,
low
);
@@ -408,6 +419,23 @@ util_lobby_name (const struct GNUNET_HashCode *hash,
return result;
}
+enum GNUNET_GenericReturnValue
+util_is_lobby_name(const char *name)
+{
+ GNUNET_assert(name);
+
+ const char *sub = strstr(name, identity_prefix_of_lobby);
+ if ((!sub) || (sub != name))
+ return GNUNET_NO;
+
+ const size_t len = strlen(identity_prefix_of_lobby);
+
+ if (name[len] != '_')
+ return GNUNET_NO;
+ else
+ return GNUNET_YES;
+}
+
enum GNUNET_CHAT_MessageKind
util_message_kind_from_kind (enum GNUNET_MESSENGER_MessageKind kind)
{
diff --git a/src/gnunet_chat_util.h b/src/gnunet_chat_util.h
@@ -198,6 +198,18 @@ util_lobby_name (const struct GNUNET_HashCode *hash,
char **name);
/**
+ * Check whether an identity <i>name</i> could be a
+ * standardized name for a lobby.
+ * @see util_lobby_name()
+ *
+ * @param[in] name Identity name
+ * @return #GNUNET_YES if it might be a lobby name,
+ * otherwise #GNUNET_NO
+ */
+enum GNUNET_GenericReturnValue
+util_is_lobby_name(const char *name);
+
+/**
* Return the chat related kind for a messages original kind
* from the service. It will return #GNUNET_CHAT_KIND_UNKNOWN
* in case the message kind is not supported.