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