Merge branch 'develop' of https://github.com/NodeBB/NodeBB into develop

This commit is contained in:
Barış Soner Uşaklı
2025-01-20 13:18:47 -05:00
54 changed files with 115 additions and 7 deletions

View File

@@ -28,7 +28,13 @@ const sha256 = payload => crypto.createHash('sha256').update(payload).digest('he
const Helpers = module.exports;
let _lastLog;
Helpers.log = (message) => {
if (!message) {
return _lastLog;
}
_lastLog = message;
if (process.env.NODE_ENV === 'development') {
winston.verbose(message);
}

View File

@@ -263,6 +263,10 @@ ActivityPub.verify = async (req) => {
};
ActivityPub.get = async (type, id, uri, options) => {
if (!meta.config.activitypubEnabled) {
throw new Error('[[error:activitypub.not-enabled]]');
}
options = {
cache: true,
...options,
@@ -358,6 +362,10 @@ async function sendMessage(uri, id, type, payload, attempts = 1) {
}
ActivityPub.send = async (type, id, targets, payload) => {
if (!meta.config.activitypubEnabled) {
return ActivityPub.helpers.log('[activitypub/send] Federation not enabled; not sending.');
}
if (!Array.isArray(targets)) {
targets = [targets];
}

View File

@@ -3,6 +3,7 @@
const nconf = require('nconf');
const winston = require('winston');
const meta = require('../../meta');
const user = require('../../user');
const activitypub = require('../../activitypub');
const helpers = require('../helpers');
@@ -14,7 +15,7 @@ Controller.topics = require('./topics');
Controller.fetch = async (req, res, next) => {
// Given a `resource` query parameter, attempts to retrieve and parse it
if (!req.query.resource) {
if (!meta.config.activitypubEnabled || !req.query.resource) {
return next();
}

View File

@@ -98,7 +98,7 @@ apiController.loadConfig = async function (req) {
version: fontawesome_version,
},
activitypub: {
probe: meta.config.activitypubProbe,
probe: meta.config.activitypubEnabled && meta.config.activitypubProbe,
},
};