From 932227bbac7fe740bff1e38bf92b58edef19e32f Mon Sep 17 00:00:00 2001 From: default Date: Wed, 8 Jan 2025 16:59:14 +0100 Subject: Bumped copyright year. --- httpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httpd.c') diff --git a/httpd.c b/httpd.c index 163f98a..dda40b9 100644 --- a/httpd.c +++ b/httpd.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2024 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" -- cgit v1.2.3 From b993e26346f885586ff0533a3b309ed7d1e910cf Mon Sep 17 00:00:00 2001 From: default Date: Thu, 16 Jan 2025 14:20:07 +0100 Subject: Implemented Mastodon-like /authorize_interaction. --- httpd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'httpd.c') diff --git a/httpd.c b/httpd.c index dda40b9..74628e3 100644 --- a/httpd.c +++ b/httpd.c @@ -182,6 +182,29 @@ const char *share_page = "" ""; +const char *authorize_interaction_page = "" +"\n" +"\n" +"\n" +"%s - snac\n" +"\n" +"\n" +"\n" +"\n" +"

%s authorize interaction

\n" +"
\n" +" %s\n" +"\n" +"

Login:

\n" +"\n" +"

%s

\n" +""; + + int server_get_handler(xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) /* basic server services */ @@ -318,6 +341,25 @@ int server_get_handler(xs_dict *req, const char *q_path, USER_AGENT ); } + else + if (strcmp(q_path, "/authorize_interaction") == 0) { + const xs_dict *q_vars = xs_dict_get(req, "q_vars"); + const char *uri = xs_dict_get(q_vars, "uri"); + + if (xs_is_string(uri)) { + status = HTTP_STATUS_OK; + *ctype = "text/html; charset=utf-8"; + *body = xs_fmt(authorize_interaction_page, + xs_dict_get(srv_config, "host"), + srv_baseurl, + xs_dict_get(srv_config, "host"), + srv_baseurl, + uri, + uri, + USER_AGENT + ); + } + } if (status != 0) srv_debug(1, xs_fmt("server_get_handler serving '%s' %d", q_path, status)); -- cgit v1.2.3 From 04803b628b44acb773ff972a4c12071cbcf49b23 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 16 Jan 2025 18:19:19 +0100 Subject: Changed Boost/Like order in the /authorize_interaction page. --- httpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httpd.c') diff --git a/httpd.c b/httpd.c index 74628e3..7222893 100644 --- a/httpd.c +++ b/httpd.c @@ -195,8 +195,8 @@ const char *authorize_interaction_page = "" "
\n" " %s\n" "\n" "

Login:

\n" -- cgit v1.2.3 From 202d99c81529694ac3c6b524af9627404a26dd2f Mon Sep 17 00:00:00 2001 From: default Date: Mon, 20 Jan 2025 08:39:06 +0100 Subject: Added the USER_AGENT to HTTP errors. --- httpd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'httpd.c') diff --git a/httpd.c b/httpd.c index 7222893..eb72c6f 100644 --- a/httpd.c +++ b/httpd.c @@ -501,13 +501,13 @@ void httpd_connection(FILE *f) } if (status == HTTP_STATUS_FORBIDDEN) - body = xs_str_new("

403 Forbidden

"); + body = xs_str_new("

403 Forbidden (" USER_AGENT ")

"); if (status == HTTP_STATUS_NOT_FOUND) - body = xs_str_new("

404 Not Found

"); + body = xs_str_new("

404 Not Found (" USER_AGENT ")

"); if (status == HTTP_STATUS_BAD_REQUEST && body != NULL) - body = xs_str_new("

400 Bad Request

"); + body = xs_str_new("

400 Bad Request (" USER_AGENT ")

"); if (status == HTTP_STATUS_SEE_OTHER) headers = xs_dict_append(headers, "location", body); -- cgit v1.2.3 From 4416e3a28a32a848d99c0b9621256be18a60325c Mon Sep 17 00:00:00 2001 From: default Date: Mon, 20 Jan 2025 18:37:21 +0100 Subject: Fixed check for the basedir (contributed by an-im-dugud). --- httpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httpd.c') diff --git a/httpd.c b/httpd.c index eb72c6f..c13402b 100644 --- a/httpd.c +++ b/httpd.c @@ -212,7 +212,7 @@ int server_get_handler(xs_dict *req, const char *q_path, int status = 0; /* is it the server root? */ - if (*q_path == '\0') { + if (*q_path == '\0' || strcmp(q_path, "/") == 0) { const xs_dict *q_vars = xs_dict_get(req, "q_vars"); const char *t = NULL; -- cgit v1.2.3 From 2611c816b01d3999ffcf3b59c0d3592908054950 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 21 Jan 2025 20:25:50 +0100 Subject: Hide the 'relay' user from the greeting list. --- httpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httpd.c') diff --git a/httpd.c b/httpd.c index c13402b..e0a36b6 100644 --- a/httpd.c +++ b/httpd.c @@ -138,7 +138,7 @@ static xs_str *greeting_html(void) while (xs_list_iter(&p, &uid)) { snac user; - if (user_open(&user, uid)) { + if (strcmp(uid, "relay") && user_open(&user, uid)) { xs_html_add(ul, xs_html_tag("li", xs_html_tag("a", -- cgit v1.2.3