Everywhere: Make session->send() callable

This commit is contained in:
Alec Murphy 2025-02-20 08:24:04 -05:00
parent 40b3fceab1
commit c6f74cfa84
26 changed files with 87 additions and 48 deletions

View file

@ -157,7 +157,7 @@ U0 @slon_api_v1_accounts_post(SlonHttpSession* session)
relationship->set("requested", FALSE, JSON_BOOLEAN); relationship->set("requested", FALSE, JSON_BOOLEAN);
relationship->set("domain_blocking", FALSE, JSON_BOOLEAN); relationship->set("domain_blocking", FALSE, JSON_BOOLEAN);
relationship->set("endorsed", FALSE, JSON_BOOLEAN); relationship->set("endorsed", FALSE, JSON_BOOLEAN);
@slon_http_send_json(session, relationship); session->send(relationship);
goto slon_api_v1_accounts_post_return; goto slon_api_v1_accounts_post_return;
} }
session->status(404); session->status(404);
@ -229,7 +229,7 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
} }
} }
@slon_http_send_json(session, relationships); session->send(relationships);
Json.Delete(relationships); Json.Delete(relationships);
goto slon_api_v1_accounts_get_return; goto slon_api_v1_accounts_get_return;
} else { } else {
@ -240,7 +240,7 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
SLON_AUTH_ACCOUNT_ID SLON_AUTH_ACCOUNT_ID
acct = @slon_api_account_by_id(account_id); acct = @slon_api_account_by_id(account_id);
if (acct) { if (acct) {
@slon_http_send_json(session, acct); session->send(acct);
} else { } else {
session->status(404); session->status(404);
} }
@ -259,7 +259,7 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
U8* method = path_segments[4]; U8* method = path_segments[4];
if (!StrICmp("following", method)) { if (!StrICmp("following", method)) {
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
goto slon_api_v1_accounts_get_return; goto slon_api_v1_accounts_get_return;
} }
if (!StrICmp("statuses", method)) { if (!StrICmp("statuses", method)) {
@ -329,7 +329,7 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
} }
} }
@slon_http_send_json(session, statuses); session->send(statuses);
Json.Delete(statuses); Json.Delete(statuses);
goto slon_api_v1_accounts_get_return; goto slon_api_v1_accounts_get_return;
@ -339,7 +339,7 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
// Return the Account profile // Return the Account profile
JsonObject* profile_object = Json.Clone(acct); JsonObject* profile_object = Json.Clone(acct);
profile_object->unset("source"); profile_object->unset("source");
@slon_http_send_json(session, profile_object); session->send(profile_object);
Json.Delete(profile_object); Json.Delete(profile_object);
} }
} }
@ -487,7 +487,7 @@ U0 @slon_api_v1_accounts_patch(SlonHttpSession* session)
@slon_db_save_accounts_to_disk; @slon_db_save_accounts_to_disk;
@slon_db_actors_update_user(acct); @slon_db_actors_update_user(acct);
@slon_http_send_json(session, acct); session->send(acct);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -65,7 +65,7 @@ U0 @slon_api_v1_apps_post(SlonHttpSession* session)
db->o("apps")->set(client_id, credential_app, JSON_OBJECT); db->o("apps")->set(client_id, credential_app, JSON_OBJECT);
@slon_db_save_apps_to_disk; @slon_db_save_apps_to_disk;
@slon_http_send_json(session, credential_app); session->send(credential_app);
@slon_free(session, id); @slon_free(session, id);
@slon_free(session, client_id); @slon_free(session, client_id);

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_blocks_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_bookmarks_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_conversations_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_custom_emojis_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_favourites_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_filters_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_follow_requests_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_followed_tags_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -6,9 +6,9 @@ U0 @slon_api_v1_notifications_get(SlonHttpSession* session)
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
if (String.EndsWith("policy", @slon_http_request_path(session))) { if (String.EndsWith("policy", @slon_http_request_path(session))) {
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT); session->send(SLON_EMPTY_JSON_OBJECT);
} else { } else {
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} }
} else { } else {
session->status(401); session->status(401);

View file

@ -8,7 +8,7 @@ U0 @slon_api_v1_statuses_delete(SlonHttpSession* session)
JsonArray* statuses = db->o("statuses")->a(account_id); JsonArray* statuses = db->o("statuses")->a(account_id);
if (!statuses || !statuses->length) { if (!statuses || !statuses->length) {
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT); session->send(SLON_EMPTY_JSON_OBJECT);
return; return;
} }
@ -43,7 +43,7 @@ U0 @slon_api_v1_statuses_delete(SlonHttpSession* session)
slon_api_v1_statuses_delete_return: slon_api_v1_statuses_delete_return:
Free(path_segments); Free(path_segments);
@slon_free(session, path); @slon_free(session, path);
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT); session->send(SLON_EMPTY_JSON_OBJECT);
} else { } else {
session->status(401); session->status(401);
} }
@ -130,7 +130,7 @@ U0 @slon_api_v1_statuses_post(SlonHttpSession* session)
} }
} }
@slon_http_send_json(session, status); session->send(status);
Json.Delete(status_app); Json.Delete(status_app);
Json.Delete(account_object); Json.Delete(account_object);

