summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c24
-rw-r--r--html.c21
-rw-r--r--mastoapi.c25
-rw-r--r--snac.h1
4 files changed, 35 insertions, 36 deletions
diff --git a/activitypub.c b/activitypub.c
index df4877b..9893470 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -593,6 +593,30 @@ int is_msg_public(const xs_dict *msg)
593} 593}
594 594
595 595
596int is_msg_from_private_user(const xs_dict *msg)
597/* checks if a message is from a local, private user */
598{
599 int ret = 0;
600
601 /* is this message from a local user? */
602 if (xs_startswith(xs_dict_get(msg, "id"), srv_baseurl)) {
603 const char *atto = get_atto(msg);
604 xs *l = xs_split(atto, "/");
605 const char *uid = xs_list_get(l, -1);
606 snac user;
607
608 if (uid && user_open(&user, uid)) {
609 if (xs_type(xs_dict_get(user.config, "private")) == XSTYPE_TRUE)
610 ret = 1;
611
612 user_free(&user);
613 }
614 }
615
616 return ret;
617}
618
619
596int is_msg_for_me(snac *snac, const xs_dict *c_msg) 620int is_msg_for_me(snac *snac, const xs_dict *c_msg)
597/* checks if this message is for me */ 621/* checks if this message is for me */
598{ 622{
diff --git a/html.c b/html.c
index 5f3dead..a340a96 100644
--- a/html.c
+++ b/html.c
@@ -1911,24 +1911,9 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
1911 if (!valid_status(status)) 1911 if (!valid_status(status))
1912 continue; 1912 continue;
1913 1913
1914 /* if it's an instance page, discard private users */ 1914 /* if it's an instance page, discard messages from private users */
1915 if (user == NULL && xs_startswith(xs_dict_get(msg, "id"), srv_baseurl)) { 1915 if (user == NULL && is_msg_from_private_user(msg))
1916 const char *atto = get_atto(msg); 1916 continue;
1917 xs *l = xs_split(atto, "/");
1918 const char *uid = xs_list_get(l, -1);
1919 snac user;
1920 int skip = 1;
1921
1922 if (uid && user_open(&user, uid)) {
1923 if (xs_type(xs_dict_get(user.config, "private")) != XSTYPE_TRUE)
1924 skip = 0;
1925
1926 user_free(&user);
1927 }
1928
1929 if (skip)
1930 continue;
1931 }
1932 1917
1933 xs_html *entry = html_entry(user, msg, local, 0, v, user ? 0 : 1); 1918 xs_html *entry = html_entry(user, msg, local, 0, v, user ? 0 : 1);
1934 1919
diff --git a/mastoapi.c b/mastoapi.c
index 000bdea..e2b7bba 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1500,24 +1500,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1500 if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0) 1500 if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
1501 continue; 1501 continue;
1502 1502
1503 /* discard private users */ 1503 /* discard messages from private users */
1504 { 1504 if (is_msg_from_private_user(msg))
1505 const char *atto = get_atto(msg); 1505 continue;
1506 xs *l = xs_split(atto, "/");
1507 const char *uid = xs_list_get(l, -1);
1508 snac p_user;
1509 int skip = 1;
1510
1511 if (uid && user_open(&p_user, uid)) {
1512 if (xs_type(xs_dict_get(p_user.config, "private")) != XSTYPE_TRUE)
1513 skip = 0;
1514
1515 user_free(&p_user);
1516 }
1517
1518 if (skip)
1519 continue;
1520 }
1521 1506
1522 /* convert the Note into a Mastodon status */ 1507 /* convert the Note into a Mastodon status */
1523 xs *st = mastoapi_status(user, msg); 1508 xs *st = mastoapi_status(user, msg);
@@ -1564,6 +1549,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1564 if (!is_msg_public(msg)) 1549 if (!is_msg_public(msg))
1565 continue; 1550 continue;
1566 1551
1552 /* discard messages from private users */
1553 if (is_msg_from_private_user(msg))
1554 continue;
1555
1567 /* convert the Note into a Mastodon status */ 1556 /* convert the Note into a Mastodon status */
1568 xs *st = mastoapi_status(NULL, msg); 1557 xs *st = mastoapi_status(NULL, msg);
1569 1558
diff --git a/snac.h b/snac.h
index cf2cf38..fd79a9d 100644
--- a/snac.h
+++ b/snac.h
@@ -277,6 +277,7 @@ xs_str *get_actor_inbox(const char *actor);
277int send_to_actor(snac *snac, const char *actor, const xs_dict *msg, 277int send_to_actor(snac *snac, const char *actor, const xs_dict *msg,
278 xs_val **payload, int *p_size, int timeout); 278 xs_val **payload, int *p_size, int timeout);
279int is_msg_public(const xs_dict *msg); 279int is_msg_public(const xs_dict *msg);
280int is_msg_from_private_user(const xs_dict *msg);
280int is_msg_for_me(snac *snac, const xs_dict *msg); 281int is_msg_for_me(snac *snac, const xs_dict *msg);
281 282
282int process_user_queue(snac *snac); 283int process_user_queue(snac *snac);