Refactor ap_id to apID + improve method using apex.domain

This commit is contained in:
Niko 2022-02-15 23:26:07 +01:00
parent 5d9e931c6f
commit ebaa58cb82
2 changed files with 4 additions and 7 deletions

View File

@ -55,7 +55,7 @@ module.exports = {
return res.status(403).json({ error: 'email_already_exists' })
// TODO: when implementing email confirmation, move this actor creation when confirmed
var actor = await apex.store.getObject(ap_id(req.body.username))
var actor = await apex.store.getObject(apID(req.body.username))
if (actor === null)
actor = await apex.createActor(req.body.username, req.body.username, '', null)

View File

@ -21,10 +21,8 @@ const routes = {
shares: '/s/:id/shares',
likes: '/s/:id/likes'
}
global.ap_id = (username) => {
return `https://${process.env.DOMAIN}` +
routes.actor.replace(':actor', username)
}
global.apID = (username) => { return `https://${apex.domain}`+
routes.actor.replace(':actor', username) }
global.db = require('./db.js')
global.apex = ActivitypubExpress({
name: 'FediLove ActivityPub API',
@ -70,7 +68,6 @@ app.route(api.url('/auth/register')).post(api.auth.register.post)
app.route(api.url('/auth/login')).post(api.auth.login.post)
app.route(api.url('/feed/meet')).get(api.feed.meet.get)
// initialize
client.connect({ useNewUrlParser: true })
.then(() => {
@ -78,7 +75,7 @@ client.connect({ useNewUrlParser: true })
return apex.store.setup()
})
.then(async () => {
const sysActor = await apex.store.getObject(ap_id('fedilove'), true)
const sysActor = await apex.store.getObject(apID('fedilove'), true)
if (sysActor === null) {
apex.createActor('fedilove', 'FediLove', '', null, 'Service')
.then(async (actor) => {