View file

@ -6,7 +6,7 @@ U0 @slon_api_v1_timelines_home(SlonHttpSession* session, U8* account_id)
// Return the Account's Home timeline // Return the Account's Home timeline
JsonArray* status_array = db->o("timelines")->o("home")->a(account_id); JsonArray* status_array = db->o("timelines")->o("home")->a(account_id);
if (!status_array) { if (!status_array) {
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
return; return;
} }
@ -74,7 +74,7 @@ U0 @slon_api_v1_timelines_home(SlonHttpSession* session, U8* account_id)
} }
} }
@slon_http_send_json(session, statuses); session->send(statuses);
Json.Delete(statuses); Json.Delete(statuses);
} }
@ -94,13 +94,13 @@ U0 @slon_api_v1_timelines_get(SlonHttpSession* session)
if (!StrICmp("public", path_segments[3])) { if (!StrICmp("public", path_segments[3])) {
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
goto slon_api_v1_timelines_get_return; goto slon_api_v1_timelines_get_return;
} }
if (!StrICmp("tag", path_segments[3])) { if (!StrICmp("tag", path_segments[3])) {
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
goto slon_api_v1_timelines_get_return; goto slon_api_v1_timelines_get_return;
} }
@ -112,13 +112,13 @@ U0 @slon_api_v1_timelines_get(SlonHttpSession* session)
if (!StrICmp("link", path_segments[3])) { if (!StrICmp("link", path_segments[3])) {
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
goto slon_api_v1_timelines_get_return; goto slon_api_v1_timelines_get_return;
} }
if (!StrICmp("list", path_segments[3])) { if (!StrICmp("list", path_segments[3])) {
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
goto slon_api_v1_timelines_get_return; goto slon_api_v1_timelines_get_return;
} }

View file

@ -5,7 +5,7 @@ U0 @slon_api_v2_filters_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -5,5 +5,5 @@ U0 @slon_api_v2_instance_get(SlonHttpSession* session)
StrPrint(scratch_buffer, "{\"domain\":\"%s\"}", db->o("instance")->@("uri")); StrPrint(scratch_buffer, "{\"domain\":\"%s\"}", db->o("instance")->@("uri"));
@slon_http_set_content_type(session, "application/json; charset=utf-8"); @slon_http_set_content_type(session, "application/json; charset=utf-8");
@slon_http_send_string(session, scratch_buffer); session->send(scratch_buffer);
} }

View file

