summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2025-01-10 08:29:57 +0100
committerGravatar default2025-01-10 08:29:57 +0100
commit538f6970f86323dca734436861fe19193fae87e5 (patch)
treea9e3e0606b554308bbad00a4ed9d1924a341d853
parentShow the location in the public page. (diff)
downloadpenes-snac2-538f6970f86323dca734436861fe19193fae87e5.tar.gz
penes-snac2-538f6970f86323dca734436861fe19193fae87e5.tar.xz
penes-snac2-538f6970f86323dca734436861fe19193fae87e5.zip
If a location is defined, user actors include a 'Place' object.
-rw-r--r--activitypub.c27
-rw-r--r--html.c2
2 files changed, 28 insertions, 1 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)
1184} 1184}
1185 1185
1186 1186
1187xs_dict *msg_place(snac *user, const char *label)
1188/* creates a Place object, if the user has a location defined */
1189{
1190 xs *place = NULL;
1191 const char *latitude = xs_dict_get_def(user->config, "latitude", "");
1192 const char *longitude = xs_dict_get_def(user->config, "longitude", "");
1193
1194 if (*latitude && *longitude) {
1195 xs *d_la = xs_number_new(atof(latitude));
1196 xs *d_lo = xs_number_new(atof(longitude));
1197
1198 place = msg_base(user, "Place", NULL, user->actor, NULL, NULL);
1199
1200 place = xs_dict_set(place, "name", label);
1201 place = xs_dict_set(place, "latitude", d_la);
1202 place = xs_dict_set(place, "longitude", d_lo);
1203 }
1204
1205 return place;
1206}
1207
1208
1187xs_dict *msg_actor(snac *snac) 1209xs_dict *msg_actor(snac *snac)
1188/* create a Person message for this actor */ 1210/* create a Person message for this actor */
1189{ 1211{
@@ -1340,6 +1362,11 @@ xs_dict *msg_actor(snac *snac)
1340 msg = xs_dict_set(msg, "manuallyApprovesFollowers", 1362 msg = xs_dict_set(msg, "manuallyApprovesFollowers",
1341 xs_stock(xs_is_true(manually) ? XSTYPE_TRUE : XSTYPE_FALSE)); 1363 xs_stock(xs_is_true(manually) ? XSTYPE_TRUE : XSTYPE_FALSE));
1342 1364
1365 /* if there are location coords, create a Place object */
1366 xs *location = msg_place(snac, "Home");
1367 if (xs_type(location) == XSTYPE_DICT)
1368 msg = xs_dict_set(msg, "location", location);
1369
1343 /* cache it */ 1370 /* cache it */
1344 snac_debug(snac, 1, xs_fmt("Caching actor %s", snac->actor)); 1371 snac_debug(snac, 1, xs_fmt("Caching actor %s", snac->actor));
1345 object_add_ow(snac->actor, msg); 1372 object_add_ow(snac->actor, msg);
diff --git a/html.c b/html.c
index eb4ab1f..3498b93 100644
--- a/html.c
+++ b/html.c
@@ -1311,7 +1311,7 @@ xs_html *html_top_controls(snac *snac)
1311 xs_html_attr("for", "show_contact_metrics"), 1311 xs_html_attr("for", "show_contact_metrics"),
1312 xs_html_text(L("Publish follower and following metrics")))), 1312 xs_html_text(L("Publish follower and following metrics")))),
1313 xs_html_tag("p", 1313 xs_html_tag("p",
1314 xs_html_text(L("Home location:")), 1314 xs_html_text(L("Current location:")),
1315 xs_html_sctag("br", NULL), 1315 xs_html_sctag("br", NULL),
1316 xs_html_sctag("input", 1316 xs_html_sctag("input",
1317 xs_html_attr("type", "text"), 1317 xs_html_attr("type", "text"),