From e1ce85debd5b192b5dc56a4e9810839cc52b0f8b Mon Sep 17 00:00:00 2001 From: default Date: Sat, 11 May 2024 18:46:15 +0200 Subject: Unified post-like object type match. --- activitypub.c | 2 +- data.c | 2 +- html.c | 4 ++-- mastoapi.c | 4 ++-- snac.h | 2 ++ 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/activitypub.c b/activitypub.c index 301fd4c..4a04000 100644 --- a/activitypub.c +++ b/activitypub.c @@ -355,7 +355,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level) type = "(null)"; } - if (xs_match(type, "Note|Page|Article|Video")) { + if (xs_match(type, POSTLIKE_OBJECT_TYPE)) { const char *actor = get_atto(object); if (content_check("filter_reject.txt", object)) diff --git a/data.c b/data.c index d037af0..108354c 100644 --- a/data.c +++ b/data.c @@ -2577,7 +2577,7 @@ xs_list *content_search(snac *user, const char *regex, if (!valid_status(timeline_get_by_md5(user, md5, &post))) continue; - if (!xs_match(xs_dict_get_def(post, "type", "-"), "Note|Question|Page|Article|Video")) + if (!xs_match(xs_dict_get_def(post, "type", "-"), POSTLIKE_OBJECT_TYPE)) continue; char *content = xs_dict_get(post, "content"); diff --git a/html.c b/html.c index 0cdb608..12dba6b 100644 --- a/html.c +++ b/html.c @@ -256,7 +256,7 @@ xs_html *html_msg_icon(snac *user, char *actor_id, const xs_dict *msg) int priv = 0; const char *type = xs_dict_get(msg, "type"); - if (xs_match(type, "Note|Question|Page|Article|Video")) + if (xs_match(type, POSTLIKE_OBJECT_TYPE)) url = xs_dict_get(msg, "id"); priv = !is_msg_public(msg); @@ -1405,7 +1405,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg))); } else - if (!xs_match(type, "Note|Question|Page|Article|Video")) { + if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { /* skip oddities */ return NULL; } diff --git a/mastoapi.c b/mastoapi.c index 1071bfd..2bf5fdc 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -1504,7 +1504,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, /* discard non-Notes */ const char *id = xs_dict_get(msg, "id"); const char *type = xs_dict_get(msg, "type"); - if (!xs_match(type, "Note|Question|Page|Article|Video")) + if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) continue; const char *from = NULL; @@ -1681,7 +1681,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, /* discard non-Notes */ const char *id = xs_dict_get(msg, "id"); const char *type = xs_dict_get(msg, "type"); - if (!xs_match(type, "Note|Question|Page|Article|Video")) + if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) continue; const char *from = NULL; diff --git a/snac.h b/snac.h index c4e062b..c585e3f 100644 --- a/snac.h +++ b/snac.h @@ -29,6 +29,8 @@ extern int dbglevel; #define L(s) (s) +#define POSTLIKE_OBJECT_TYPE "Note|Question|Page|Article|Video" + int mkdirx(const char *pathname); int valid_status(int status); -- cgit v1.2.3 From 6f3763f452ba55ee6ddd9f63f5bc523807e7288f Mon Sep 17 00:00:00 2001 From: default Date: Sat, 11 May 2024 19:15:18 +0200 Subject: Show 'Event' object types as Notes. --- format.c | 5 ++--- html.c | 1 + snac.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/format.c b/format.c index 8d51351..631c11c 100644 --- a/format.c +++ b/format.c @@ -311,9 +311,8 @@ xs_str *sanitize(const char *content) s = xs_str_cat(s, s2); } else { - /* else? just show it with encoded code.. that's it. */ - xs *el = encode_html(v); - s = xs_str_cat(s, el); + if (strcmp(v, "")) + s = xs_str_cat(s, "

"); } } else { diff --git a/html.c b/html.c index 12dba6b..201456e 100644 --- a/html.c +++ b/html.c @@ -1407,6 +1407,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, else if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { /* skip oddities */ + snac_debug(user, 1, xs_fmt("html_entry: ignoring object type '%s' %s", type, id)); return NULL; } diff --git a/snac.h b/snac.h index c585e3f..239f27a 100644 --- a/snac.h +++ b/snac.h @@ -29,7 +29,7 @@ extern int dbglevel; #define L(s) (s) -#define POSTLIKE_OBJECT_TYPE "Note|Question|Page|Article|Video" +#define POSTLIKE_OBJECT_TYPE "Note|Question|Page|Article|Video|Event" int mkdirx(const char *pathname); -- cgit v1.2.3