@ -200,7 +200,7 @@ U0 @slon_api_v2_search_get(SlonHttpSession* session)
} }
slon_api_v2_search_get_return: slon_api_v2_search_get_return:
@slon_http_send_json(session, results); session->send(results);
Json.Delete(results); Json.Delete(results);
} else { } else {
session->status(401); session->status(401);

View file

@ -5,7 +5,7 @@ U0 @slon_api_v2_suggestions_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) { if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID // SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_ARRAY); session->send(SLON_EMPTY_JSON_ARRAY);
} else { } else {
session->status(401); session->status(401);
} }

View file

@ -1,5 +1,5 @@
if (!StrICmp("/api/v1/instance", @slon_http_request_path(session))) { if (!StrICmp("/api/v1/instance", @slon_http_request_path(session))) {
@slon_http_send_json(session, db->o("instance")); session->send(db->o("instance"));
return; return;
} }

View file

@ -245,7 +245,7 @@ U0 @slon_admin_delete_account(SlonHttpSession* session)
} }
} }
@slon_db_save_to_disk; @slon_db_save_to_disk;
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT); session->send(SLON_EMPTY_JSON_OBJECT);
} }
U0 @slon_admin_new_account(SlonHttpSession* session) U0 @slon_admin_new_account(SlonHttpSession* session)
@ -255,16 +255,16 @@ U0 @slon_admin_new_account(SlonHttpSession* session)
if (db->o("actors")->@(request_json->@("username"))) { if (db->o("actors")->@(request_json->@("username"))) {
StrPrint(scratch_buffer, "{\"error\":\"account already exists\"}"); StrPrint(scratch_buffer, "{\"error\":\"account already exists\"}");
@slon_http_set_content_type(session, "application/json"); @slon_http_set_content_type(session, "application/json");
@slon_http_send(session, scratch_buffer, StrLen(scratch_buffer)); session->send(scratch_buffer, StrLen(scratch_buffer));
} else { } else {
@slon_admin_create_account(session); @slon_admin_create_account(session);
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT); session->send(SLON_EMPTY_JSON_OBJECT);
} }
} }
U0 @slon_admin_manage_accounts(SlonHttpSession* session) U0 @slon_admin_manage_accounts(SlonHttpSession* session)
{ {
@slon_http_send_json(session, db->a("accounts")); session->send(db->a("accounts"));
} }
U0 @slon_admin_info_stats(SlonHttpSession* session) U0 @slon_admin_info_stats(SlonHttpSession* session)
@ -277,7 +277,7 @@ U0 @slon_admin_info_stats(SlonHttpSession* session)
String.Append(scratch_buffer, "}"); String.Append(scratch_buffer, "}");
@slon_http_set_content_type(session, "application/json"); @slon_http_set_content_type(session, "application/json");
@slon_http_send(session, scratch_buffer, StrLen(scratch_buffer)); session->send(scratch_buffer, StrLen(scratch_buffer));
} }
U0 @slon_admin_server_get(SlonHttpSession* session) U0 @slon_admin_server_get(SlonHttpSession* session)
@ -330,7 +330,7 @@ U0 @slon_admin_setup_instance(SlonHttpSession* session)
@slon_db_save_to_disk; @slon_db_save_to_disk;
db->set("setup", TRUE); db->set("setup", TRUE);
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT); session->send(SLON_EMPTY_JSON_OBJECT);
} }
U0 @slon_admin_server_post(SlonHttpSession* session) U0 @slon_admin_server_post(SlonHttpSession* session)

View file

@ -107,7 +107,7 @@ U0 @slon_local_server_directory_listing(SlonHttpSession* session, U8* path)
String.Append(html, "</body></html>"); String.Append(html, "</body></html>");
@slon_http_set_content_type(session, "text/html"); @slon_http_set_content_type(session, "text/html");
@slon_http_send(session, html, StrLen(html)); session->send(html, StrLen(html));
@slon_free(session, html); @slon_free(session, html);
} }
@ -115,7 +115,7 @@ U0 @slon_local_server_not_found(SlonHttpSession* session)
{ {
session->status(404); session->status(404);
@slon_http_set_content_type(session, "text/html"); @slon_http_set_content_type(session, "text/html");
@slon_http_send(session, "<h2>404 Not Found</h2>", 22); session->send("<h2>404 Not Found</h2>", 22);
} }
U0 @slon_local_server_get(SlonHttpSession* session) U0 @slon_local_server_get(SlonHttpSession* session)

