summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
authorGravatar default2025-01-16 14:20:07 +0100
committerGravatar default2025-01-16 14:20:07 +0100
commitb993e26346f885586ff0533a3b309ed7d1e910cf (patch)
tree53c78a997b8231aea0353dfcf7d0391dd3c2f63c /httpd.c
parentUpdated RELEASE_NOTES. (diff)
downloadsnac2-b993e26346f885586ff0533a3b309ed7d1e910cf.tar.gz
snac2-b993e26346f885586ff0533a3b309ed7d1e910cf.tar.xz
snac2-b993e26346f885586ff0533a3b309ed7d1e910cf.zip
Implemented Mastodon-like /authorize_interaction.
Diffstat (limited to 'httpd.c')
-rw-r--r--httpd.c42
1 files changed, 42 insertions, 0 deletions
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 = ""
182""; 182"";
183 183
184 184
185const char *authorize_interaction_page = ""
186"<!DOCTYPE html>\n"
187"<html>\n"
188"<head>\n"
189"<title>%s - snac</title>\n"
190"<meta content=\"width=device-width, initial-scale=1, minimum-scale=1, user-scalable=no\" name=\"viewport\">\n"
191"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s/style.css\"/>\n"
192"<style>:root {color-scheme: light dark}</style>\n"
193"</head>\n"
194"<body><h1>%s authorize interaction</h1>\n"
195"<form method=\"get\" action=\"%s/auth-int-bridge\">\n"
196"<select name=\"action\">\n"
197"<option value=\"Follow\">Follow</option>\n"
198"<option value=\"Like\">Like</option>\n"
199"<option value=\"Boost\">Boost</option>\n"
200"</select> %s\n"
201"<input type=\"hidden\" name=\"id\" value=\"%s\">\n"
202"<p>Login: <input type=\"text\" name=\"login\" autocapitalize=\"off\" required=\"required\"></p>\n"
203"<input type=\"submit\" value=\"OK\">\n"
204"</form><p>%s</p></body></html>\n"
205"";
206
207
185int server_get_handler(xs_dict *req, const char *q_path, 208int server_get_handler(xs_dict *req, const char *q_path,
186 char **body, int *b_size, char **ctype) 209 char **body, int *b_size, char **ctype)
187/* basic server services */ 210/* basic server services */
@@ -318,6 +341,25 @@ int server_get_handler(xs_dict *req, const char *q_path,
318 USER_AGENT 341 USER_AGENT
319 ); 342 );
320 } 343 }
344 else
345 if (strcmp(q_path, "/authorize_interaction") == 0) {
346 const xs_dict *q_vars = xs_dict_get(req, "q_vars");
347 const char *uri = xs_dict_get(q_vars, "uri");
348
349 if (xs_is_string(uri)) {
350 status = HTTP_STATUS_OK;
351 *ctype = "text/html; charset=utf-8";
352 *body = xs_fmt(authorize_interaction_page,
353 xs_dict_get(srv_config, "host"),
354 srv_baseurl,
355 xs_dict_get(srv_config, "host"),
356 srv_baseurl,
357 uri,
358 uri,
359 USER_AGENT
360 );
361 }
362 }
321 363
322 if (status != 0) 364 if (status != 0)
323 srv_debug(1, xs_fmt("server_get_handler serving '%s' %d", q_path, status)); 365 srv_debug(1, xs_fmt("server_get_handler serving '%s' %d", q_path, status));