mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Minor actor name code refactoring.
This commit is contained in:
parent
80b6824f2b
commit
90838f07c6
1 changed files with 22 additions and 14 deletions
36
html.c
36
html.c
|
@ -37,19 +37,16 @@ int login(snac *snac, char *headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
d_char *html_actor_icon(snac *snac, d_char *os, char *actor,
|
xs_str *actor_name(xs_dict *actor)
|
||||||
const char *date, const char *udate, const char *url, int priv)
|
/* gets the actor name */
|
||||||
{
|
{
|
||||||
xs *s = xs_str_new(NULL);
|
xs_list *p;
|
||||||
|
char *v;
|
||||||
|
xs_str *name;
|
||||||
|
|
||||||
xs *name = NULL;
|
|
||||||
xs *avatar = NULL;
|
|
||||||
char *p, *v;
|
|
||||||
|
|
||||||
/* get the name */
|
|
||||||
if (xs_is_null((v = xs_dict_get(actor, "name"))) || *v == '\0') {
|
if (xs_is_null((v = xs_dict_get(actor, "name"))) || *v == '\0') {
|
||||||
if (xs_is_null(v = xs_dict_get(actor, "preferredUsername"))) {
|
if (xs_is_null(v = xs_dict_get(actor, "preferredUsername")) || *v == '\0') {
|
||||||
v = "user";
|
v = "anonymous";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +72,20 @@ d_char *html_actor_icon(snac *snac, d_char *os, char *actor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
d_char *html_actor_icon(snac *snac, d_char *os, char *actor,
|
||||||
|
const char *date, const char *udate, const char *url, int priv)
|
||||||
|
{
|
||||||
|
xs *s = xs_str_new(NULL);
|
||||||
|
|
||||||
|
xs *avatar = NULL;
|
||||||
|
char *v;
|
||||||
|
|
||||||
|
xs *name = actor_name(actor);
|
||||||
|
|
||||||
/* get the avatar */
|
/* get the avatar */
|
||||||
if ((v = xs_dict_get(actor, "icon")) != NULL &&
|
if ((v = xs_dict_get(actor, "icon")) != NULL &&
|
||||||
(v = xs_dict_get(v, "url")) != NULL) {
|
(v = xs_dict_get(v, "url")) != NULL) {
|
||||||
|
@ -708,10 +719,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, cons
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (valid_status(object_get_by_md5(p, &actor_r))) {
|
if (valid_status(object_get_by_md5(p, &actor_r))) {
|
||||||
char *name;
|
xs *name = actor_name(actor_r);
|
||||||
|
|
||||||
if ((name = xs_dict_get(actor_r, "name")) == NULL)
|
|
||||||
name = xs_dict_get(actor_r, "preferredUsername");
|
|
||||||
|
|
||||||
if (!xs_is_null(name)) {
|
if (!xs_is_null(name)) {
|
||||||
xs *s1 = xs_fmt(
|
xs *s1 = xs_fmt(
|
||||||
|
|
Loading…
Reference in a new issue