commit 751eb05

default  ·  2023-07-29 13:19:52 +0000 UTC
parent 0f8c0cd
msg_create() is of type @wrapper.

This means that it also generate the same id for the same Note.
1 files changed,  +11, -1
+11, -1
 1@@ -764,6 +764,16 @@ xs_dict *msg_base(snac *snac, const char *type, const char *id,
 2             else
 3                 id = NULL;
 4         }
 5+        else
 6+        if (strcmp(id, "@wrapper") == 0) {
 7+            /* like @object, but always generate the same id */
 8+            if (object != NULL) {
 9+                did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
10+                id = did;
11+            }
12+            else
13+                id = NULL;
14+        }
15     }
16 
17     xs_dict *msg = xs_dict_new();
18@@ -935,7 +945,7 @@ xs_dict *msg_actor(snac *snac)
19 xs_dict *msg_create(snac *snac, const xs_dict *object)
20 /* creates a 'Create' message */
21 {
22-    xs_dict *msg = msg_base(snac, "Create", "@object", snac->actor, "@now", object);
23+    xs_dict *msg = msg_base(snac, "Create", "@wrapper", snac->actor, "@now", object);
24     xs_val *v;
25 
26     if ((v = xs_dict_get(object, "attributedTo")))