ssb: Follow + block = block.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m4s

This commit is contained in:
2025-11-19 18:49:08 -05:00
parent 775fdafa63
commit 111a6c3c6e
2 changed files with 49 additions and 6 deletions

View File

@@ -1597,8 +1597,10 @@ typedef struct _following_t
int depth;
following_t** following;
following_t** blocking;
following_t** both;
int following_count;
int blocking_count;
int both_count;
int ref_count;
int block_ref_count;
} following_t;
@@ -1715,14 +1717,27 @@ static void _populate_follows_and_blocks(
{
if (_add_following_entry(&entry->following, &entry->following_count, next))
{
next->ref_count++;
if (next->ref_count++ == 0 && next->block_ref_count)
{
if (_remove_following_entry(&entry->blocking, &entry->blocking_count, next))
{
_remove_following_entry(&entry->following, &entry->following_count, next);
_add_following_entry(&entry->both, &entry->both_count, next);
}
}
}
}
else
{
if (_remove_following_entry(&entry->following, &entry->following_count, next))
{
next->ref_count--;
if (next->ref_count-- == 1 && next->block_ref_count)
{
if (_remove_following_entry(&entry->both, &entry->both_count, next))
{
_add_following_entry(&entry->blocking, &entry->blocking_count, next);
}
}
}
}
}
@@ -1737,14 +1752,29 @@ static void _populate_follows_and_blocks(
{
if (_add_following_entry(&entry->blocking, &entry->blocking_count, next))
{
next->block_ref_count++;
if (next->block_ref_count++ == 0 && next->ref_count)
{
if (_remove_following_entry(&entry->following, &entry->following_count, next))
{
next->ref_count--;
_remove_following_entry(&entry->blocking, &entry->blocking_count, next);
_add_following_entry(&entry->both, &entry->both_count, next);
}
}
}
}
else
{
if (_remove_following_entry(&entry->blocking, &entry->blocking_count, next))
{
next->block_ref_count--;
if (next->block_ref_count-- == 1)
{
if (_remove_following_entry(&entry->both, &entry->both_count, next))
{
next->ref_count++;
_add_following_entry(&entry->following, &entry->following_count, next);
}
}
}
}
}
@@ -1841,6 +1871,7 @@ tf_ssb_following_t* tf_ssb_db_following_deep(tf_ssb_t* ssb, const char** ids, in
{
tf_free(following[i]->following);
tf_free(following[i]->blocking);
tf_free(following[i]->both);
tf_free(following[i]);
}
tf_free(following);
@@ -1892,6 +1923,7 @@ const char** tf_ssb_db_following_deep_ids(tf_ssb_t* ssb, const char** ids, int c
{
tf_free(following[i]->following);
tf_free(following[i]->blocking);
tf_free(following[i]->both);
tf_free(following[i]);
}
tf_free(following);

View File

@@ -639,8 +639,14 @@ void tf_ssb_test_following(const tf_test_options_t* options)
message = JS_NewObject(context); \
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "contact")); \
JS_SetPropertyStr(context, message, "contact", JS_NewString(context, contact)); \
JS_SetPropertyStr(context, message, "following", follow ? JS_TRUE : JS_FALSE); \
JS_SetPropertyStr(context, message, "blocking", block ? JS_TRUE : JS_FALSE); \
if (follow) \
{ \
JS_SetPropertyStr(context, message, "following", JS_TRUE); \
} \
if (block) \
{ \
JS_SetPropertyStr(context, message, "blocking", JS_TRUE); \
} \
signed_message = tf_ssb_sign_message(ssb0, id, priv, message, NULL, 0); \
stored = false; \
tf_ssb_verify_strip_and_store_message(ssb0, signed_message, _message_stored, &stored); \
@@ -660,6 +666,11 @@ void tf_ssb_test_following(const tf_test_options_t* options)
_assert_visible(ssb0, id0, id1, true);
_assert_visible(ssb0, id0, id2, true);
_assert_visible(ssb0, id0, id3, false);
FOLLOW_BLOCK(id0, priv0, id1, false, true);
_assert_visible(ssb0, id0, id0, true);
_assert_visible(ssb0, id0, id1, false);
_assert_visible(ssb0, id0, id2, false);
_assert_visible(ssb0, id0, id3, false);
#undef FOLLOW_BLOCK