Compare commits

...

7 Commits

Author SHA1 Message Date
default 2d2c1bdfef Updated documentation. 2024-04-22 08:03:33 +02:00
default 6ed34913f0 Added queue timeout tweaks to default server.json. 2024-04-22 07:55:03 +02:00
default 16a4a09e4f New server.json knobs "queue_timeout" and "queue_timeout_2". 2024-04-22 07:53:40 +02:00
default cf1c2b1ed8 Backport from xs. 2024-04-22 07:31:50 +02:00
default 9cfce7a4bd Deleted useless recalculation of queue_retry_max. 2024-04-22 07:23:27 +02:00
default ebf6a4bd8e URLs like {srv_baseurl}/{user}/admin/p/{md5} are valid.
But only if {md5} is in the user's timeline.
2024-04-22 05:46:56 +02:00
default 62cc167c5f Updated TODO. 2024-04-20 22:48:02 +02:00
8 changed files with 95 additions and 16 deletions

View File

@ -14,14 +14,10 @@ Important: deleting a follower should do more that just delete the object, see h
Implement `Group`-like accounts (i.e. an actor that boosts to their followers all posts that mention it).
Integrate "Ability to federate with hidden networks" see https://codeberg.org/grunfink/snac2/issues/93
Integrate "Added handling for International Domain Names" PR https://codeberg.org/grunfink/snac2/pulls/104
Consider adding Mastodon import functionality (for following_accounts.csv and outbox.json).
Consider adding milter-like support to reject posts to mitigate spam.
Do something about Akkoma and Misskey's quoted replies (they use the `quoteUrl` field instead of `inReplyTo`).
Add more CSS classes according to https://comam.es/snac/grunfink/p/1705598619.090050
@ -311,3 +307,7 @@ Consider implementing the rejection of activities from recently-created accounts
Consider discarding posts by content using string or regex to mitigate spam (2024-03-14T10:40:14+0100).
Post edits should preserve the image and the image description somewhat (2024-03-22T09:57:18+0100).
Integrate "Ability to federate with hidden networks" see https://codeberg.org/grunfink/snac2/issues/93
Consider adding milter-like support to reject posts to mitigate spam (discarded; 2024-04-20T22:46:35+0200).

View File

