forked from cory/tildefriends
ssb: Make blocks begin to do something.
This commit is contained in:
@@ -221,6 +221,14 @@ static void _ebt_add_to_clock(ebt_get_clock_t* work, const char* id, int64_t val
|
||||
}
|
||||
}
|
||||
|
||||
static bool _is_blocked(tf_ssb_t* ssb, const char* id)
|
||||
{
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
bool blocked = tf_ssb_db_is_blocked(db, id);
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
return blocked;
|
||||
}
|
||||
|
||||
static void _tf_ssb_ebt_get_send_clock_work(tf_ssb_connection_t* connection, void* user_data)
|
||||
{
|
||||
ebt_get_clock_t* work = user_data;
|
||||
@@ -239,7 +247,10 @@ static void _tf_ssb_ebt_get_send_clock_work(tf_ssb_connection_t* connection, voi
|
||||
for (int i = 0; visible[i]; i++)
|
||||
{
|
||||
int32_t sequence = 0;
|
||||
tf_ssb_db_get_latest_message_by_author(ssb, visible[i], &sequence, NULL, 0);
|
||||
if (!_is_blocked(ssb, visible[i]))
|
||||
{
|
||||
tf_ssb_db_get_latest_message_by_author(ssb, visible[i], &sequence, NULL, 0);
|
||||
}
|
||||
sequences = tf_resize_vec(sequences, (i + 1) * sizeof(int32_t));
|
||||
sequences[i] = sequence;
|
||||
}
|
||||
@@ -259,11 +270,14 @@ static void _tf_ssb_ebt_get_send_clock_work(tf_ssb_connection_t* connection, voi
|
||||
char id[k_id_base64_len] = "";
|
||||
if (tf_ssb_connection_get_id(connection, id, sizeof(id)))
|
||||
{
|
||||
int32_t sequence = 0;
|
||||
tf_ssb_db_get_latest_message_by_author(ssb, id, &sequence, NULL, 0);
|
||||
uv_mutex_lock(&work->ebt->mutex);
|
||||
_ebt_add_to_clock(work, id, sequence, true, true);
|
||||
uv_mutex_unlock(&work->ebt->mutex);
|
||||
if (!_is_blocked(ssb, id))
|
||||
{
|
||||
int32_t sequence = 0;
|
||||
tf_ssb_db_get_latest_message_by_author(ssb, id, &sequence, NULL, 0);
|
||||
uv_mutex_lock(&work->ebt->mutex);
|
||||
_ebt_add_to_clock(work, id, sequence, true, true);
|
||||
uv_mutex_unlock(&work->ebt->mutex);
|
||||
}
|
||||
}
|
||||
|
||||
/* Also respond with what we know about all requested identities. */
|
||||
@@ -287,7 +301,10 @@ static void _tf_ssb_ebt_get_send_clock_work(tf_ssb_connection_t* connection, voi
|
||||
{
|
||||
for (int i = 0; i < requested_count; i++)
|
||||
{
|
||||
tf_ssb_db_get_latest_message_by_author(ssb, requested[i].id, &requested[i].value, NULL, 0);
|
||||
if (!_is_blocked(ssb, requested[i].id))
|
||||
{
|
||||
tf_ssb_db_get_latest_message_by_author(ssb, requested[i].id, &requested[i].value, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
uv_mutex_lock(&work->ebt->mutex);
|
||||
|
||||
Reference in New Issue
Block a user