commit 538f697

default  ·  2025-01-10 07:29:57 +0000 UTC
parent ea2eb32
If a location is defined, user actors include a 'Place' object.
2 files changed,  +28, -1
M html.c
+27, -0
 1@@ -1184,6 +1184,28 @@ xs_dict *msg_repulsion(snac *user, const char *id, const char *type)
 2 }
 3 
 4 
 5+xs_dict *msg_place(snac *user, const char *label)
 6+/* creates a Place object, if the user has a location defined */
 7+{
 8+    xs *place = NULL;
 9+    const char *latitude = xs_dict_get_def(user->config, "latitude", "");
10+    const char *longitude = xs_dict_get_def(user->config, "longitude", "");
11+
12+    if (*latitude && *longitude) {
13+        xs *d_la = xs_number_new(atof(latitude));
14+        xs *d_lo = xs_number_new(atof(longitude));
15+
16+        place = msg_base(user, "Place", NULL, user->actor, NULL, NULL);
17+
18+        place = xs_dict_set(place, "name", label);
19+        place = xs_dict_set(place, "latitude", d_la);
20+        place = xs_dict_set(place, "longitude", d_lo);
21+    }
22+
23+    return place;
24+}
25+
26+
27 xs_dict *msg_actor(snac *snac)
28 /* create a Person message for this actor */
29 {
30@@ -1340,6 +1362,11 @@ xs_dict *msg_actor(snac *snac)
31     msg = xs_dict_set(msg, "manuallyApprovesFollowers",
32         xs_stock(xs_is_true(manually) ? XSTYPE_TRUE : XSTYPE_FALSE));
33 
34+    /* if there are location coords, create a Place object */
35+    xs *location = msg_place(snac, "Home");
36+    if (xs_type(location) == XSTYPE_DICT)
37+        msg = xs_dict_set(msg, "location", location);
38+
39     /* cache it */
40     snac_debug(snac, 1, xs_fmt("Caching actor %s", snac->actor));
41     object_add_ow(snac->actor, msg);
M html.c
+1, -1
1@@ -1311,7 +1311,7 @@ xs_html *html_top_controls(snac *snac)
2                         xs_html_attr("for", "show_contact_metrics"),
3                         xs_html_text(L("Publish follower and following metrics")))),
4                 xs_html_tag("p",
5-                    xs_html_text(L("Home location:")),
6+                    xs_html_text(L("Current location:")),
7                     xs_html_sctag("br", NULL),
8                     xs_html_sctag("input",
9                         xs_html_attr("type", "text"),