Skip to content

Node.js based forum software built for the modern web

chore: minor re-shuffling of code

Julian Lam5e693702a46f
diff --git a/src/activitypub/index.js b/src/activitypub/index.js
index a986cb2335..07b8da2d5a 100644
--- a/src/activitypub/index.js
+++ b/src/activitypub/index.js
@@ -13,7 +13,6 @@ const ActivityPub = module.exports;
ActivityPub.helpers = require('./helpers');
ActivityPub.inbox = require('./inbox');
-ActivityPub.outbox = require('./outbox');
ActivityPub.getActor = async (id) => {
if (actorCache.has(id)) {
diff --git a/src/activitypub/outbox.js b/src/activitypub/outbox.js
deleted file mode 100644
index a21ef567fd..0000000000
--- a/src/activitypub/outbox.js
+++ /dev/null
@@ -1,13 +0,0 @@
-'use strict';
-
-const db = require('../database');
-
-const outbox = module.exports;
-
-outbox.isFollowing = async (uid, actorId) => {
- if (parseInt(uid, 10) <= 0 || actorId.indexOf('@') === -1) {
- return false;
- }
- return await db.isSortedSetMember(`followingRemote:${uid}`, actorId);
-};
-
diff --git a/src/controllers/activitypub/profiles.js b/src/controllers/activitypub/profiles.js
index 3d05ce2c6f..10ca171dc9 100644
--- a/src/controllers/activitypub/profiles.js
+++ b/src/controllers/activitypub/profiles.js
@@ -1,6 +1,7 @@
'use strict';
-const { getActor, outbox } = require('../../activitypub');
+const db = require('../../database');
+const { getActor } = require('../../activitypub');
const controller = module.exports;
@@ -11,7 +12,7 @@ controller.get = async function (req, res, next) {
return next();
}
const { preferredUsername, published, icon, image, name, summary, hostname } = actor;
- const isFollowing = await outbox.isFollowing(req.uid, uid);
+ const isFollowing = await db.isSortedSetMember(`followingRemote:${req.uid}`, uid);
const payload = {
uid,
diff --git a/src/routes/activitypub.js b/src/routes/activitypub.js
index 121d085d9b..8737d7baca 100644
--- a/src/routes/activitypub.js
+++ b/src/routes/activitypub.js
@@ -5,12 +5,12 @@ module.exports = function (app, middleware, controllers) {
app.get('/user/:userslug', middlewares, controllers.activitypub.getActor);
- app.get('/user/:userslug/following', middlewares, controllers.activitypub.getFollowing);
- app.get('/user/:userslug/followers', middlewares, controllers.activitypub.getFollowers);
+ app.get('/user/:userslug/inbox', middlewares, controllers.activitypub.getInbox);
+ app.post('/user/:userslug/inbox', [...middlewares, middleware.validateActivity], controllers.activitypub.postInbox);
app.get('/user/:userslug/outbox', middlewares, controllers.activitypub.getOutbox);
app.post('/user/:userslug/outbox', middlewares, controllers.activitypub.postOutbox);
- app.get('/user/:userslug/inbox', middlewares, controllers.activitypub.getInbox);
- app.post('/user/:userslug/inbox', [...middlewares, middleware.validateActivity], controllers.activitypub.postInbox);
+ app.get('/user/:userslug/following', middlewares, controllers.activitypub.getFollowing);
+ app.get('/user/:userslug/followers', middlewares, controllers.activitypub.getFollowers);
};