mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
Minor actor name code refactoring.
This commit is contained in:
parent
80b6824f2b
commit
90838f07c6
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,
|
||||
const char *date, const char *udate, const char *url, int priv)
|
||||
xs_str *actor_name(xs_dict *actor)
|
||||
/* 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, "preferredUsername"))) {
|
||||
v = "user";
|
||||
if (xs_is_null(v = xs_dict_get(actor, "preferredUsername")) || *v == '\0') {
|
||||
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 */
|
||||
if ((v = xs_dict_get(actor, "icon")) != 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
|
||||
if (valid_status(object_get_by_md5(p, &actor_r))) {
|
||||
char *name;
|
||||
|
||||
if ((name = xs_dict_get(actor_r, "name")) == NULL)
|
||||
name = xs_dict_get(actor_r, "preferredUsername");
|
||||
xs *name = actor_name(actor_r);
|
||||
|
||||
if (!xs_is_null(name)) {
|
||||
xs *s1 = xs_fmt(
|
||||
|
Loading…
Reference in New Issue
Block a user