mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
xs_html() doesn't filter the top string, just returns the generated string.
This commit is contained in:
parent
97b7100b06
commit
bd2540e23f
1 changed files with 28 additions and 24 deletions
40
html.c
40
html.c
|
@ -1430,8 +1430,8 @@ xs_html *html_entry_controls(snac *snac, const xs_dict *msg, const char *md5)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
xs_str *html_entry(snac *user, xs_dict *msg, int local,
|
||||||
int level, const char *md5, int hide_children)
|
int level, char *md5, int hide_children)
|
||||||
{
|
{
|
||||||
char *id = xs_dict_get(msg, "id");
|
char *id = xs_dict_get(msg, "id");
|
||||||
char *type = xs_dict_get(msg, "type");
|
char *type = xs_dict_get(msg, "type");
|
||||||
|
@ -1442,15 +1442,15 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
|
|
||||||
/* do not show non-public messages in the public timeline */
|
/* do not show non-public messages in the public timeline */
|
||||||
if ((local || !user) && !is_msg_public(msg))
|
if ((local || !user) && !is_msg_public(msg))
|
||||||
return os;
|
return NULL;
|
||||||
|
|
||||||
/* hidden? do nothing more for this conversation */
|
/* hidden? do nothing more for this conversation */
|
||||||
if (user && is_hidden(user, id))
|
if (user && is_hidden(user, id))
|
||||||
return os;
|
return NULL;
|
||||||
|
|
||||||
/* avoid too deep nesting, as it may be a loop */
|
/* avoid too deep nesting, as it may be a loop */
|
||||||
if (level >= 256)
|
if (level >= 256)
|
||||||
return os;
|
return NULL;
|
||||||
|
|
||||||
if (strcmp(type, "Follow") == 0) {
|
if (strcmp(type, "Follow") == 0) {
|
||||||
xs_html *h = xs_html_tag("div",
|
xs_html *h = xs_html_tag("div",
|
||||||
|
@ -1462,32 +1462,31 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
xs_html_text(L("follows you"))),
|
xs_html_text(L("follows you"))),
|
||||||
html_msg_icon(msg)));
|
html_msg_icon(msg)));
|
||||||
|
|
||||||
xs *s1 = xs_html_render(h);
|
return xs_html_render(h);
|
||||||
return xs_str_cat(os, s1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (!xs_match(type, "Note|Question|Page|Article")) {
|
if (!xs_match(type, "Note|Question|Page|Article")) {
|
||||||
/* skip oddities */
|
/* skip oddities */
|
||||||
return os;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ignore notes with "name", as they are votes to Questions */
|
/* ignore notes with "name", as they are votes to Questions */
|
||||||
if (strcmp(type, "Note") == 0 && !xs_is_null(xs_dict_get(msg, "name")))
|
if (strcmp(type, "Note") == 0 && !xs_is_null(xs_dict_get(msg, "name")))
|
||||||
return os;
|
return NULL;
|
||||||
|
|
||||||
/* bring the main actor */
|
/* bring the main actor */
|
||||||
if ((actor = xs_dict_get(msg, "attributedTo")) == NULL)
|
if ((actor = xs_dict_get(msg, "attributedTo")) == NULL)
|
||||||
return os;
|
return NULL;
|
||||||
|
|
||||||
/* ignore muted morons immediately */
|
/* ignore muted morons immediately */
|
||||||
if (user && is_muted(user, actor))
|
if (user && is_muted(user, actor))
|
||||||
return os;
|
return NULL;
|
||||||
|
|
||||||
if ((user == NULL || strcmp(actor, user->actor) != 0)
|
if ((user == NULL || strcmp(actor, user->actor) != 0)
|
||||||
&& !valid_status(actor_get(actor, NULL)))
|
&& !valid_status(actor_get(actor, NULL)))
|
||||||
return os;
|
return NULL;
|
||||||
|
|
||||||
xs *s = xs_str_new("<div>\n");
|
xs_str *s = xs_str_new("<div>\n");
|
||||||
|
|
||||||
{
|
{
|
||||||
xs *s1 = xs_fmt("<a name=\"%s_entry\"></a>\n", md5);
|
xs *s1 = xs_fmt("<a name=\"%s_entry\"></a>\n", md5);
|
||||||
|
@ -2018,9 +2017,9 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
object_get_by_md5(cmd5, &chd);
|
object_get_by_md5(cmd5, &chd);
|
||||||
|
|
||||||
if (chd != NULL && xs_is_null(xs_dict_get(chd, "name"))) {
|
if (chd != NULL && xs_is_null(xs_dict_get(chd, "name"))) {
|
||||||
xs *s1 = xs_str_new(NULL);
|
xs *s1 = html_entry(user, chd, local, level + 1, cmd5, hide_children);
|
||||||
s1 = html_entry(user, s1, chd, local, level + 1, cmd5, hide_children);
|
|
||||||
|
|
||||||
|
if (s1 != NULL) {
|
||||||
if (left > 3)
|
if (left > 3)
|
||||||
xs_html_add(ch_older,
|
xs_html_add(ch_older,
|
||||||
xs_html_raw(s1));
|
xs_html_raw(s1));
|
||||||
|
@ -2028,6 +2027,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
xs_html_add(ch_container,
|
xs_html_add(ch_container,
|
||||||
xs_html_raw(s1));
|
xs_html_raw(s1));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
srv_debug(2, xs_fmt("cannot read child %s", cmd5));
|
srv_debug(2, xs_fmt("cannot read child %s", cmd5));
|
||||||
|
|
||||||
|
@ -2041,7 +2041,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n</div>\n");
|
s = xs_str_cat(s, "</div>\n</div>\n");
|
||||||
|
|
||||||
return xs_str_cat(os, s);
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2116,7 +2116,8 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = html_entry(user, s, msg, local, 0, v, user ? 0 : 1);
|
xs *s1 = html_entry(user, msg, local, 0, v, user ? 0 : 1);
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n");
|
s = xs_str_cat(s, "</div>\n");
|
||||||
|
@ -2439,7 +2440,10 @@ xs_str *html_notifications(snac *snac)
|
||||||
else {
|
else {
|
||||||
xs *md5 = xs_md5_hex(id, strlen(id));
|
xs *md5 = xs_md5_hex(id, strlen(id));
|
||||||
|
|
||||||
s = html_entry(snac, s, obj, 0, 0, md5, 1);
|
xs *s1 = html_entry(snac, obj, 0, 0, md5, 1);
|
||||||
|
|
||||||
|
if (s1 != NULL)
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n");
|
s = xs_str_cat(s, "</div>\n");
|
||||||
|
|
Loading…
Reference in a new issue