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
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 31m17s
This commit is contained in:
16
src/ssb.db.c
16
src/ssb.db.c
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user