commit 749dbef
default
·
2023-09-21 19:25:45 +0000 UTC
parent f31eb8d
Used xs_match() in some places.
M
Makefile
+1,
-1
1@@ -39,7 +39,7 @@ data.o: data.c xs.h xs_io.h xs_json.h xs_openssl.h xs_glob.h xs_set.h \
2 xs_time.h snac.h
3 format.o: format.c xs.h xs_regex.h xs_mime.h snac.h
4 html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \
5- xs_time.h xs_mime.h snac.h
6+ xs_time.h xs_mime.h xs_match.h snac.h
7 http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \
8 snac.h
9 httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_httpd.h xs_mime.h \
M
html.c
+3,
-4
1@@ -9,6 +9,7 @@
2 #include "xs_openssl.h"
3 #include "xs_time.h"
4 #include "xs_mime.h"
5+#include "xs_match.h"
6
7 #include "snac.h"
8
9@@ -203,8 +204,7 @@ xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
10 int priv = 0;
11 const char *type = xs_dict_get(msg, "type");
12
13- if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 ||
14- strcmp(type, "Page") == 0 || strcmp(type, "Article") == 0)
15+ if (xs_match(type, "Note|Question|Page|Article"))
16 url = xs_dict_get(msg, "id");
17
18 priv = !is_msg_public(msg);
19@@ -1387,8 +1387,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
20 continue;
21
22 /* infer MIME type from non-specific attachments */
23- if (xs_list_len(attach) < 2 &&
24- (strcmp(t, "Link") == 0 || strcmp(t, "Document") == 0)) {
25+ if (xs_list_len(attach) < 2 && xs_match(t, "Link|Document")) {
26 const char *mt = xs_mime_by_ext(url);
27
28 if (xs_startswith(mt, "image/") ||