Differences From
Artifact [b336ed6430]:
9 9 "preferredUsername": %$handle,
10 10 "name": %$nym,
11 11 "summary": %$desc,
12 12 "alsoKnownAs": ["https://%+domain/@%+handle"],
13 13 "publicKey": {
14 14 "id": "%lpid#ident-rsa",
15 15 "owner": "%lpid",
16 - "publicKeyPem": %rsa
16 + "publicKeyPem": %$rsa
17 17 },
18 18 "icon": {
19 19 "type": "Image",
20 20 "url": "https://%+domain%+avi"
21 21 },
22 22 "capabilities": { "acceptsChatMessages": false },
23 23 "discoverable": true,
................................................................................
26 26 "outbox": "https://%+domain/api/lp/outbox/user/%uid",
27 27 "followers": "https://%+domain/api/lp/rel/%uid/followers",
28 28 "following": "https://%+domain/api/lp/rel/%uid/following"
29 29 }]];
30 30 }
31 31
32 32 local pstr = lib.str.t
33 -terra cs(s: rawstring) return pstr {s, lib.str.sz(s)} end
33 +terra cs(s: rawstring) return pstr {s, lib.trn(s == nil,0,lib.str.sz(s))} end
34 34
35 35 local terra
36 36 api_lp_actor(co: &lib.srv.convo, actor: &lib.store.actor)
37 37 var lpid = co:stra(64)
38 38 lpid:lpush'https://':ppush(co.srv.cfg.domain):lpush'/user/':shpush(actor.id)
39 39 var uid = co:stra(32) uid:shpush(actor.id) -- dumb hack bc lazy FIXME
40 40
41 + var upk = lib.crypt.loadpriv(actor.key)
42 + var pem: lib.crypt.pemfile
43 +
44 + if not upk.ok then
45 + lib.warn("could not load user's keypair; this is a sign of a bug, a corrupt database, or a problem with mbedtls")
46 + else defer upk.val:free()
47 + if not lib.crypt.pem(true, &upk.val, &pem[0]) then
48 + pem[0] = 0;
49 + lib.warn('could not export actor certificate as PEM file; there is a bug, the database is corrupt, or there is a problem in mbedtls')
50 + end
51 + end
41 52 var body = tpl {
42 53 domain = co.srv.cfg.domain;
43 54 uid = uid:finalize();
44 55 lpid = lpid:finalize();
45 56 handle = cs(actor.handle);
46 57 nym = cs(actor.nym);
47 58 desc = cs(actor.bio);
48 59 avi = cs(actor.avatar);
49 - rsa = '';
60 + rsa = cs(&pem[0]);
50 61 locked = 'false';
51 62 }
52 63
53 64 co:json(body:poolstr(&co.srv.pool))
65 +
54 66 end
55 67 return api_lp_actor