aboutsummaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-01-10 08:29:57 +0100
committerdefault <nobody@localhost>2025-01-10 08:29:57 +0100
commit538f6970f86323dca734436861fe19193fae87e5 (patch)
treea9e3e0606b554308bbad00a4ed9d1924a341d853 /activitypub.c
parentea2eb3299dbb13699cffadb7be445ae87cae00bc (diff)
If a location is defined, user actors include a 'Place' object.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c
index ecc0533..3bd6220 100644
--- 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);