commit 8ebfa10
default
·
2023-09-17 01:00:31 +0000 UTC
parent 952da47
Use xs_match() in some places for more clarity.
1 files changed,
+5,
-8
+5,
-8
1@@ -9,6 +9,7 @@
2 #include "xs_regex.h"
3 #include "xs_time.h"
4 #include "xs_set.h"
5+#include "xs_match.h"
6
7 #include "snac.h"
8
9@@ -192,9 +193,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
10 type = "(null)";
11 }
12
13- if (strcmp(type, "Note") == 0 ||
14- strcmp(type, "Page") == 0 ||
15- strcmp(type, "Article") == 0) {
16+ if (xs_match(type, "Note|Page|Article")) {
17 const char *actor = xs_dict_get(object, "attributedTo");
18
19 /* request (and drop) the actor for this entry */
20@@ -441,7 +440,7 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
21 {
22 const char *type = xs_dict_get(c_msg, "type");
23
24- if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) {
25+ if (xs_match(type, "Like|Announce")) {
26 const char *object = xs_dict_get(c_msg, "object");
27
28 if (xs_type(object) == XSTYPE_DICT)
29@@ -1648,16 +1647,14 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
30 }
31 else
32 if (strcmp(type, "Update") == 0) { /** **/
33- if (strcmp(utype, "Person") == 0 || strcmp(utype, "Service") == 0) { /** **/
34+ if (xs_match(utype, "Person|Service")) { /** **/
35 actor_add(actor, xs_dict_get(msg, "object"));
36 timeline_touch(snac);
37
38 snac_log(snac, xs_fmt("updated actor %s", actor));
39 }
40 else
41- if (strcmp(utype, "Note") == 0 || /** **/
42- strcmp(utype, "Page") == 0 || /** **/
43- strcmp(utype, "Article") == 0) { /** **/
44+ if (xs_match(utype, "Note|Page|Article")) { /** **/
45 const char *id = xs_dict_get(object, "id");
46
47 object_add_ow(id, object);