Overview
| Comment: | finish up LP support for user outbox views |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
3f080eded4c19d163503b04791aca4e3 |
| User & Date: | lexi on 2021-01-25 13:24:48 |
| Other Links: | manifest | tags |
Context
|
2021-01-25
| ||
| 14:38 | iterating check-in: 050ce7d4fc user: lexi tags: trunk | |
| 13:24 | finish up LP support for user outbox views check-in: 3f080eded4 user: lexi tags: trunk | |
| 12:41 | commit missing file check-in: bd5794c0cc user: lexi tags: trunk | |
Changes
Modified api/lp/tweet.t from [e0805dcd2f] to [1ada03554b].
12 12 @extra 13 13 }]] 14 14 15 15 local wrap = lib.tpl.mk [[{ 16 16 "\@context": "https://@+domain/s/litepub.jsonld", 17 17 "type": "@kind", 18 18 "actor": "https://@+domain/user/@^uid", 19 - "published": "@$pubtime", 19 + "published": "@pubtime", 20 20 "id": "https://@+domain/api/lp/act/@^aid", 21 21 "object": @obj 22 22 }]] 23 23 24 24 local terra 25 25 lp_tweet(co: &lib.srv.convo, p: &lib.store.post, act_wrap: bool) 26 - 26 + var opdate = lib.conv.datetime(&co.srv.pool, p.posted) 27 + 27 28 var tweet = (obj { 28 29 domain = co.srv.cfg.domain, uid = p.author, pid = p.id; 29 30 html = lib.smackdown.html(&co.srv.pool, p.body, false); 30 - raw = p.body, pubtime = '', extra = ''; 31 + raw = p.body, pubtime = opdate, extra = ''; 31 32 }):poolstr(&co.srv.pool) 32 33 33 34 if act_wrap then 34 35 return (wrap { 35 - domain = co.srv.cfg.domain; 36 + domain = co.srv.cfg.domain, obj = tweet; 36 37 kind = lib.trn(p.rtdby == 0, 'Create', 'Announce'); 37 38 uid = lib.trn(p.rtdby == 0, p.author, p.rtdby); 38 39 aid = lib.trn(p.rtdby == 0, p.id, p.rtact); 39 - pubtime = '', obj = tweet; 40 + pubtime = lib.trn(p.rtdby == 0, opdate, 41 + lib.conv.datetime(&co.srv.pool,p.rtdat)); 40 42 }):poolstr(&co.srv.pool) 41 43 else 42 44 return tweet 43 45 end 44 46 end 45 47 46 48 return lp_tweet
Modified backend/pgsql.t from [4517a951a0] to [040ddf2134].
1071 1071 p.ptr.parent = r:int(uint64,row,9) 1072 1072 if r:null(row,11) 1073 1073 then p.ptr.chgcount = 0 1074 1074 else p.ptr.chgcount = r:int(uint32,row,11) 1075 1075 end 1076 1076 p.ptr.accent = r:int(int16,row,12) 1077 1077 p.ptr.rtdby = r:int(uint64,row,13) 1078 - p.ptr.rtact = r:int(uint64,row,14) 1079 - p.ptr.likes = r:int(uint32,row,15) 1080 - p.ptr.rts = r:int(uint32,row,16) 1081 - p.ptr.isreply = r:bool(row,17) 1078 + p.ptr.rtdat = r:int(uint64,row,14) 1079 + p.ptr.rtact = r:int(uint64,row,15) 1080 + p.ptr.likes = r:int(uint32,row,16) 1081 + p.ptr.rts = r:int(uint32,row,17) 1082 + p.ptr.isreply = r:bool(row,18) 1082 1083 p.ptr.localpost = r:bool(row,0) 1083 1084 1084 1085 return p 1085 1086 end 1086 1087 local terra row_to_actor(r: &pqr, row: intptr): lib.mem.ptr(lib.store.actor) 1087 1088 var a: lib.mem.ptr(lib.store.actor) 1088 1089 var av: rawstring, avlen: intptr
Modified backend/schema/pgsql-views.sql from [ac2cb76c4f] to [b916bb0a63].
109 109 edited bigint, 110 110 parent bigint, 111 111 convoheaduri text, 112 112 chgcount integer, 113 113 -- ephemeral 114 114 accent smallint, 115 115 rtdby bigint, -- note that these must be 0 if the record 116 - rtid bigint, -- in question does not represent an RT! 116 + rtdat bigint, -- in question does not represent an RT! 117 + rtid bigint, -- (this one too) 117 118 n_likes integer, 118 119 n_rts integer, 119 120 isreply bool -- true if parent in (table posts); saves us a bunch of queries 120 121 ); 121 122 122 123 create or replace function 123 -pg_temp.parsavpg_translate_post(parsav_posts,bigint,bigint) 124 +pg_temp.parsavpg_translate_post(parsav_posts,bigint,bigint,bigint) 124 125 returns pg_temp.parsavpg_intern_post as $$ 125 126 select a.origin is null, 126 127 ($1).id, ($1).author, 127 128 ($1).subject,($1).acl, ($1).body, 128 129 ($1).posted, ($1).discovered, ($1).edited, 129 130 ($1).parent, ($1).convoheaduri,($1).chgcount, 130 131 coalesce(c.value, -1)::smallint, 131 - $2 as rtdby, $3 as rtid, 132 + $2 as rtdby, $3 as rtdat, $4 as rtid, 132 133 re.likes, re.rts, 133 134 ($1).parent in (select id from parsav_posts) 134 135 from parsav_actors as a 135 136 left join parsav_actor_conf_ints as c 136 137 on c.key = 'ui-accent' and 137 138 c.uid = a.id 138 139 left join pg_temp.parsavpg_post_react_counts as re ................................................................................ 158 159 inner join parsav_posts as p on a.subject = p.id 159 160 where a.kind = 'rt' 160 161 ), 161 162 162 163 content as (select * from posts union select * from rts) 163 164 164 165 select pg_temp.parsavpg_translate_post(cn.orig, 165 - coalesce(cn.promoter,0), coalesce(cn.promotion,0) 166 + coalesce(cn.promoter,0), 167 + coalesce(cn.promotime,0), 168 + coalesce(cn.promotion,0) 166 169 ) as post, 167 170 cn.promotime::bigint as tltime, 168 171 coalesce(cn.promoter, (cn.orig).author) as promoter 169 172 from content as cn 170 173 order by cn.promotime desc 171 174 ); 172 175
Added conv.t version [13b89ea2d7].
1 +-- vim: ft=terra 2 +local m={} 3 +local pstr = lib.str.t 4 + 5 +terra m.datetime(pool: &lib.mem.pool, when: lib.osclock.time_t) 6 + -- formats a unix epoch time as a dumbfuck XSD datetime spec 7 + var td: lib.osclock.tm 8 + if lib.osclock.gmtime_r(&when, &td) == nil then 9 + return pstr.null() 10 + end 11 + 12 + var tpl = [lib.tpl.mk ('@#year:-@MM@#month:-@dd@#day:T'.. 13 + '@hh@#hour::@mm@#min::@ss@#sec:Z')] { 14 + year = td.tm_year + 1900, month = td.tm_mon + 1, day = td.tm_mday; 15 + hour = td.tm_hour, min = td.tm_min, sec = td.tm_sec; 16 + MM = lib.trn(td.tm_mon+1 < 10, '0', ''); 17 + dd = lib.trn(td.tm_mday < 10, '0', ''); 18 + ss = lib.trn(td.tm_sec < 10, '0', ''); 19 + mm = lib.trn(td.tm_min < 10, '0', ''); 20 + hh = lib.trn(td.tm_min < 10, '0', ''); 21 + } 22 + 23 + return tpl:poolstr(pool) 24 +end 25 + 26 +return m
Modified parsav.t from [1d36a792dc] to [76fc393228].
441 441 lib.jc = lib.loadlib('json-c','json.h') 442 442 443 443 lib.load { 444 444 'mem', 'math', 'str', 'file', 'crypt', 'ipc'; 445 445 'http', 'html', 'session', 'tpl', 'store', 'acl'; 446 446 447 447 'smackdown'; -- md-alike parser 448 + 'conv'; -- miscellaneous conversion/munging functions 448 449 } 449 450 450 451 local be = {} 451 452 for _, b in pairs(config.backends) do 452 453 be[#be+1] = terralib.loadfile(string.format('backend/%s.t',b))() 453 454 end 454 455 lib.store.backends = global(`array([be]))
Modified store.t from [c7ef550a1d] to [33ecd773b1].
231 231 parent: uint64 232 232 -- ephemera 233 233 localpost: bool 234 234 accent: int16 235 235 rts: uint32 236 236 likes: uint32 237 237 rtdby: uint64 -- 0 if not rt 238 + rtdat: m.timepoint -- 0 if not rt, time of promotion otherwise 238 239 rtact: uint64 -- 0 if not rt, id of rt action otherwise 239 240 isreply: bool 240 241 source: &m.source 241 242 242 243 -- save :: bool -> {} (defined in acl.t due to dep. hell) 243 244 } 244 245
Modified tpl.t from [2f4ebceee0] to [b153c48352].
34 34 str = str:gsub('%s+[\n$]','') 35 35 str = str:gsub('\n','') 36 36 str = str:gsub('</a><a ','</a> <a ') -- keep nav links from getting smooshed 37 37 str = str:gsub(tplchar .. '%?([-%w]+)', function(file) 38 38 if not docs[file] then docs[file] = data.doc[file] end 39 39 return string.format('<a href="#help-%s" class="help">?</a>', file) 40 40 end) 41 - for start, mode, key, stop in string.gmatch(str,'()'..tplchar..'([+:!$#%^]?)([-a-zA-Z0-9_]+)()') do 41 + for start, mode, key, stop in string.gmatch(str,'()'..tplchar..'([+:!$#%^]?)([-a-zA-Z0-9_]+):?()') do 42 42 if string.sub(str,start-1,start-1) ~= '\\' then 43 43 segs[#segs+1] = string.sub(str,last,start-1) 44 44 fields[#segs] = { key = key:gsub('-','_'), mode = (mode ~= '' and mode or nil) } 45 45 last = stop 46 46 end 47 47 end 48 48 segs[#segs+1] = string.sub(str,last)