Differences From
Artifact [1ada03554b]:
4 4 local obj = lib.tpl.mk [[{
5 5 "\@context": "https://@+domain/s/litepub.jsonld",
6 6 "type": "Note",
7 7 "id": "https://@+domain/post/@^pid",
8 8 "content": @$html,
9 9 "source": @$raw,
10 10 "attributedTo": "https://@+domain/user/@^uid",
11 - "published": "@pubtime"
11 + "actor": "https://@+domain/user/@^uid",
12 + "published": "@pubtime",
13 + "sensitive": false,
14 + "directMessage": false,
15 + "to": ["https://www.w3.org/ns/activitystreams#Public"],
16 + "summary": @$subj
12 17 @extra
13 18 }]]
14 19
15 20 local wrap = lib.tpl.mk [[{
16 21 "\@context": "https://@+domain/s/litepub.jsonld",
17 22 "type": "@kind",
18 23 "actor": "https://@+domain/user/@^uid",
19 24 "published": "@pubtime",
20 25 "id": "https://@+domain/api/lp/act/@^aid",
26 + "to": ["https://www.w3.org/ns/activitystreams#Public"],
21 27 "object": @obj
22 28 }]]
23 29
24 30 local terra
25 -lp_tweet(co: &lib.srv.convo, p: &lib.store.post, act_wrap: bool)
26 - var opdate = lib.conv.datetime(&co.srv.pool, p.posted)
31 +lp_tweet(co: &lib.srv.convo, p: &lib.store.post, act_wrap: bool): pstr
32 + var opdate = lib.munge.datetime(&co.srv.pool, p.posted)
33 +
34 + var extra: lib.str.acc extra:pool(&co.srv.pool,256)
35 +
36 + if p.parent ~= 0 then
37 + extra:lpush ',"inReplyTo":"'
38 + var par = co.srv:post_fetch(p.parent)
39 + if not par then
40 + lib.warn('database integrity violation: broken parent reference')
41 + else defer par:free()
42 + if par().localpost then -- gen uri for parent
43 + extra:lpush'https://':qpush(co.srv.cfg.domain):lpush'/post/':shpush(p.parent)
44 + else extra:push(par().uri,0) end
45 + end
46 + extra:lpush'"'
47 + end
48 +
49 + extra:lpush ',"conversation":"'
50 + if p.convoheaduri ~= nil then
51 + extra:qpush(p.convoheaduri)
52 + else
53 + var cid: uint64 = 0
54 + if p.parent ~= 0 then
55 + var top = co.srv:thread_top_find(p.parent)
56 + var tp = co.srv:post_fetch(top)
57 + if not tp then
58 + lib.warn('database integrity violation: missing thread parent')
59 + cid = p.id
60 + else
61 + if tp().convoheaduri ~= nil then
62 + extra:push(tp().convoheaduri,0)
63 + elseif tp().localpost == false then
64 + extra:push(tp().uri,0)
65 + else cid = top end
66 + end
67 + else
68 + cid = p.id
69 + end
70 + if cid ~= 0 then
71 + extra:lpush'https://':qpush(co.srv.cfg.domain)
72 + :lpush'/post/':shpush(cid):lpush'/tree'
73 + end
74 + end
75 + extra:lpush'"'
27 76
28 77 var tweet = (obj {
29 78 domain = co.srv.cfg.domain, uid = p.author, pid = p.id;
30 79 html = lib.smackdown.html(&co.srv.pool, p.body, false);
31 - raw = p.body, pubtime = opdate, extra = '';
80 + raw = p.body, pubtime = opdate, extra = extra:finalize();
81 + subj = lib.trn(p.subject ~= nil, pstr(p.subject), pstr'');
32 82 }):poolstr(&co.srv.pool)
33 83
34 84 if act_wrap then
35 85 return (wrap {
36 86 domain = co.srv.cfg.domain, obj = tweet;
37 87 kind = lib.trn(p.rtdby == 0, 'Create', 'Announce');
38 88 uid = lib.trn(p.rtdby == 0, p.author, p.rtdby);
39 89 aid = lib.trn(p.rtdby == 0, p.id, p.rtact);
40 90 pubtime = lib.trn(p.rtdby == 0, opdate,
41 - lib.conv.datetime(&co.srv.pool,p.rtdat));
91 + lib.munge.datetime(&co.srv.pool,p.rtdat));
42 92 }):poolstr(&co.srv.pool)
43 93 else
44 94 return tweet
45 95 end
46 96 end
47 97
48 98 return lp_tweet