diff --git a/libdc/src/channel.c b/libdc/src/channel.c index afb1427..20fd937 100644 --- a/libdc/src/channel.c +++ b/libdc/src/channel.c @@ -284,10 +284,16 @@ void dc_channel_add_recipient(dc_channel_t c, dc_account_t a) bool dc_channel_has_recipient(dc_channel_t c, dc_account_t a) { + size_t i = 0; return_if_true(c == NULL || a == NULL, false); - return g_ptr_array_find_with_equal_func( - c->recipients, a, (GEqualFunc)dc_account_equal, NULL - ); + + for (i = 0; i < c->recipients->len; i++) { + if (dc_account_equal(g_ptr_array_index(c->recipients, i), a)) { + return true; + } + } + + return false; } diff --git a/libdc/src/session.c b/libdc/src/session.c index def3dd2..12a4084 100644 --- a/libdc/src/session.c +++ b/libdc/src/session.c @@ -339,19 +339,23 @@ dc_channel_t dc_session_channel_recipients(dc_session_t s, GHashTableIter iter; gpointer key, value; - size_t i = 0, j = 0; + size_t i = 0; g_hash_table_iter_init(&iter, s->channels); while (g_hash_table_iter_next(&iter, &key, &value)) { dc_channel_t chan = (dc_channel_t)value; bool found = true; + if (dc_channel_recipients(chan) == 0) { + continue; + } + if (dc_channel_recipients(chan) != sz) { continue; } for (i = 0; i < sz; i++) { - if (!dc_channel_has_recipient(chan, r[j])) { + if (!dc_channel_has_recipient(chan, r[i])) { found = false; break; }