parsav  Diff

Differences From Artifact [48c04bb947]:

To Artifact [8f0d6bf9b0]:


    17     17   			var act = co:ppostv('act')
    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         -				lib.dbg('encircling user!')
    25     24   				var allcircs = co.srv:circle_search(&co.srv.pool, co.who.id, 0)
    26     25   				var mycircs = co.srv:circle_memberships_uid(&co.srv.pool, co.who.id, actor.id)
    27     26   				var marked = co.srv.pool:alloc(bool, allcircs.ct)
    28     27   				var member = co.srv.pool:alloc(bool, allcircs.ct)
    29     28   				for i = 0, marked.ct do
    30     29   					marked(i) = false
    31     30   					member(i) = false
................................................................................
   107    106   		handle.ct = uri.ct - 2
   108    107   		uri:advance(uri.ct)
   109    108   	elseif handle.ct + 2 < uri.ct then uri:advance(handle.ct + 2) end
   110    109   
   111    110   	lib.dbg('looking up user by xid "', {handle.ptr,handle.ct} ,'", path: ', {uri.ptr,uri.ct})
   112    111   
   113    112   	var path = lib.http.hier(&co.srv.pool, uri) --defer path:free()
   114         -	for i=0,path.ct do
   115         -		lib.dbg('got path component ', {path.ptr[i].ptr, path.ptr[i].ct})
   116         -	end
   117    113   
   118    114   	var actor = co.srv:actor_fetch_xid(handle)
   119    115   	if actor.ptr == nil then
   120    116   		co:complain(404,'no such user','no such user known to this server')
   121    117   		return
   122    118   	end
   123    119   	defer actor:free()
................................................................................
   924    920   	if not data then goto e404 end
   925    921   	do defer data:free() defer mime:free()
   926    922   		co:bytestream(mime,data)
   927    923   	return end
   928    924   
   929    925   	::e404:: do co:complain(404, 'artifact not found', 'no such artifact has been uploaded to this instance') return end
   930    926   end
          927  +
          928  +local json = {}
          929  +
          930  +terra json.webfinger(co: &lib.srv.convo)
          931  +	
          932  +end
   931    933   
   932    934   -- entry points
   933    935   terra r.dispatch_http(co: &lib.srv.convo, uri: lib.mem.ptr(int8), meth: method.t)
   934    936   	lib.dbg('handling URI of form ', {uri.ptr,uri.ct})
   935    937   	co.navbar = lib.render.nav(co)
   936    938   	-- some routes are non-hierarchical, and can be resolved with a simple strcmp
   937    939   	-- we run through those first before giving up and parsing the URI
................................................................................
   965    967   	elseif uri:cmp( '/logout') then
   966    968   		if co.aid == 0
   967    969   			then goto notfound
   968    970   			else co:reroute_cookie('/','auth=; Path=/')
   969    971   		end
   970    972   	else -- hierarchical routes
   971    973   		var path = lib.http.hier(&co.srv.pool, uri) --defer path:free()
   972         -		if path.ct > 1 and path(0):cmp(lib.str.lit('user')) then
          974  +		if path.ct > 1 and path(0):cmp('user') then
   973    975   			http.actor_profile_uid(co, path, meth)
   974         -		elseif path.ct > 1 and path(0):cmp(lib.str.lit('post')) then
          976  +		elseif path.ct > 1 and path(0):cmp('post') then
   975    977   			http.tweet_page(co, path, meth)
   976         -		elseif path(0):cmp(lib.str.lit('tl')) then
          978  +		elseif path(0):cmp('tl') then
   977    979   			http.timeline(co, path)
   978         -		elseif path(0):cmp(lib.str.lit('media')) then
          980  +		elseif path(0):cmp('.well-known') then
          981  +			if path(1):cmp('webfinger') then
          982  +				json.webfinger(co)
          983  +			end
          984  +		elseif path(0):cmp('media') then
   979    985   			if co.aid == 0 then goto unauth end
   980    986   			http.media_manager(co, path, meth, co.who.id)
   981         -		elseif path(0):cmp(lib.str.lit('doc')) then
          987  +		elseif path(0):cmp('doc') then
   982    988   			if not meth_get(meth) then goto wrongmeth end
   983    989   			http.documentation(co, path)
   984         -		elseif path(0):cmp(lib.str.lit('conf')) then
          990  +		elseif path(0):cmp('conf') then
   985    991   			if co.aid == 0 then goto unauth end
   986    992   			http.configure(co,path,meth)
   987    993   		else goto notfound end
   988    994   	end
   989    995   	do return end
   990    996   
   991    997   	::wrongmeth:: co:complain(405, 'method not allowed', 'that method is not meaningful for this endpoint') do return end
   992    998   	::notfound:: co:complain(404, 'not found', 'no such resource available') do return end
   993    999   	::unauth:: co:complain(401, 'unauthorized', 'this content is not available at your clearance level') do return end
   994   1000   end