View file

@ -102,6 +102,27 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
a += 0x31; a += 0x31;
@patch_call_rel32(a, &@slon_http_set_header); @patch_call_rel32(a, &@slon_http_set_header);
// Create a copy of function and patch send
code_size = MSize(&@slon_session_send_wrapper_function);
session->send = CAlloc(code_size, adam_task->code_heap);
MemCpy(session->send, &@slon_session_send_wrapper_function, code_size);
a = session->send;
a += 0x16;
MemSetI64(a, session, 1);
a = session->send;
a += 0x33;
@patch_call_rel32(a, &@slon_http_send_json);
a = session->send;
a += 0x41;
@patch_call_rel32(a, &@slon_http_send_string);
a = session->send;
a += 0x4c;
@patch_call_rel32(a, &@slon_http_send);
return session; return session;
} }
@ -409,7 +430,7 @@ U0 @slon_http_handle_delete_request(SlonHttpSession* session)
/* clang-format on */ /* clang-format on */
// FIXME: Implement this // FIXME: Implement this
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT); session->send(SLON_EMPTY_JSON_OBJECT);
} }
U0 @slon_http_handle_get_request(SlonHttpSession* session) U0 @slon_http_handle_get_request(SlonHttpSession* session)

View file

@ -64,6 +64,7 @@ class SlonHttpSession {
U8* actor_for_key_id; U8* actor_for_key_id;
U8* (*header)(U8* key, U8* value = NULL); U8* (*header)(U8* key, U8* value = NULL);
U0 (*send)(U64 payload, I64 size = NULL);
I64 (*status)(I64 code = NULL); I64 (*status)(I64 code = NULL);
}; };
@ -209,7 +210,7 @@ U0 @slon_http_send_file(SlonHttpSession* session, U8* path)
return; return;
I64 size = 0; I64 size = 0;
U8* data = FileRead(path, &size); U8* data = FileRead(path, &size);
@slon_http_send(session, data, size); session->send(data, size);
Free(data); Free(data);
} }
@ -278,3 +279,20 @@ U8* @slon_session_header_wrapper_function(U8* key, U8* value = NULL)
@slon_http_set_header(session, key, value); @slon_http_set_header(session, key, value);
return value; return value;
} }
U0 @slon_session_send_wrapper_function(U64 payload, I64 size = NULL)
{
SlonHttpSession* session = SLON_WRAPPER_MAGIC_NUMBER;
if (!payload) {
return;
}
if (*payload(U32*) == JSON_SIG) {
@slon_http_send_json(session, payload);
return;
}
if (!size) {
@slon_http_send_string(session, payload);
} else {
@slon_http_send(session, payload, size);
}
}

View file

@ -5,5 +5,5 @@ U0 @slon_host_meta(SlonHttpSession* session)
StrPrint(scratch_buffer, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\"><Link rel=\"lrdd\" template=\"https://%s/.well-known/webfinger?resource={uri}\"/></XRD>", db->o("instance")->@("uri")); StrPrint(scratch_buffer, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\"><Link rel=\"lrdd\" template=\"https://%s/.well-known/webfinger?resource={uri}\"/></XRD>", db->o("instance")->@("uri"));
@slon_http_set_content_type(session, "application/xrd+xml; charset=utf-8"); @slon_http_set_content_type(session, "application/xrd+xml; charset=utf-8");
@slon_http_send_string(session, scratch_buffer); session->send(scratch_buffer);
} }

View file

