Fix feed replication. Ugh, Cory.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4104 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-01-04 02:59:35 +00:00
parent 8ed359327c
commit ff06e91ac8
2 changed files with 31 additions and 22 deletions

View File

@ -320,6 +320,9 @@ function ebtReplicateServer(request) {
ssb.addRpc(['ebt', 'replicate'], ebtReplicateServer);
ssb.addRpc(['createHistoryStream'], function(request) {
if (!request?.args) {
print('missing request.args in createHistoryStream');
}
var id = request.args[0].id;
var seq = request.args[0].seq;
var keys = request.args[0].keys || request.args[0].keys === undefined;

View File

@ -1010,9 +1010,15 @@ static following_t* _get_following(tf_ssb_t* ssb, const char* id, following_t***
{
int index = tf_util_insert_index(id, *following, *following_count, sizeof(following_t*), _following_compare);
following_t* entry = NULL;
bool already_populated = false;
if (index < *following_count && strcmp(id, (*following)[index]->id) == 0)
{
entry = (*following)[index];
already_populated = entry->depth < max_depth;
if (depth < entry->depth)
{
entry->depth = depth;
}
}
else
{
@ -1027,8 +1033,9 @@ static following_t* _get_following(tf_ssb_t* ssb, const char* id, following_t***
memset(entry, 0, sizeof(*entry));
snprintf(entry->id, sizeof(entry->id), "%s", id);
entry->depth = depth;
}
if (depth < max_depth)
if (depth < max_depth && !already_populated)
{
sqlite3* db = tf_ssb_get_db(ssb);
sqlite3_stmt* statement = NULL;
@ -1062,7 +1069,6 @@ static following_t* _get_following(tf_ssb_t* ssb, const char* id, following_t***
sqlite3_finalize(statement);
}
}
}
return entry;
}