diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index 411ed5ce..a89c404e 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -410,11 +410,20 @@ static void _tf_ssb_rpc_on_connections_changed(tf_ssb_t* ssb, tf_ssb_change_t ch return; } + char connection_id[k_id_base64_len]; char id[k_id_base64_len]; - if (tf_ssb_connection_get_id(connection, id, sizeof(id))) { + if (tf_ssb_connection_get_id(connection, connection_id, sizeof(connection_id)) && + tf_ssb_whoami(ssb, id, sizeof(id))) { const char** ids = tf_ssb_get_following_deep(ssb, (const char*[]) { id, NULL }, 2); + bool found_connection_id = false; for (int i = 0; ids && ids[i]; i++) { tf_ssb_rpc_send_createHistoryStream(connection, ids[i]); + if (strcmp(ids[i], connection_id) == 0) { + found_connection_id = true; + } + } + if (!found_connection_id) { + tf_ssb_rpc_send_createHistoryStream(connection, connection_id); } free(ids); }