Add actor URL redirection to /@username when Accepts text/html
This commit is contained in:
parent
83e34a6dd4
commit
7e0abcbc17
|
@ -0,0 +1,18 @@
|
|||
module.exports = {
|
||||
init: () => {
|
||||
apex.net.actor.get.unshift(async (req, res, next) => {
|
||||
if (req.accepts('text/html')) {
|
||||
const actor = req.params[apex.actorParam]
|
||||
const actorIRI = apex.utils.usernameToIRI(actor)
|
||||
let actorObj
|
||||
try {
|
||||
actorObj = await apex.store.getObject(actorIRI)
|
||||
if (actorObj !== null &&
|
||||
actorObj.preferredUsername !== undefined)
|
||||
return res.redirect(`/@${actorObj.preferredUsername[0]}`)
|
||||
} catch (err) {}
|
||||
}
|
||||
next()
|
||||
})
|
||||
},
|
||||
}
|
|
@ -7,5 +7,6 @@ global.replaceImpl = (funcs, name, withFunc) => {
|
|||
module.exports = {
|
||||
rewriteImplementations: () => {
|
||||
require('./well-known.js').init()
|
||||
require('./actor.js').init()
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue