ssb: Allow otherwise unrecognized incoming connections when not talking to strangers if they have a valid invite.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 31m17s

This commit is contained in:
2025-02-16 08:45:08 -05:00
parent 478bcd5d13
commit 1cfac3cae6
3 changed files with 38 additions and 7 deletions

View File

@ -2269,3 +2269,19 @@ bool tf_ssb_db_use_invite(sqlite3* db, const char* id)
return used;
}
bool tf_ssb_db_has_invite(sqlite3* db, const char* id)
{
bool has = false;
sqlite3_stmt* statement;
if (sqlite3_prepare(db, "SELECT COUNT(*) FROM invites WHERE invite_public_key = ? AND (expires < 0 OR expires >= ?) AND (use_count > 0 OR use_count = -1)", -1, &statement,
NULL) == SQLITE_OK)
{
if (sqlite3_bind_text(statement, 1, id, -1, NULL) == SQLITE_OK && sqlite3_bind_int64(statement, 2, (int64_t)time(NULL)) == SQLITE_OK)
{
has = sqlite3_step(statement) == SQLITE_ROW && sqlite3_column_int(statement, 0) > 0;
}
sqlite3_finalize(statement);
}
return has;
}