From ebaa58cb82dfd64209144c04ab42e9334acf36e9 Mon Sep 17 00:00:00 2001 From: Niko Date: Tue, 15 Feb 2022 23:26:07 +0100 Subject: [PATCH] Refactor ap_id to apID + improve method using apex.domain --- api/src/api/auth.js | 2 +- api/src/server.js | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/api/src/api/auth.js b/api/src/api/auth.js index 1c0081d..22357f7 100644 --- a/api/src/api/auth.js +++ b/api/src/api/auth.js @@ -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) diff --git a/api/src/server.js b/api/src/server.js index f6860f3..71331c0 100644 --- a/api/src/server.js +++ b/api/src/server.js @@ -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) => {