@ -8,7 +8,7 @@ U0 @slon_oauth_well_known(SlonHttpSession* session)
StrPrint(scratch_buffer, "{\"issuer\":\"https://%s\",\"authorization_endpoint\":\"https://%s/oauth/authorize\",\"response_types_supported\":[\"code\"],\"app_registration_endpoint\":\"https://%s/api/v1/apps\"}", StrPrint(scratch_buffer, "{\"issuer\":\"https://%s\",\"authorization_endpoint\":\"https://%s/oauth/authorize\",\"response_types_supported\":[\"code\"],\"app_registration_endpoint\":\"https://%s/api/v1/apps\"}",
db->o("instance")->@("uri"), db->o("instance")->@("uri"), db->o("instance")->@("uri")); db->o("instance")->@("uri"), db->o("instance")->@("uri"), db->o("instance")->@("uri"));
@slon_http_set_content_type(session, "application/json; charset=utf-8"); @slon_http_set_content_type(session, "application/json; charset=utf-8");
@slon_http_send_string(session, scratch_buffer); session->send(scratch_buffer);
} }
U0 @slon_oauth_fetch_token(U8* client_id) U0 @slon_oauth_fetch_token(U8* client_id)
@ -132,7 +132,7 @@ U0 @slon_oauth_verify_access_get(SlonHttpSession* session)
StrPrint(scratch_buffer, "%s?code=%s", redirect_uri, authorization_code); StrPrint(scratch_buffer, "%s?code=%s", redirect_uri, authorization_code);
JsonObject* redirect_uri_object = Json.CreateObject(); JsonObject* redirect_uri_object = Json.CreateObject();
redirect_uri_object->set("redirect_uri", scratch_buffer, JSON_STRING); redirect_uri_object->set("redirect_uri", scratch_buffer, JSON_STRING);
@slon_http_send_json(session, redirect_uri_object); session->send(redirect_uri_object);
Json.Delete(redirect_uri_object); Json.Delete(redirect_uri_object);
@slon_free(session, authorization_code); @slon_free(session, authorization_code);
@ -178,7 +178,7 @@ U0 @slon_oauth_token_post(SlonHttpSession* session)
if (!StrCmp(client_id, code_object->@("client_id")) && !StrCmp(client_secret, code_object->@("client_secret"))) { if (!StrCmp(client_id, code_object->@("client_id")) && !StrCmp(client_secret, code_object->@("client_secret"))) {
JsonObject* token = db->o("oauth")->o("tokens")->@(access_token); JsonObject* token = db->o("oauth")->o("tokens")->@(access_token);
if (token) { if (token) {
@slon_http_send_json(session, token); session->send(token);
} else { } else {
// If the token doesn't exist, Page Expired? // If the token doesn't exist, Page Expired?
session->status(419); session->status(419);

View file

@ -26,7 +26,7 @@ U0 @slon_web_user_get(SlonHttpSession* session)
String.Append(html_data, user_file_data); String.Append(html_data, user_file_data);
String.Append(html_data, ");</script>"); String.Append(html_data, ");</script>");
@slon_http_set_content_type(session, "text/html"); @slon_http_set_content_type(session, "text/html");
@slon_http_send(session, html_data, StrLen(html_data)); session->send(html_data, StrLen(html_data));
Free(html_file_data); Free(html_file_data);
Free(user_file_data); Free(user_file_data);

View file

@ -28,7 +28,7 @@ U0 @slon_webfinger(SlonHttpSession* session)
links->append(Json.CreateItem(link_object, JSON_OBJECT)); links->append(Json.CreateItem(link_object, JSON_OBJECT));
webfinger_object->set("links", links, JSON_ARRAY); webfinger_object->set("links", links, JSON_ARRAY);
@slon_http_send_json(session, webfinger_object); session->send(webfinger_object);
Json.Delete(webfinger_object); Json.Delete(webfinger_object);
} else { } else {
session->status(404); session->status(404);