diff options
Diffstat (limited to 'matrix-roommembers.c')
-rw-r--r-- | matrix-roommembers.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/matrix-roommembers.c b/matrix-roommembers.c index a437796..cfe36a0 100644 --- a/matrix-roommembers.c +++ b/matrix-roommembers.c @@ -314,3 +314,27 @@ GList *matrix_roommembers_get_active_members( } return members; } + + +/** + * Get the userid of a member of a room, given their displayname + * + * @returns a string, which will be freed by the caller, or null if not known + */ +gchar *matrix_roommembers_displayname_to_userid( + MatrixRoomMemberTable *table, const gchar *who) +{ + /* TODO: make this more efficient */ + GHashTableIter iter; + gpointer key, value; + g_hash_table_iter_init (&iter, table->hash_table); + while (g_hash_table_iter_next (&iter, &key, &value)) { + const gchar *user_id = key; + MatrixRoomMember *member = value; + if(member->current_displayname != NULL + && strcmp(who, member->current_displayname) == 0) { + return g_strdup(user_id); + } + } + return NULL; +} |