ssb: Don't require -u for the private command. #119

This commit is contained in:
2025-05-05 21:51:38 -04:00
parent cf81ebe8ad
commit 3bf19fabda
3 changed files with 50 additions and 2 deletions

View File

@ -566,11 +566,11 @@ static int _tf_command_private(const char* file, int argc, char* argv[])
}
}
if (show_usage || !user || !identity || !recipients || !text)
if (show_usage || !identity || !recipients || !text)
{
tf_printf("\n%s private [options]\n\n", file);
tf_printf("options:\n");
tf_printf(" -u, --user user User owning identity with which to publish.\n");
tf_printf(" -u, --user user User owning identity with which to publish (optional).\n");
tf_printf(" -i, --id identity Identity with which to publish message.\n");
tf_printf(" -r, --recipients recipients Recipient identities.\n");
tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path);
@ -591,6 +591,13 @@ static int _tf_command_private(const char* file, int argc, char* argv[])
recipient_list[recipient_count++] = identity;
bool free_user = false;
if (!user)
{
user = tf_ssb_db_get_user_for_identity(ssb, identity);
free_user = true;
}
if (tf_ssb_db_identity_get_private_key(ssb, user, identity, private_key, sizeof(private_key)))
{
char* copy = tf_strdup(recipients);
@ -642,6 +649,11 @@ static int _tf_command_private(const char* file, int argc, char* argv[])
{
tf_printf("Did not find private key for identity %s belonging to %s.\n", identity, user);
}
if (free_user)
{
tf_free((void*)user);
}
done:
tf_ssb_destroy(ssb);
tf_free((void*)default_db_path);