aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbyte <gf3qyrmw7@mozmail.com>2025-11-01 00:48:33 +0100
committerbyte <gf3qyrmw7@mozmail.com>2025-11-01 00:48:33 +0100
commit8ed4d5bdcbe552eaa0f143c71b90ff7cd2a3d709 (patch)
tree8f86ca0f28ef5c6b242a411bb6e9d38de25cf191
parenta4a1990dbb16e3e4599500299c32c980c9cbd5bf (diff)
parent074072bde45284a2f11bb8a06b5670dbd3c4a716 (diff)
Merge remote-tracking branch 'orig/master' into feature/lesser-visibility
-rw-r--r--RELEASE_NOTES.md2
-rw-r--r--activitypub.c10
-rw-r--r--data.c29
-rw-r--r--html.c5
-rw-r--r--httpd.c3
-rw-r--r--po/de_DE.po10
-rw-r--r--snac.h4
-rw-r--r--utils.c2
-rw-r--r--xs_curl.h18
9 files changed, 61 insertions, 22 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index d89bee6..7dfb332 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,6 +1,6 @@
# Release Notes
-## UNRELEASED
+## 2.84
Implemented more scopes to match other ActivityPub implementations (public, unlisted, followers-only and direct message) (contributed by byte).
diff --git a/activitypub.c b/activitypub.c
index 2d53cbe..0368ac8 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -3660,8 +3660,9 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
uid = xs_list_get(l, 1);
if (!user_open(&snac, uid)) {
/* invalid user */
- srv_debug(1, xs_fmt("activitypub_get_handler bad user %s", uid));
- return HTTP_STATUS_NOT_FOUND;
+ status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND;
+ srv_debug(1, xs_fmt("activitypub_get_handler bad user %s %d", uid, status));
+ return status;
}
p_path = xs_list_get(l, 2);
@@ -3854,8 +3855,9 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
const char *uid = xs_list_get(l, 1);
if (!user_open(&snac, uid)) {
/* invalid user */
- srv_debug(1, xs_fmt("activitypub_post_handler bad user %s", uid));
- return HTTP_STATUS_NOT_FOUND;
+ status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND;
+ srv_debug(1, xs_fmt("activitypub_post_handler bad user %s %d", uid, status));
+ return status;
}
/* if it has a digest, check it now, because
diff --git a/data.c b/data.c
index 36f5101..d291ba7 100644
--- a/data.c
+++ b/data.c
@@ -3137,6 +3137,35 @@ int instance_failure(const char *url, int op)
}
+int grave(const char *objid, int op)
+/* the graveyeard of deleted objects */
+{
+ int ret = 0;
+ xs *dir = xs_fmt("%s/grave", srv_basedir);
+ xs *md5 = xs_md5_hex(objid, strlen(objid));
+ xs *fn = xs_fmt("%s/%s", dir, md5);
+ FILE *f;
+
+ switch (op) {
+ case 0: /** check **/
+ ret = mtime(fn) > 0.0 ? 1 : 0;
+ break;
+
+ case 1: /** add **/
+ mkdirx(dir);
+
+ if ((f = fopen(fn, "w")) != NULL) {
+ fprintf(f, "%s\n", objid);
+ fclose(f);
+ }
+
+ break;
+ }
+
+ return ret;
+}
+
+
/** notifications **/
xs_str *notify_check_time(snac *snac, int reset)
diff --git a/html.c b/html.c
index 7c39237..a2dfb79 100644
--- a/html.c
+++ b/html.c
@@ -3822,8 +3822,9 @@ int html_get_handler(const xs_dict *req, const char *q_path,
if (!uid || !user_open(&snac, uid)) {
/* invalid user */
- srv_debug(1, xs_fmt("html_get_handler bad user %s", uid));
- return HTTP_STATUS_NOT_FOUND;
+ status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND;
+ srv_debug(1, xs_fmt("html_get_handler bad user %s %d", uid, status));
+ return status;
}
user = &snac; /* for L() */
diff --git a/httpd.c b/httpd.c
index 254d0e5..a8cd849 100644
--- a/httpd.c
+++ b/httpd.c
@@ -598,6 +598,9 @@ void httpd_connection(FILE *f)
if (status == HTTP_STATUS_NOT_FOUND)
body = xs_str_new("<h1>404 Not Found (" USER_AGENT ")</h1>");
+ if (status == HTTP_STATUS_GONE)
+ body = xs_str_new("<h1>410 Gone (" USER_AGENT ")</h1>");
+
if (status == HTTP_STATUS_BAD_REQUEST && body != NULL)
body = xs_str_new("<h1>400 Bad Request (" USER_AGENT ")</h1>");
diff --git a/po/de_DE.po b/po/de_DE.po
index 147f7ac..bb6876c 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -782,20 +782,20 @@ msgstr "en fr es de_DE"
#: html.c:460
msgid "Visibility: "
-msgstr ""
+msgstr "Sichtbarkeit"
#: html.c:468
msgid "Public"
-msgstr ""
+msgstr "Öffentlich"
#: html.c:477
msgid "Unlisted"
-msgstr ""
+msgstr "Ungelistete"
#: html.c:486
msgid "Followers-only"
-msgstr ""
+msgstr "Nur Follower"
#: html.c:495
msgid "Direct Message"
-msgstr ""
+msgstr "Direktnachricht"
diff --git a/snac.h b/snac.h
index 038aa40..4c3100a 100644
--- a/snac.h
+++ b/snac.h
@@ -1,7 +1,7 @@
/* snac - A simple, minimalistic ActivityPub instance */
/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */
-#define VERSION "2.84-dev"
+#define VERSION "2.84"
#define USER_AGENT "snac/" VERSION
@@ -288,6 +288,8 @@ xs_list *content_search(snac *user, const char *regex,
int actor_failure(const char *actor, int op);
int instance_failure(const char *url, int op);
+int grave(const char *objid, int op);
+
void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);
void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries);
void enqueue_output_raw(const char *keyid, const char *seckey,
diff --git a/utils.c b/utils.c
index de6db79..b76c0f8 100644
--- a/utils.c
+++ b/utils.c
@@ -454,6 +454,8 @@ int deluser(snac *user)
}
}
+ grave(user->uid, 1);
+
rm_rf(user->basedir);
return ret;
diff --git a/xs_curl.h b/xs_curl.h
index 2301661..feb23e0 100644
--- a/xs_curl.h
+++ b/xs_curl.h
@@ -54,10 +54,10 @@ struct _payload_data {
int offset;
};
-static int _data_callback(void *buffer, size_t size,
+static size_t _data_callback(void *buffer, size_t size,
size_t nitems, struct _payload_data *pd)
{
- int sz = size * nitems;
+ size_t sz = size * nitems;
/* open space */
pd->size += sz;
@@ -71,14 +71,14 @@ static int _data_callback(void *buffer, size_t size,
}
-static int _post_callback(char *buffer, size_t size,
+static size_t _post_callback(char *buffer, size_t size,
size_t nitems, struct _payload_data *pd)
{
/* size of data left */
- int sz = pd->size - pd->offset;
+ size_t sz = pd->size - pd->offset;
/* if it's still bigger than the provided space, trim */
- if (sz > (int) (size * nitems))
+ if (sz > (size_t) (size * nitems))
sz = size * nitems;
memcpy(buffer, pd->data + pd->offset, sz);
@@ -125,11 +125,11 @@ xs_dict *xs_http_request(const char *method, const char *url,
/* store response headers here */
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &response);
- curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, _header_callback);
+ curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, (curl_read_callback) _header_callback);
struct _payload_data ipd = { NULL, 0, 0 };
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ipd);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _data_callback);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (curl_read_callback) _data_callback);
if (strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0) {
CURLoption curl_method = method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD;
@@ -147,7 +147,7 @@ xs_dict *xs_http_request(const char *method, const char *url,
pd.offset = 0;
curl_easy_setopt(curl, CURLOPT_READDATA, &pd);
- curl_easy_setopt(curl, CURLOPT_READFUNCTION, _post_callback);
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback) _post_callback);
}
}
@@ -232,7 +232,7 @@ int xs_smtp_request(const char *url, const char *user, const char *pass,
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt);
curl_easy_setopt(curl, CURLOPT_READDATA, &pd);
- curl_easy_setopt(curl, CURLOPT_READFUNCTION, _post_callback);
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback) _post_callback);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
res = curl_easy_perform(curl);