Differences From
Artifact [a232000d86]:
11 11
12 12 terra http.actor_profile(co: &lib.srv.convo, actor: &lib.store.actor, meth: method.t)
13 13 var rel: lib.store.relationship
14 14 if co.aid ~= 0 then
15 15 rel = co.srv:actor_rel_calc(co.who.id, actor.id)
16 16 if meth == method.post then
17 17 var act = co:ppostv('act')
18 - if act:cmp(lib.str.plit 'follow') and not rel.rel.follow() then
19 - if rel.recip.block() then
18 + if rel.recip.block() then
19 + if act:cmp(lib.str.plit 'follow') or act:cmp(lib.str.plit 'subscribe') then
20 20 co:complain(403,'blocked','you cannot follow a user you are blocked by') return
21 21 end
22 - (rel.rel.follow << true)
23 - co.srv:actor_rel_create([lib.store.relation.idvmap.follow], co.who.id, actor.id)
24 - elseif act:cmp(lib.str.plit 'unfollow') and rel.rel.follow() then
25 - (rel.rel.follow << false)
26 - co.srv:actor_rel_destroy([lib.store.relation.idvmap.follow], co.who.id, actor.id)
22 + end
23 + if act:cmp(lib.str.plit 'block') and not rel.rel.block() then
24 + (rel.rel.block << true) ; (rel.recip.follow << false)
25 + co.srv:actor_rel_create([lib.store.relation.idvmap.block], co.who.id, actor.id)
26 + co.srv:actor_rel_destroy([lib.store.relation.idvmap.follow], actor.id, co.who.id)
27 + else
28 + [(function()
29 + local tests = quote co:complain(400,'bad request','the action you have attempted on this user is not meaningful') return end
30 + for i,v in ipairs(lib.store.relation.members) do
31 + tests = quote
32 + if [v ~= 'block'] and act:cmp(lib.str.plit([v])) and not rel.rel.[v]() then -- rely on dead code elimination :/
33 + (rel.rel.[v] << true)
34 + co.srv:actor_rel_create([lib.store.relation.idvmap[v]], co.who.id, actor.id)
35 + elseif act:cmp(lib.str.plit(['un'..v])) and rel.rel.[v]() then
36 + (rel.rel.[v] << false)
37 + co.srv:actor_rel_destroy([lib.store.relation.idvmap[v]], co.who.id, actor.id)
38 + else [tests] end
39 + end
40 + end
41 + return tests
42 + end)()]
27 43 end
28 44 end
29 45 else
30 46 rel.rel:clear()
31 47 rel.recip:clear()
32 48 end
33 49
................................................................................
42 58 if handle.ct == 0 then
43 59 handle.ct = uri.ct - 2
44 60 uri:advance(uri.ct)
45 61 elseif handle.ct + 2 < uri.ct then uri:advance(handle.ct + 2) end
46 62
47 63 lib.dbg('looking up user by xid "', {handle.ptr,handle.ct} ,'", path: ', {uri.ptr,uri.ct})
48 64
49 - var path = lib.http.hier(uri) defer path:free()
65 + var path = lib.http.hier(&co.srv.pool, uri) --defer path:free()
50 66 for i=0,path.ct do
51 67 lib.dbg('got path component ', {path.ptr[i].ptr, path.ptr[i].ct})
52 68 end
53 69
54 70 var actor = co.srv:actor_fetch_xid(handle)
55 71 if actor.ptr == nil then
56 72 co:complain(404,'no such user','no such user known to this server')
................................................................................
318 334 credsec_for_uid(co: &lib.srv.convo, uid: uint64)
319 335 var act = co:ppostv('act')
320 336 lib.dbg('showing credentials')
321 337 if act:cmp(lib.str.plit 'invalidate') then
322 338 lib.dbg('setting user\'s cookie validation time to now')
323 339 co.who.source:auth_sigtime_user_alter(uid, lib.osclock.time(nil))
324 340 -- the current session has been invalidated as well, so we need to immediately install a new authentication cookie with the same aid so the user doesn't need to log back in all over again
325 - co:installkey('/conf/sec',co.aid)
341 + co:installkey('?',co.aid)
326 342 return
327 343 elseif act:cmp(lib.str.plit 'newcred') then
328 344 var cmt = co:ppostv('comment')
329 345 var pw = co:ppostv('newpw')
330 346 var aid: uint64 = 0
331 347 if pw:ref() then
332 348 var cpw = co:ppostv('rptpw')
................................................................................
692 708 end
693 709 elseif uri:cmp(lib.str.plit '/logout') then
694 710 if co.aid == 0
695 711 then goto notfound
696 712 else co:reroute_cookie('/','auth=; Path=/')
697 713 end
698 714 else -- hierarchical routes
699 - var path = lib.http.hier(uri) defer path:free()
715 + var path = lib.http.hier(&co.srv.pool, uri) --defer path:free()
700 716 if path.ct > 1 and path(0):cmp(lib.str.lit('user')) then
701 717 http.actor_profile_uid(co, path, meth)
702 718 elseif path.ct > 1 and path(0):cmp(lib.str.lit('post')) then
703 719 http.tweet_page(co, path, meth)
704 720 elseif path(0):cmp(lib.str.lit('tl')) then
705 721 http.timeline(co, path)
706 722 elseif path(0):cmp(lib.str.lit('media')) then