Node.js based forum software built for the modern web
refactor: remove verbose logs,
Barış Soner Uşaklı2ae58570053d
diff --git a/src/activitypub/actors.js b/src/activitypub/actors.jsindex 46f4d382e1..aa093802dd 100644--- a/src/activitypub/actors.js+++ b/src/activitypub/actors.js@@ -1,6 +1,5 @@'use strict';-const winston = require('winston');const nconf = require('nconf');const db = require('../database');@@ -22,7 +21,9 @@ Actors.assert = async (ids, options = {}) => {if (!Array.isArray(ids)) {ids = [ids];}-+ if (!ids.length) {+ return false;+ }// Existance in failure cache is automatic assertion failureif (ids.some(id => failedWebfingerCache.has(id))) {return false;diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.jsindex bc1d37f50b..5eb51077b8 100644--- a/src/activitypub/helpers.js+++ b/src/activitypub/helpers.js@@ -1,7 +1,6 @@'use strict';const { generateKeyPairSync } = require('crypto');-const winston = require('winston');const nconf = require('nconf');const validator = require('validator');const cheerio = require('cheerio');@@ -15,7 +14,7 @@ const ttl = require('../cache/ttl');const user = require('../user');const activitypub = require('.');-const webfingerRegex = /^(@|acct:)?[\w\-]+@.+$/;+const webfingerRegex = /^(@|acct:)?[\w-]+@.+$/;const webfingerCache = ttl({max: 5000,ttl: 1000 * 60 * 60 * 24, // 24 hoursdiff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.jsindex b47fdfeab7..7d7172d082 100644--- a/src/activitypub/inbox.js+++ b/src/activitypub/inbox.js@@ -440,7 +440,10 @@ inbox.undo = async (req) => {id = id || object.object; // remote announcesconst exists = await posts.exists(id);if (!exists) {- // winston.verbose(`[activitypub/inbox/undo] Attempted to undo announce of ${id} but couldn't find it, so doing nothing.`);+ // winston.verbose(+ // `[activitypub/inbox/undo] Attempted to undo announce of ${id} but couldn't find it, so doing nothing.+ // `);+ break;}await activitypub.notes.announce.remove(id, actor);diff --git a/src/api/activitypub.js b/src/api/activitypub.jsindex cf06c7a3fe..df374635e1 100644--- a/src/api/activitypub.js+++ b/src/api/activitypub.js@@ -9,7 +9,7 @@*/const nconf = require('nconf');-const winston = require('winston');+// const winston = require('winston');const db = require('../database');const user = require('../user');@@ -135,7 +135,7 @@ activitypubApi.create.note = enabledCheck(async (caller, { pid }) => {const allowed = await privileges.posts.can('topics:read', pid, activitypub._constants.uid);if (!allowed) {- winston.verbose(`[activitypub/api] Not federating creation of pid ${pid} to the fediverse due to privileges.`);+ // winston.verbose(`[activitypub/api] Not federating creation of pid ${pid} to the fediverse due to privileges.`);return;}@@ -195,7 +195,9 @@ activitypubApi.update.note = enabledCheck(async (caller, { post }) => {const allowed = await privileges.posts.can('topics:read', post.pid, activitypub._constants.uid);if (!allowed) {- winston.verbose(`[activitypub/api] Not federating update of pid ${post.pid} to the fediverse due to privileges.`);+ // winston.verbose(+ // `[activitypub/api] Not federating update of pid ${post.pid} to the fediverse due to privileges.`+ // );return;}@@ -225,7 +227,7 @@ activitypubApi.delete.note = enabledCheck(async (caller, { pid }) => {const allowed = await privileges.posts.can('topics:read', pid, activitypub._constants.uid);if (!allowed) {- winston.verbose(`[activitypub/api] Not federating update of pid ${pid} to the fediverse due to privileges.`);+ // winston.verbose(`[activitypub/api] Not federating update of pid ${pid} to the fediverse due to privileges.`);return;}diff --git a/src/middleware/activitypub.js b/src/middleware/activitypub.jsindex aa8c0c9e26..6f29993707 100644--- a/src/middleware/activitypub.js+++ b/src/middleware/activitypub.js@@ -31,30 +31,30 @@ middleware.assertS2S = async function (req, res, next) {};middleware.validate = async function (req, res, next) {- winston.verbose('[middleware/activitypub] Validating incoming payload...');+ // winston.verbose('[middleware/activitypub] Validating incoming payload...');// Sanity-check payload schemaconst required = ['id', 'type', 'actor', 'object'];if (!required.every(prop => req.body.hasOwnProperty(prop))) {- winston.verbose('[middleware/activitypub] Request body missing required properties.');+ // winston.verbose('[middleware/activitypub] Request body missing required properties.');return res.sendStatus(400);}- winston.verbose('[middleware/activitypub] Request body check passed.');+ // winston.verbose('[middleware/activitypub] Request body check passed.');// History checkconst seen = await db.isSortedSetMember('activities:datetime', req.body.id);if (seen) {- winston.verbose(`[middleware/activitypub] Activity already seen, ignoring (${req.body.id}).`);+ // winston.verbose(`[middleware/activitypub] Activity already seen, ignoring (${req.body.id}).`);return res.sendStatus(200);}// Checks the validity of the incoming payload against the sender and rejects on failureconst verified = await activitypub.verify(req);if (!verified) {- winston.verbose('[middleware/activitypub] HTTP signature verification failed.');+ // winston.verbose('[middleware/activitypub] HTTP signature verification failed.');return res.sendStatus(400);}- winston.verbose('[middleware/activitypub] HTTP signature verification passed.');+ // winston.verbose('[middleware/activitypub] HTTP signature verification passed.');let { actor, object } = req.body;@@ -74,10 +74,10 @@ middleware.validate = async function (req, res, next) {const objectHostname = new URL(object.id).hostname;// require that all actors have the same hostname as the object for nowif (!actorHostnames.every(actorHostname => actorHostname === objectHostname)) {- winston.verbose('[middleware/activitypub] Origin check failed, stripping object down to id.');+ // winston.verbose('[middleware/activitypub] Origin check failed, stripping object down to id.');req.body.object = [object.id];}- winston.verbose('[middleware/activitypub] Origin check passed.');+ // winston.verbose('[middleware/activitypub] Origin check passed.');}// Cross-check key ownership against received actor@@ -89,10 +89,10 @@ middleware.validate = async function (req, res, next) {return [v.substring(0, index), v.slice(index + 1)];})).get('keyId');if (`"${compare}"` !== keyId) {- winston.verbose('[middleware/activitypub] Key ownership cross-check failed.');+ // winston.verbose('[middleware/activitypub] Key ownership cross-check failed.');return res.sendStatus(403);}- winston.verbose('[middleware/activitypub] Key ownership cross-check passed.');+ // winston.verbose('[middleware/activitypub] Key ownership cross-check passed.');next();};@@ -100,12 +100,12 @@ middleware.validate = async function (req, res, next) {middleware.resolveObjects = async function (req, res, next) {const { type, object } = req.body;if (type !== 'Delete' && (typeof object === 'string' || (Array.isArray(object) && object.every(o => typeof o === 'string')))) {- winston.verbose('[middleware/activitypub] Resolving object(s)...');+ // winston.verbose('[middleware/activitypub] Resolving object(s)...');try {req.body.object = await activitypub.helpers.resolveObjects(object);- winston.verbose('[middleware/activitypub] Object(s) successfully resolved.');+ // winston.verbose('[middleware/activitypub] Object(s) successfully resolved.');} catch (e) {- winston.verbose('[middleware/activitypub] Failed to resolve object(s).');+ // winston.verbose('[middleware/activitypub] Failed to resolve object(s).');return res.sendStatus(424);}}diff --git a/src/posts/attachments.js b/src/posts/attachments.jsindex 8a5ab822ee..5f48f12d2b 100644--- a/src/posts/attachments.js+++ b/src/posts/attachments.js@@ -1,6 +1,5 @@'use strict';-const winston = require('winston');const crypto = require('crypto');const db = require('../database');@@ -52,7 +51,6 @@ Attachments.update = async (pid, attachments) => {};Attachments.empty = async (pids) => {- winston.verbose(`[posts/attachments] Emptying attachments for ids ${pids.join(', ')}.`);const zsets = pids.map(pid => `post:${pid}:attachments`);const hashes = await db.getSortedSetsMembers(zsets);let keys = hashes.reduce((memo, hashes) => new Set([...memo, ...hashes]), new Set());