parsav  Diff

Differences From Artifact [b336ed6430]:

To Artifact [c96b63a8f1]:


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40











41
42
43
44
45
46
47
48
49
50
51
52
53

54
55
		"preferredUsername": %$handle,
		"name": %$nym,
		"summary": %$desc,
		"alsoKnownAs": ["https://%+domain/@%+handle"],
		"publicKey": {
			"id": "%lpid#ident-rsa",
			"owner": "%lpid",
			"publicKeyPem": %rsa
		},
		"icon": {
			"type": "Image",
			"url": "https://%+domain%+avi"
		},
		"capabilities": { "acceptsChatMessages": false },
		"discoverable": true,
................................................................................
		"outbox": "https://%+domain/api/lp/outbox/user/%uid",
		"followers": "https://%+domain/api/lp/rel/%uid/followers",
		"following": "https://%+domain/api/lp/rel/%uid/following"
	}]];
}

local pstr = lib.str.t
terra cs(s: rawstring) return pstr {s, lib.str.sz(s)} end

local terra 
api_lp_actor(co: &lib.srv.convo, actor: &lib.store.actor)
	var lpid = co:stra(64)
	lpid:lpush'https://':ppush(co.srv.cfg.domain):lpush'/user/':shpush(actor.id)
	var uid = co:stra(32) uid:shpush(actor.id) -- dumb hack bc lazy FIXME












	var body = tpl {
		domain = co.srv.cfg.domain;
		uid = uid:finalize();
		lpid = lpid:finalize();
		handle = cs(actor.handle);
		nym = cs(actor.nym);
		desc = cs(actor.bio);
		avi = cs(actor.avatar);
		rsa = '';
		locked = 'false';
	}

	co:json(body:poolstr(&co.srv.pool))

end
return api_lp_actor







|







 







|







>
>
>
>
>
>
>
>
>
>
>








|




>


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
		"preferredUsername": %$handle,
		"name": %$nym,
		"summary": %$desc,
		"alsoKnownAs": ["https://%+domain/@%+handle"],
		"publicKey": {
			"id": "%lpid#ident-rsa",
			"owner": "%lpid",
			"publicKeyPem": %$rsa
		},
		"icon": {
			"type": "Image",
			"url": "https://%+domain%+avi"
		},
		"capabilities": { "acceptsChatMessages": false },
		"discoverable": true,
................................................................................
		"outbox": "https://%+domain/api/lp/outbox/user/%uid",
		"followers": "https://%+domain/api/lp/rel/%uid/followers",
		"following": "https://%+domain/api/lp/rel/%uid/following"
	}]];
}

local pstr = lib.str.t
terra cs(s: rawstring) return pstr {s, lib.trn(s == nil,0,lib.str.sz(s))} end

local terra 
api_lp_actor(co: &lib.srv.convo, actor: &lib.store.actor)
	var lpid = co:stra(64)
	lpid:lpush'https://':ppush(co.srv.cfg.domain):lpush'/user/':shpush(actor.id)
	var uid = co:stra(32) uid:shpush(actor.id) -- dumb hack bc lazy FIXME

	var upk = lib.crypt.loadpriv(actor.key)
	var pem: lib.crypt.pemfile

	if not upk.ok then
		lib.warn("could not load user's keypair; this is a sign of a bug, a corrupt database, or a problem with mbedtls")
	else defer upk.val:free()
		if not lib.crypt.pem(true, &upk.val, &pem[0]) then
			pem[0] = 0;
			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')
		end
	end
	var body = tpl {
		domain = co.srv.cfg.domain;
		uid = uid:finalize();
		lpid = lpid:finalize();
		handle = cs(actor.handle);
		nym = cs(actor.nym);
		desc = cs(actor.bio);
		avi = cs(actor.avatar);
		rsa = cs(&pem[0]);
		locked = 'false';
	}

	co:json(body:poolstr(&co.srv.pool))

end
return api_lp_actor