diff options
| author | 2025-01-10 08:29:57 +0100 | |
|---|---|---|
| committer | 2025-01-10 08:29:57 +0100 | |
| commit | 538f6970f86323dca734436861fe19193fae87e5 (patch) | |
| tree | a9e3e0606b554308bbad00a4ed9d1924a341d853 /activitypub.c | |
| parent | Show the location in the public page. (diff) | |
| download | penes-snac2-538f6970f86323dca734436861fe19193fae87e5.tar.gz penes-snac2-538f6970f86323dca734436861fe19193fae87e5.tar.xz penes-snac2-538f6970f86323dca734436861fe19193fae87e5.zip | |
If a location is defined, user actors include a 'Place' object.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 27 |
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) | |||
| 1184 | } | 1184 | } |
| 1185 | 1185 | ||
| 1186 | 1186 | ||
| 1187 | xs_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 | |||
| 1187 | xs_dict *msg_actor(snac *snac) | 1209 | xs_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); |