Przeglądaj źródła

If a location is defined, user actors include a 'Place' object.

default 3 miesięcy temu
rodzic
commit
538f6970f8
2 zmienionych plików z 28 dodań i 1 usunięć
  1. 27 0
      activitypub.c
  2. 1 1
      html.c

+ 27 - 0
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);

+ 1 - 1
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"),