aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2026-04-11 09:36:33 +0200
committergrunfink <grunfink@comam.es>2026-04-11 09:36:33 +0200
commit04898751fda75b5b686153a9917699b54013da45 (patch)
treebf21b2dc881621c3d1a881bfc100bc677ee28e30
parent4ff0393152111ec5e1a50f2f89caca1a268fb083 (diff)
Rewritten last commit to be more reliable (latitude and longitude data may be strings).
-rw-r--r--html.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/html.c b/html.c
index 9473397..a3d2c61 100644
--- a/html.c
+++ b/html.c
@@ -3827,23 +3827,27 @@ xs_html *html_people_list(snac *user, xs_list *list, const char *header, const c
const xs_dict *location = xs_dict_get(actor, "location");
if (xs_is_dict(location)) {
- const xs_val *latitude = xs_dict_get_def(location, "latitude", xs_stock(0));
- const xs_val *longitude = xs_dict_get_def(location, "longitude", xs_stock(0));
- const char *name = xs_dict_get_def(location, "name", "Home");
+ const xs_val *latitude = xs_dict_get(location, "latitude");
+ const xs_val *longitude = xs_dict_get(location, "longitude");
- if (*latitude && *longitude) {
- xs *label = xs_fmt("%s,%s", xs_number_str(latitude), xs_number_str(longitude));
- xs *url = xs_fmt("https://openstreetmap.org/search?query=%s,%s",
- latitude, longitude);
+ if (latitude && longitude) {
+ const char *name = xs_dict_get_def(location, "name", "Home");
+ const char *la = xs_is_string(latitude) ? latitude : xs_number_str(latitude);
+ const char *lo = xs_is_string(longitude) ? longitude : xs_number_str(longitude);
- xs_html_add(snac_post,
- xs_html_tag("p",
- xs_html_text(name),
- xs_html_text(": "),
- xs_html_tag("a",
- xs_html_attr("href", url),
- xs_html_attr("target", "_blank"),
- xs_html_text(label))));
+ if (xs_is_string(la) && xs_is_string(lo)) {
+ xs *label = xs_fmt("%s,%s", la, lo);
+ xs *url = xs_fmt("https://openstreetmap.org/search?query=%s,%s", la, lo);
+
+ xs_html_add(snac_post,
+ xs_html_tag("p",
+ xs_html_text(name),
+ xs_html_text(": "),
+ xs_html_tag("a",
+ xs_html_attr("href", url),
+ xs_html_attr("target", "_blank"),
+ xs_html_text(label))));
+ }
}
}