fix /msg command

This commit is contained in:
Florian Stinglmayr 2019-07-17 21:17:54 +02:00
parent d43d008cb8
commit 85d6134d33
2 changed files with 15 additions and 5 deletions

View File

@ -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;
}

View File

@ -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;
}