mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
fix: re-enable logging only for dev mode
This commit is contained in:
@@ -48,7 +48,7 @@ ActivityPub.actors = require('./actors');
|
||||
ActivityPub.instances = require('./instances');
|
||||
|
||||
ActivityPub.startJobs = () => {
|
||||
// winston.verbose('[activitypub/jobs] Registering jobs.');
|
||||
ActivityPub.helpers.log('[activitypub/jobs] Registering jobs.');
|
||||
new CronJob('0 0 * * *', async () => {
|
||||
try {
|
||||
await ActivityPub.notes.prune();
|
||||
@@ -188,9 +188,9 @@ ActivityPub.sign = async ({ key, keyId }, url, payload) => {
|
||||
};
|
||||
|
||||
ActivityPub.verify = async (req) => {
|
||||
// winston.verbose('[activitypub/verify] Starting signature verification...');
|
||||
ActivityPub.helpers.log('[activitypub/verify] Starting signature verification...');
|
||||
if (!req.headers.hasOwnProperty('signature')) {
|
||||
// winston.verbose('[activitypub/verify] Failed, no signature header.');
|
||||
ActivityPub.helpers.log('[activitypub/verify] Failed, no signature header.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,17 +238,17 @@ ActivityPub.verify = async (req) => {
|
||||
// Verify the signature string via public key
|
||||
try {
|
||||
// Retrieve public key from remote instance
|
||||
// winston.verbose(`[activitypub/verify] Retrieving pubkey for ${keyId}`);
|
||||
ActivityPub.helpers.log(`[activitypub/verify] Retrieving pubkey for ${keyId}`);
|
||||
const { publicKeyPem } = await ActivityPub.fetchPublicKey(keyId);
|
||||
|
||||
const verify = createVerify('sha256');
|
||||
verify.update(signed_string);
|
||||
verify.end();
|
||||
// winston.verbose('[activitypub/verify] Attempting signed string verification');
|
||||
ActivityPub.helpers.log('[activitypub/verify] Attempting signed string verification');
|
||||
const verified = verify.verify(publicKeyPem, signature, 'base64');
|
||||
return verified;
|
||||
} catch (e) {
|
||||
// winston.verbose('[activitypub/verify] Failed, key retrieval or verification failure.');
|
||||
ActivityPub.helpers.log('[activitypub/verify] Failed, key retrieval or verification failure.');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -266,7 +266,7 @@ ActivityPub.get = async (type, id, uri, options) => {
|
||||
|
||||
const keyData = await ActivityPub.getPrivateKey(type, id);
|
||||
const headers = id >= 0 ? await ActivityPub.sign(keyData, uri) : {};
|
||||
// winston.verbose(`[activitypub/get] ${uri}`);
|
||||
ActivityPub.helpers.log(`[activitypub/get] ${uri}`);
|
||||
try {
|
||||
const { response, body } = await request.get(uri, {
|
||||
headers: {
|
||||
@@ -313,7 +313,7 @@ pubsub.on(`activitypub-retry-queue:lruCache:del`, (keys) => {
|
||||
async function sendMessage(uri, id, type, payload, attempts = 1) {
|
||||
const keyData = await ActivityPub.getPrivateKey(type, id);
|
||||
const headers = await ActivityPub.sign(keyData, uri, payload);
|
||||
// winston.verbose(`[activitypub/send] ${uri}`);
|
||||
ActivityPub.helpers.log(`[activitypub/send] ${uri}`);
|
||||
try {
|
||||
const { response, body } = await request.post(uri, {
|
||||
headers: {
|
||||
@@ -324,7 +324,7 @@ async function sendMessage(uri, id, type, payload, attempts = 1) {
|
||||
});
|
||||
|
||||
if (String(response.statusCode).startsWith('2')) {
|
||||
// winston.verbose(`[activitypub/send] Successfully sent ${payload.type} to ${uri}`);
|
||||
ActivityPub.helpers.log(`[activitypub/send] Successfully sent ${payload.type} to ${uri}`);
|
||||
} else {
|
||||
throw new Error(String(body));
|
||||
}
|
||||
@@ -337,7 +337,7 @@ async function sendMessage(uri, id, type, payload, attempts = 1) {
|
||||
const timeoutId = setTimeout(() => sendMessage(uri, id, type, payload, attempts + 1), timeout);
|
||||
ActivityPub.retryQueue.set(queueId, timeoutId);
|
||||
|
||||
// winston.verbose(`[activitypub/send] Added ${payload.type} to ${uri} to retry queue for ${timeout}ms`);
|
||||
ActivityPub.helpers.log(`[activitypub/send] Added ${payload.type} to ${uri} to retry queue for ${timeout}ms`);
|
||||
} else {
|
||||
winston.warn(`[activitypub/send] Max attempts reached for ${payload.type} to ${uri}; giving up on sending`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user