parsav  Diff

Differences From Artifact [23df5e6037]:

To Artifact [48c04bb947]:


    18     18   			if rel.recip.block() then
    19     19   				if act:cmp('follow') or act:cmp('subscribe') then
    20     20   					co:complain(403,'blocked','you cannot follow a user you are blocked by') return
    21     21   				end
    22     22   			end
    23     23   			if act:cmp('circle') then
    24     24   				lib.dbg('encircling user!')
           25  +				var allcircs = co.srv:circle_search(&co.srv.pool, co.who.id, 0)
           26  +				var mycircs = co.srv:circle_memberships_uid(&co.srv.pool, co.who.id, actor.id)
           27  +				var marked = co.srv.pool:alloc(bool, allcircs.ct)
           28  +				var member = co.srv.pool:alloc(bool, allcircs.ct)
           29  +				for i = 0, marked.ct do
           30  +					marked(i) = false
           31  +					member(i) = false
           32  +					-- search through list of memberships to see if this circle is in them
           33  +					-- if it is, set its membership flag
           34  +					for j = 0, mycircs.ct do
           35  +						if mycircs(j).cid == allcircs(i).cid then
           36  +							member(i) = true
           37  +						end
           38  +					end
           39  +				end
           40  +
           41  +				-- which circles did the user mark this time?
    25     42   				var iter = co:eachpostv('circle')
    26     43   				for cid in iter do
           44  +					var decode, ok = lib.math.shorthand.parse(cid.ptr, cid.ct)
           45  +					if ok then
           46  +						for i=0, allcircs.ct do
           47  +							if allcircs(i).cid == decode then
           48  +								marked(i) = true
           49  +							end
           50  +						end
           51  +					end
           52  +				end
    27     53   
           54  +				-- compute the differential and carry out the appropriate action
           55  +				for i = 0, marked.ct do
           56  +					if marked(i) ~= member(i) then
           57  +						if marked(i) then -- newly marked, add
           58  +							co.srv:circle_members_add_uid(allcircs(i).cid, actor.id)
           59  +						elseif member(i) then -- unmarked, remove
           60  +							co.srv:circle_members_del_uid(allcircs(i).cid, actor.id)
           61  +						end
           62  +					end
    28     63   				end
           64  +
           65  +				-- thanks html for making this all so complicated
    29     66   			elseif act:cmp('block') and not rel.rel.block() then
    30     67   				rel.rel.block = true  rel.recip.follow = false
    31     68   				co.srv:actor_rel_create([lib.store.relation.idvmap.block], co.who.id, actor.id)
    32     69   				co.srv:actor_rel_destroy([lib.store.relation.idvmap.follow], actor.id, co.who.id)
    33     70   			elseif not act:cmp('report') then
    34     71   				[(function()
    35     72   					local tests = quote co:complain(400,'bad request','the action you have attempted on this user is not meaningful') return end
................................................................................
    49     86   			end
    50     87   		end
    51     88   	else
    52     89   		rel.rel:clear()
    53     90   		rel.recip:clear()
    54     91   	end
    55     92   
    56         -	lib.render.user_page(co, actor, &rel)
           93  +	var go = co:pgetv('go')
           94  +	if not go or go(0) ~= @'/' then
           95  +		lib.render.user_page(co, actor, &rel)
           96  +	else
           97  +		co:reroute(go.ptr)
           98  +	end
    57     99   end
    58    100   
    59    101   terra http.actor_profile_xid(co: &lib.srv.convo, uri: lib.mem.ptr(int8), meth: method.t)
    60    102   	var handle = [lib.mem.ptr(int8)] { ptr = &uri.ptr[2], ct = 0 }
    61    103   	for i=2,uri.ct do
    62    104   		if uri.ptr[i] == @'/' or uri.ptr[i] == 0 then handle.ct = i - 2 break end
    63    105   	end