refactor: move all methods in src/api/activitypub.js to src/activitypub.out.js

This commit is contained in:
Julian Lam
2025-10-22 12:51:50 -04:00
parent bb34b8c7a3
commit 3ede64d8a1
18 changed files with 364 additions and 451 deletions

View File

@@ -2,6 +2,7 @@
const categories = require('../../categories');
const meta = require('../../meta');
const activitypub = require('../../activitypub');
const api = require('../../api');
const helpers = require('../helpers');
@@ -107,6 +108,7 @@ Categories.setModerator = async (req, res) => {
};
Categories.follow = async (req, res, next) => {
// Priv check done in route middleware
const { actor } = req.body;
const id = parseInt(req.params.cid, 10);
@@ -114,11 +116,7 @@ Categories.follow = async (req, res, next) => {
return next();
}
await api.activitypub.follow(req, {
type: 'cid',
id,
actor,
});
await activitypub.out.follow('cid', id, actor);
helpers.formatApiResponse(200, res, {});
};
@@ -131,11 +129,6 @@ Categories.unfollow = async (req, res, next) => {
return next();
}
await api.activitypub.unfollow(req, {
type: 'cid',
id,
actor,
});
await activitypub.out.undo.follow('cid', id, actor);
helpers.formatApiResponse(200, res, {});
};

View File

@@ -5,6 +5,7 @@ const path = require('path');
const crypto = require('crypto');
const api = require('../../api');
const activitypub = require('../../activitypub');
const user = require('../../user');
const helpers = require('../helpers');
@@ -94,11 +95,7 @@ Users.changePassword = async (req, res) => {
Users.follow = async (req, res) => {
const remote = String(req.params.uid).includes('@');
if (remote) {
await api.activitypub.follow(req, {
type: 'uid',
id: req.uid,
actor: req.params.uid,
});
await activitypub.out.follow('uid', req.uid, req.params.uid);
} else {
await api.users.follow(req, req.params);
}
@@ -109,11 +106,7 @@ Users.follow = async (req, res) => {
Users.unfollow = async (req, res) => {
const remote = String(req.params.uid).includes('@');
if (remote) {
await api.activitypub.unfollow(req, {
type: 'uid',
id: req.uid,
actor: req.params.uid,
});
await activitypub.out.undo.follow('uid', req.uid, req.params.uid);
} else {
await api.users.unfollow(req, req.params);
}