core: Better error handling for deleting users.
This commit is contained in:
11
src/api.js.c
11
src/api.js.c
@@ -1108,16 +1108,19 @@ static void _tf_ssb_delete_user_work(tf_ssb_t* ssb, void* user_data)
|
||||
size_t length = strlen("user:") + strlen(work->user) + 1;
|
||||
char* buffer = alloca(length);
|
||||
snprintf(buffer, length, "user:%s", work->user);
|
||||
tf_ssb_db_remove_property(ssb, "auth", buffer);
|
||||
tf_ssb_db_remove_value_from_array_property(ssb, "auth", "users", work->user);
|
||||
work->completed = true;
|
||||
work->completed = tf_ssb_db_remove_property(ssb, "auth", buffer) || work->completed;
|
||||
work->completed = tf_ssb_db_remove_value_from_array_property(ssb, "auth", "users", work->user) || work->completed;
|
||||
}
|
||||
|
||||
static void _tf_ssb_delete_user_after_work(tf_ssb_t* ssb, int status, void* user_data)
|
||||
{
|
||||
delete_user_t* work = user_data;
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
JSValue error = JS_Call(context, work->promise[0], JS_UNDEFINED, 1, &work->result);
|
||||
if (!work->completed && JS_IsUndefined(work->result))
|
||||
{
|
||||
work->result = JS_NewString(context, "User not found.");
|
||||
}
|
||||
JSValue error = JS_Call(context, work->completed ? work->promise[0] : work->promise[1], JS_UNDEFINED, 1, &work->result);
|
||||
JS_FreeValue(context, work->result);
|
||||
tf_util_report_error(context, error);
|
||||
JS_FreeValue(context, error);
|
||||
|
||||
Reference in New Issue
Block a user