parsav  Diff

Differences From Artifact [8f0d6bf9b0]:

To Artifact [325df84c8e]:


   923    923   	return end
   924    924   
   925    925   	::e404:: do co:complain(404, 'artifact not found', 'no such artifact has been uploaded to this instance') return end
   926    926   end
   927    927   
   928    928   local json = {}
   929    929   
   930         -terra json.webfinger(co: &lib.srv.convo)
   931         -	
          930  +do wftpl = lib.tpl.mk [[{
          931  +		"subject": @$subj,
          932  +		"links": [
          933  +			{ "rel": "self", "type": "application/ld+json", "href": @$href }
          934  +		]
          935  +	}]]
          936  +	terra json.webfinger(co: &lib.srv.convo)
          937  +		var res = co:pgetv('resource')
          938  +		if (not res) or not res:startswith 'acct:' then goto err end
          939  +		
          940  +		-- technically we should look this user up in the database to make sure
          941  +		-- they actually exist, buuut that's costly and i doubt that's actually
          942  +		-- necessary for webfinger to do its job. so we cheat and just do string
          943  +		-- munging so lookups are as cheap as possible. TODO make sure this works
          944  +		-- in practice and doesn't cause any weird security problems
          945  +		var acct = res + 5
          946  +		var svp = lib.str.find(acct, '@')
          947  +		if svp:ref() then
          948  +			acct.ct = (svp.ptr - acct.ptr)
          949  +			svp:advance(1)
          950  +			if not svp:cmp(co.srv.cfg.domain) then goto err end
          951  +		end
          952  +		var tp = wftpl {
          953  +			subj = res;
          954  +			href = co:qstr('https://', co.srv.cfg.domain, '/@', acct);
          955  +		}
          956  +		co:json(tp:poolstr(&co.srv.pool))
          957  +
          958  +		do return end -- error conditions
          959  +		::err:: do co:json('{}') return end
          960  +	end
   932    961   end
   933    962   
   934    963   -- entry points
   935    964   terra r.dispatch_http(co: &lib.srv.convo, uri: lib.mem.ptr(int8), meth: method.t)
   936    965   	lib.dbg('handling URI of form ', {uri.ptr,uri.ct})
   937    966   	co.navbar = lib.render.nav(co)
   938    967   	-- some routes are non-hierarchical, and can be resolved with a simple strcmp