commit 71a7569

default  ·  2023-02-05 16:45:00 +0000 UTC
parent bad9f3a
Deleted the type argument from object_get_my_md5() and object_get().

It was never used.
4 files changed,  +19, -30
M data.c
M html.c
M snac.h
+5, -5
 1@@ -469,7 +469,7 @@ d_char *msg_admiration(snac *snac, char *object, char *type)
 2     /* call the object */
 3     timeline_request(snac, &object, &wrk);
 4 
 5-    if (valid_status(object_get(object, &a_msg, NULL))) {
 6+    if (valid_status(object_get(object, &a_msg))) {
 7         xs *rcpts = xs_list_new();
 8 
 9         msg = msg_base(snac, type, "@dummy", snac->actor, "@now", object);
10@@ -664,7 +664,7 @@ xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_t
11         /* demand this thing */
12         timeline_request(snac, &in_reply_to, &wrk);
13 
14-        if (valid_status(object_get(in_reply_to, &p_msg, NULL))) {
15+        if (valid_status(object_get(in_reply_to, &p_msg))) {
16             /* add this author as recipient */
17             char *a, *v;
18 
19@@ -977,7 +977,7 @@ int process_input_message(snac *snac, char *msg, char *req)
20 
21         timeline_request(snac, &object, &wrk);
22 
23-        if (valid_status(object_get(object, &a_msg, NULL))) {
24+        if (valid_status(object_get(object, &a_msg))) {
25             char *who = xs_dict_get(a_msg, "attributedTo");
26 
27             if (who && !is_muted(snac, who)) {
28@@ -1262,7 +1262,7 @@ int activitypub_get_handler(d_char *req, char *q_path,
29         while (xs_list_iter(&p, &v)) {
30             xs *i = NULL;
31 
32-            if (valid_status(object_get_by_md5(v, &i, NULL))) {
33+            if (valid_status(object_get_by_md5(v, &i))) {
34                 char *type = xs_dict_get(i, "type");
35                 char *id   = xs_dict_get(i, "id");
36 
37@@ -1287,7 +1287,7 @@ int activitypub_get_handler(d_char *req, char *q_path,
38     if (xs_startswith(p_path, "p/")) {
39         xs *id = xs_fmt("%s/%s", snac.actor, p_path);
40 
41-        status = object_get(id, &msg, NULL);
42+        status = object_get(id, &msg);
43     }
44     else
45         status = 404;
M data.c
+9, -20
 1@@ -466,7 +466,7 @@ int object_here(char *id)
 2 }
 3 
 4 
 5-int object_get_by_md5(const char *md5, d_char **obj, const char *type)
 6+int object_get_by_md5(const char *md5, xs_dict **obj)
 7 /* returns a stored object, optionally of the requested type */
 8 {
 9     int status = 404;
10@@ -481,19 +481,8 @@ int object_get_by_md5(const char *md5, d_char **obj, const char *type)
11 
12         *obj = xs_json_loads(j);
13 
14-        if (*obj) {
15+        if (*obj)
16             status = 200;
17-
18-            /* specific type requested? */
19-            if (!xs_is_null(type)) {
20-                char *v = xs_dict_get(*obj, "type");
21-
22-                if (xs_is_null(v) || strcmp(v, type) != 0) {
23-                    status = 404;
24-                    *obj   = xs_free(*obj);
25-                }
26-            }
27-        }
28     }
29     else
30         *obj = NULL;
31@@ -502,11 +491,11 @@ int object_get_by_md5(const char *md5, d_char **obj, const char *type)
32 }
33 
34 
35-int object_get(const char *id, d_char **obj, const char *type)
36+int object_get(const char *id, xs_dict **obj)
37 /* returns a stored object, optionally of the requested type */
38 {
39     xs *md5 = xs_md5_hex(id, strlen(id));
40-    return object_get_by_md5(md5, obj, type);
41+    return object_get_by_md5(md5, obj);
42 }
43 
44 
45@@ -803,7 +792,7 @@ d_char *follower_list(snac *snac)
46     while (xs_list_iter(&p, &v)) {
47         xs *a_obj = NULL;
48 
49-        if (valid_status(object_get_by_md5(v, &a_obj, NULL))) {
50+        if (valid_status(object_get_by_md5(v, &a_obj))) {
51             char *actor = xs_dict_get(a_obj, "id");
52 
53             if (!xs_is_null(actor))
54@@ -827,7 +816,7 @@ double timeline_mtime(snac *snac)
55 int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg)
56 /* gets a message from the timeline */
57 {
58-    return object_get_by_md5(md5, msg, NULL);
59+    return object_get_by_md5(md5, msg);
60 }
61 
62 
63@@ -851,7 +840,7 @@ void timeline_update_indexes(snac *snac, const char *id)
64     if (xs_startswith(id, snac->actor)) {
65         xs *msg = NULL;
66 
67-        if (valid_status(object_get(id, &msg, NULL))) {
68+        if (valid_status(object_get(id, &msg))) {
69             /* if its ours and is public, also store in public */
70             if (is_msg_public(snac, msg))
71                 object_user_cache_add(snac, id, "public");
72@@ -1138,7 +1127,7 @@ void hide(snac *snac, const char *id)
73             xs *co = NULL;
74 
75             /* resolve to get the id */
76-            if (valid_status(object_get_by_md5(v, &co, NULL))) {
77+            if (valid_status(object_get_by_md5(v, &co))) {
78                 if ((v = xs_dict_get(co, "id")) != NULL)
79                     hide(snac, v);
80             }
81@@ -1178,7 +1167,7 @@ int actor_get(snac *snac, const char *actor, d_char **data)
82     }
83 
84     /* read the object */
85-    if (!valid_status(status = object_get(actor, &d, NULL)))
86+    if (!valid_status(status = object_get(actor, &d)))
87         return status;
88 
89     if (data)
M html.c
+3, -3
 1@@ -655,7 +655,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, cons
 2             s = xs_str_cat(s, s1);
 3         }
 4         else
 5-        if (valid_status(object_get_by_md5(p, &actor_r, NULL))) {
 6+        if (valid_status(object_get_by_md5(p, &actor_r))) {
 7             char *name;
 8 
 9             if ((name = xs_dict_get(actor_r, "name")) == NULL)
10@@ -1190,7 +1190,7 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
11         xs *id  = xs_fmt("%s/%s", snac.actor, p_path);
12         xs *msg = NULL;
13 
14-        if (valid_status(object_get(id, &msg, NULL))) {
15+        if (valid_status(object_get(id, &msg))) {
16             xs *md5  = xs_md5_hex(id, strlen(id));
17             xs *list = xs_list_new();
18 
19@@ -1416,7 +1416,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
20                 /* an edition of a previous message */
21                 xs *p_msg = NULL;
22 
23-                if (valid_status(object_get(edit_id, &p_msg, NULL))) {
24+                if (valid_status(object_get(edit_id, &p_msg))) {
25                     /* copy relevant fields from previous version */
26                     char *fields[] = { "id", "context", "url", "published",
27                                        "to", "inReplyTo", NULL };
M snac.h
+2, -2
 1@@ -65,8 +65,8 @@ int object_add(const char *id, d_char *obj);
 2 int object_add_ow(const char *id, d_char *obj);
 3 int object_here_by_md5(char *id);
 4 int object_here(char *id);
 5-int object_get_by_md5(const char *md5, d_char **obj, const char *type);
 6-int object_get(const char *id, d_char **obj, const char *type);
 7+int object_get_by_md5(const char *md5, xs_dict **obj);
 8+int object_get(const char *id, xs_dict **obj);
 9 int object_del(const char *id);
10 int object_del_if_unref(const char *id);
11 int object_admire(const char *id, const char *actor, int like);