commit 22d772e80767fb3222c1c7eecf43f77994ef7701
parent d36a5f5f49a4d8bfd0094f69075539c6e468b10c
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Sat, 13 Nov 2021 23:31:58 +0100
Added automatic name announcement in chats
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
@@ -172,6 +172,8 @@ GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle,
if (!room)
return NULL;
+ intern_room_send_name(handle->messenger, room);
+
struct GNUNET_CHAT_Context *context = context_create_from_room(handle, room);
context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP;
@@ -446,7 +448,9 @@ GNUNET_CHAT_group_invite_contact (struct GNUNET_CHAT_Group *group,
group->context->room
);
- GNUNET_MESSENGER_open_room(group->handle->messenger, key);
+ intern_room_send_name(group->handle->messenger, GNUNET_MESSENGER_open_room(
+ group->handle->messenger, key
+ ));
struct GNUNET_MESSENGER_Message msg;
msg.header.kind = GNUNET_MESSENGER_KIND_INVITE;
diff --git a/src/gnunet_chat_lib_intern.c b/src/gnunet_chat_lib_intern.c
@@ -48,6 +48,27 @@ it_handle_iterate_contacts (void *cls,
return it->cb(it->cls, it->handle, contact);
}
+void
+intern_room_send_name (struct GNUNET_MESSENGER_Handle *handle,
+ struct GNUNET_MESSENGER_Room *room)
+{
+ GNUNET_assert((handle) && (room));
+
+ const char *name = GNUNET_MESSENGER_get_name(handle);
+
+ if (!name)
+ return;
+
+ struct GNUNET_MESSENGER_Message msg;
+
+ msg.header.kind = GNUNET_MESSENGER_KIND_NAME;
+ msg.body.name.name = GNUNET_strdup(name);
+
+ GNUNET_MESSENGER_send_message(room, &msg, NULL);
+
+ GNUNET_free(msg.body.name.name);
+}
+
struct GNUNET_CHAT_HandleIterateGroups
{
struct GNUNET_CHAT_Handle *handle;