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