commit 538f6970f86323dca734436861fe19193fae87e5
parent ea2eb3299dbb13699cffadb7be445ae87cae00bc
Author: default <nobody@localhost>
Date: Fri, 10 Jan 2025 08:29:57 +0100
If a location is defined, user actors include a 'Place' object.
Diffstat:
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/activitypub.c b/activitypub.c
@@ -1184,6 +1184,28 @@ xs_dict *msg_repulsion(snac *user, const char *id, const char *type)
}
+xs_dict *msg_place(snac *user, const char *label)
+/* creates a Place object, if the user has a location defined */
+{
+ xs *place = NULL;
+ const char *latitude = xs_dict_get_def(user->config, "latitude", "");
+ const char *longitude = xs_dict_get_def(user->config, "longitude", "");
+
+ if (*latitude && *longitude) {
+ xs *d_la = xs_number_new(atof(latitude));
+ xs *d_lo = xs_number_new(atof(longitude));
+
+ place = msg_base(user, "Place", NULL, user->actor, NULL, NULL);
+
+ place = xs_dict_set(place, "name", label);
+ place = xs_dict_set(place, "latitude", d_la);
+ place = xs_dict_set(place, "longitude", d_lo);
+ }
+
+ return place;
+}
+
+
xs_dict *msg_actor(snac *snac)
/* create a Person message for this actor */
{
@@ -1340,6 +1362,11 @@ xs_dict *msg_actor(snac *snac)
msg = xs_dict_set(msg, "manuallyApprovesFollowers",
xs_stock(xs_is_true(manually) ? XSTYPE_TRUE : XSTYPE_FALSE));
+ /* if there are location coords, create a Place object */
+ xs *location = msg_place(snac, "Home");
+ if (xs_type(location) == XSTYPE_DICT)
+ msg = xs_dict_set(msg, "location", location);
+
/* cache it */
snac_debug(snac, 1, xs_fmt("Caching actor %s", snac->actor));
object_add_ow(snac->actor, msg);
diff --git a/html.c b/html.c
@@ -1311,7 +1311,7 @@ xs_html *html_top_controls(snac *snac)
xs_html_attr("for", "show_contact_metrics"),
xs_html_text(L("Publish follower and following metrics")))),
xs_html_tag("p",
- xs_html_text(L("Home location:")),
+ xs_html_text(L("Current location:")),
xs_html_sctag("br", NULL),
xs_html_sctag("input",
xs_html_attr("type", "text"),