Index: backend/pgsql.t ================================================================== --- backend/pgsql.t +++ backend/pgsql.t @@ -1227,20 +1227,20 @@ local privupdate = terra( src: &lib.store.source, ac: &lib.store.actor ): {} - var pdef: lib.store.powerset pdef:clear() + var pdef = lib.store.rights_default().powers var map = array([privmap]) for i=0, [map.type.N] do var d = pdef and map[i].val var u = ac.rights.powers and map[i].val queries.actor_power_delete.exec(src, ac.id, map[i].name) - if d:sz() > 0 and u:sz() == 0 then + if d:any() and u:sz() == 0 then lib.dbg('blocking power ', {map[i].name.ptr, map[i].name.ct}) queries.actor_power_insert.exec(src, ac.id, map[i].name, 0) - elseif d:sz() == 0 and u:sz() > 0 then + elseif d:any() == false and u:sz() > 0 then lib.dbg('granting power ', {map[i].name.ptr, map[i].name.ct}) queries.actor_power_insert.exec(src, ac.id, map[i].name, 1) end end end Index: makefile ================================================================== --- makefile +++ makefile @@ -1,9 +1,9 @@ version = dev dl = git dbg-flags = $(if $(dbg),-g) - +build-vars = parsav_enable_debug=$(if $(dbg),yes,no) # for nix prefix = ${out} images = static/default-avatar.webp static/query.webp static/heart.webp static/retweet.webp static/reply.webp static/file.webp static/follow.webp #$(addsuffix .webp, $(basename $(wildcard static/*.svg))) @@ -11,15 +11,15 @@ # .PHONY: all # all: parsav parsavd parsav parsavd: parsav.t config.lua pkgdata.lua $(images) $(styles) - terra $(dbg-flags) $< + env $(build-vars) terra $(dbg-flags) $< parsav.o parsavd.o: parsav.t config.lua pkgdata.lua $(images) $(styles) - env parsav_link=no terra $(dbg-flags) $< + env $(build-vars) parsav_link=no terra $(dbg-flags) $< parsav.ll parsavd.ll: parsav.t config.lua pkgdata.lua $(images) $(styles) - env parsav_emit_type=ll parsav_link=no terra $(dbg-flags) $< + env $(build-vars) parsav_emit_type=ll parsav_link=no terra $(dbg-flags) $< parsav.s parsavd.ss: parsav.ll llc --march=$(target) $< static/%.svg.clean: static/%.svg svgcleaner $< $@ Index: parsav.t ================================================================== --- parsav.t +++ parsav.t @@ -280,10 +280,16 @@ set.name = string.format('set<%s>', table.concat(tbl, '|')) set.metamethods.__entrymissing = macro(function(val, obj) if o[val] == nil then error('value ' .. val .. ' not in set') end return `bit { _v=[o[val] - 1], _set = &(obj) } end) + terra set:any() + for i = 0, bytes - 1 do + if self._store[i] ~= 0 then return true end + end + return false + end terra set:sz() var ct: intptr = 0 --for i = 0, [math.floor(#tbl/8)] do -- ct = ct + lib.math.ll.ctpop_u8(self._store[i]) --end Index: render/timeline.t ================================================================== --- render/timeline.t +++ render/timeline.t @@ -16,14 +16,17 @@ modestr = hpath(1) if hpath.ct >= 3 then spec = hpath(2) end end var mode = modes.follow var circle: uint64 = 0 + var reqPowers: lib.store.powerset + reqPowers:clear() + reqPowers.visible = true if modestr:ref() then - if modestr:cmp('local' ) then mode = [modes['local']] + if modestr:cmp('local' ) then mode = [modes['local']] reqPowers.shout = true elseif modestr:cmp('mutual') then mode = modes.mutual - elseif modestr:cmp('fedi' ) then mode = modes.fedi + elseif modestr:cmp('fedi' ) then mode = modes.fedi reqPowers.shout = true elseif modestr:cmp('circle') then mode = modes.circle end end if requires_login(mode) and co.aid == 0 then mode = [modes['local']] end @@ -99,17 +102,21 @@ if mode == modes.mutual and posts(i).ptr.author ~= co.who.id then if not author.relationship.recip.follow() then goto skip end end if author.relationship.rel.mute() or author.relationship.rel.avoid() or - author.relationship.recip.exclude() then goto skip end + author.relationship.recip.exclude() or + (not ((author.rights.powers and reqPowers) == reqPowers)) + then goto skip end if posts(i).ptr.rtdby ~= 0 then var rter = co:uid2actor(posts(i).ptr.rtdby) if rter.relationship.rel.mute() or rter.relationship.rel.attenuate() or rter.relationship.rel.avoid() - or rter.relationship.recip.exclude() then goto skip end + or rter.relationship.recip.exclude() + or (not ((rter.rights.powers and reqPowers) == reqPowers)) + then goto skip end end lib.render.tweet(co, posts(i).ptr, &acc) var t = lib.math.biggest(lib.math.biggest(posts(i).ptr.posted, posts(i).ptr.discovered),posts(i).ptr.edited) if t > newest then newest = t end ::skip:: posts(i):free() Index: route.t ================================================================== --- route.t +++ route.t @@ -732,12 +732,13 @@ end elseif path.ct == 2 and meth == method.post then var act = co:ppostv('act') if act:cmp('create') then var newname = co:ppostv('handle') - if not newname or not lib.store.actor.handle_validate(newname.ptr) then + if (not newname) or (not lib.store.actor.handle_validate(newname)) then co:complain(400,'invalid handle','the handle you have requested is not valid') + return end var tu = co.srv:actor_fetch_xid(newname) if tu:ref() then tu:free() co:complain(409,'handle clash','that handle conflicts with one that already exists') return Index: store.t ================================================================== --- store.t +++ store.t @@ -161,12 +161,12 @@ return true end return self:outranks(other) end -terra m.actor.methods.handle_validate(hnd: rawstring) - if hnd[0] == 0 then +terra m.actor.methods.handle_validate(hnd: pstr) + if hnd.ct == 0 then return false end -- TODO validate fully return true end