'Built-in blocks are registered from the compiled block manifest, so the list reflects what is actually installed.',
'Built-in blocks are registered from the compiled block manifest, so the list reflects what is actually installed. This is what the editor builds its block picker from, so it is available to page authors and to anyone an approval rule lets suggest an edit — guests included, where a site takes public suggestions — as well as to site administrators.',
tags:['Blocks'],
params:{
type:'object',
@ -42,6 +97,9 @@ async function routes(app: FastifyInstance) {
if(!site){
returnreply.notFound('Site does not exist.')
}
if(!(awaitmayListBlocks(req,req.params.siteId))){
returnreply.forbidden('You are not allowed to list the blocks of this site.')
'The site for the hostname, the system flags, and the current session — the same answers `sites/{hostname}`, `system/flags` and `users/whoami` give, in one request.\n\nCarries the session, so it is never cached.',
tags:['System'],
querystring:{
type:'object',
properties:{
hostname:{
type:'string',
maxLength: 255,
description:"The host the browser is on. The request's own hostname when absent."
}
}
},
response:{
200:{
description:'Site, flags and session',
type:'object',
properties:{
site:{$ref:'Site#'},
flags:{$ref:'SystemFlags#'},
user:{
type:'object',
description:
'As `users/whoami` answers it: `authenticated: false` alone for a guest, otherwise the account and its group-wide permissions.',
additionalProperties: true
}
}
}
}
}
},
async(req,reply)=>{
// -> The session decides part of the answer, so no shared cache may hold on to it
'Where the requester stands on this page: what they may do to it, whether they may suggest an edit, and whether they review it. Present when a page is fetched on its own — the page view draws its controls from this, rather than asking three further endpoints about a page it already has. Absent from a page returned by a save.',
properties:{
permissions:{
type:'array',
items:{type:'string'},
description:
'The page permissions held AT THIS PATH, as this reader’s groups’ rules decide. The same answer `pages/userPermissions` gives for the path.'
},
canSuggestEdits:{
type:'boolean',
description:
'An enabled approval rule covers this page and names a group the requester is in, and the page allows contributions.'
},
hasOpenSuggestion:{
type:'boolean',
description:
'The requester already has a suggestion waiting on this page, which they would carry on with rather than start again. Always false for a guest, whose suggestions are attributed to nobody.'
},
canReview:{
type:'boolean',
description:'The requester reviews this page. Always false without an account.'
},
pendingSubmissions:{
type:'array',
items:{$ref:'PageEditSubmission#'},
description:'What is waiting on this page, oldest first. Empty unless `canReview`.'
@ -120,22 +144,14 @@ async function routes(app: FastifyInstance) {
{
schema:{
summary:'Get currently logged in user info',
description:
'Includes the group-wide permissions of the session, which is what the interface hides its own controls by. Permissions ON A PAGE are a different question, answered by `pages/userPermissions`.\n\nThe app itself gets this from `bootstrap` on load, together with the site and the flags; this endpoint is what asks again once a login or a logout has changed the answer.',
tags:['Users']
}
},
async(req,reply)=>{
reply.preventCache()
if(req.session?.authenticated){
return{
authenticated: true,
...req.session.user,
permissions:['manage:system']// TODO: pull actual permissions