@ -2371,6 +2371,7 @@ void process_queue_item(xs_dict *q_item)
int p_status = xs_number_get(xs_dict_get(q_item, "p_status"));
xs *payload = NULL;
int p_size = 0;
int timeout = 0;
if (xs_is_null(inbox) || xs_is_null(msg) || xs_is_null(keyid) || xs_is_null(seckey)) {
srv_log(xs_fmt("output message error: missing fields"));
@ -2383,8 +2384,15 @@ void process_queue_item(xs_dict *q_item)
}
/* deliver (if previous error status was a timeout, try now longer) */
status = send_to_inbox_raw(keyid, seckey, inbox, msg,
&payload, &p_size, p_status == 599 ? 8 : 6);
if (p_status == 599)
timeout = xs_number_get(xs_dict_get_def(srv_config, "queue_timeout_2", "8"));
else
timeout = xs_number_get(xs_dict_get_def(srv_config, "queue_timeout", "6"));
if (timeout == 0)
timeout = 6;
status = send_to_inbox_raw(keyid, seckey, inbox, msg, &payload, &p_size, timeout);
if (payload) {
if (p_size > 64) {
@ -2516,8 +2524,6 @@ void process_queue_item(xs_dict *q_item)
if (r == 0) {
/* transient error? retry */
int queue_retry_max = xs_number_get(xs_dict_get(srv_config, "queue_retry_max"));
if (retries > queue_retry_max)
srv_log(xs_fmt("shared input giving up"));
else {

14
data.c
View File

@ -1065,14 +1065,18 @@ int timeline_touch(snac *snac)
xs_str *timeline_fn_by_md5(snac *snac, const char *md5)
/* get the filename of an entry by md5 from any timeline */
{
xs_str *fn = xs_fmt("%s/private/%s.json", snac->basedir, md5);
xs_str *fn = NULL;
if (mtime(fn) == 0.0) {
fn = xs_free(fn);
fn = xs_fmt("%s/public/%s.json", snac->basedir, md5);
if (xs_is_hex(md5) && strlen(md5) == 32) {
fn = xs_fmt("%s/private/%s.json", snac->basedir, md5);
if (mtime(fn) == 0.0)
if (mtime(fn) == 0.0) {
fn = xs_free(fn);
fn = xs_fmt("%s/public/%s.json", snac->basedir, md5);
if (mtime(fn) == 0.0)
fn = xs_free(fn);
}
}
return fn;

View File

@ -143,6 +143,14 @@ times the sending will be retried.
The number of minutes to wait before the failed posting of a message is
retried. This is not linear, but multipled by the number of retries
already done.
.It Ic queue_timeout
The maximum number of seconds to wait when sending a message from the queue.
.It Ic queue_timeout_2
The maximum number of seconds to wait when sending a message from the queue
to those servers that went timeout in the previous retry. If you want to
give slow servers a chance to receive your messages, you can increase this
value (but also take into account that processing the queue will take longer
while waiting for these molasses to respond).
.It Ic max_timeline_entries
This is the maximum timeline entries shown in the web interface.
.It Ic timeline_purge_days

19
html.c
View File

@ -2586,6 +2586,25 @@ int html_get_handler(const xs_dict *req, const char *q_path,
}
}
else
if (xs_startswith(p_path, "admin/p/")) { /** unique post by md5 **/
if (!login(&snac, req)) {
*body = xs_dup(uid);
status = 401;
}
else {
xs *l = xs_split(p_path, "/");
char *md5 = xs_list_get(l, -1);
if (md5 && *md5 && timeline_here(&snac, md5)) {
xs *list = xs_list_append(xs_list_new(), md5);
*body = html_timeline(&snac, list, 0, 0, 0, 0, NULL, "/admin", 1);
*b_size = strlen(*body);
status = 200;
}
}
}
else
if (strcmp(p_path, "people") == 0) { /** the list of people **/
if (!login(&snac, req)) {
*body = xs_dup(uid);

View File

@ -25,6 +25,8 @@ static const char *default_srv_config = "{"
"\"dbglevel\": 0,"
"\"queue_retry_minutes\": 2,"
"\"queue_retry_max\": 10,"
"\"queue_timeout\": 6,"
"\"queue_timeout_2\": 8,"
"\"cssurls\": [\"\"],"
"\"max_timeline_entries\": 50,"
"\"timeline_purge_days\": 120,"

44
xs.h
View File

@ -94,6 +94,7 @@ xs_list *xs_list_append_m(xs_list *list, const char *mem, int dsz);
xs_list *_xs_list_append(xs_list *list, const xs_val *vals[]);
#define xs_list_append(list, ...) _xs_list_append(list, (const xs_val *[]){ __VA_ARGS__, NULL })
int xs_list_iter(xs_list **list, xs_val **value);
int xs_list_next(const xs_list *list, xs_val **value, int *ctxt);
int xs_list_len(const xs_list *list);
xs_val *xs_list_get(const xs_list *list, int num);
xs_list *xs_list_del(xs_list *list, int num);
@ -752,6 +753,42 @@ int xs_list_iter(xs_list **list, xs_val **value)
}
int xs_list_next(const xs_list *list, xs_val **value, int *ctxt)
/* iterates a list, with context */
{
if (xs_type(list) != XSTYPE_LIST)
return 0;
int goon = 1;
char *p = (char *)list;
/* skip the start of the list */
if (*ctxt == 0)
*ctxt = 1 + _XS_TYPE_SIZE;
p += *ctxt;
/* an element? */
if (xs_type(p) == XSTYPE_LITEM) {
p++;
*value = p;
p += xs_size(*value);
}
else {
/* end of list */
goon = 0;
}
/* update the context */
*ctxt = p - list;
return goon;
}
int xs_list_len(const xs_list *list)
/* returns the number of elements in the list */
{
@ -1199,8 +1236,11 @@ double xs_number_get(const xs_number *v)
{
double f = 0.0;
if (v != NULL && v[0] == XSTYPE_NUMBER)
if (xs_type(v) == XSTYPE_NUMBER)
f = atof(&v[1]);
else
if (xs_type(v) == XSTYPE_STRING)
f = atof(v);
return f;
}
@ -1211,7 +1251,7 @@ const char *xs_number_str(const xs_number *v)
{
const char *p = NULL;
if (v != NULL && v[0] == XSTYPE_NUMBER)
if (xs_type(v) == XSTYPE_NUMBER)
p = &v[1];
return p;

View File

@ -1 +1 @@
/* f712d1336ef427c3b56305364b2687578537543f 2024-04-14T19:11:53+02:00 */
/* 0206a65508e86f66b6aa329418ddc8f6f8c1ecb2 2024-04-22T07:31:05+02:00 */