mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-11 01:52:55 +01:00
refactor: comment out verbose logs
This commit is contained in:
@@ -68,14 +68,14 @@ Actors.assert = async (ids, options = {}) => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
winston.verbose(`[activitypub/actors] Asserting ${ids.length} actor(s)`);
|
// winston.verbose(`[activitypub/actors] Asserting ${ids.length} actor(s)`);
|
||||||
|
|
||||||
const urlMap = new Map();
|
const urlMap = new Map();
|
||||||
const followersUrlMap = new Map();
|
const followersUrlMap = new Map();
|
||||||
const pubKeysMap = new Map();
|
const pubKeysMap = new Map();
|
||||||
let actors = await Promise.all(ids.map(async (id) => {
|
let actors = await Promise.all(ids.map(async (id) => {
|
||||||
try {
|
try {
|
||||||
winston.verbose(`[activitypub/actors] Processing ${id}`);
|
// winston.verbose(`[activitypub/actors] Processing ${id}`);
|
||||||
const actor = (typeof id === 'object' && id.hasOwnProperty('id')) ? id : await activitypub.get('uid', 0, id);
|
const actor = (typeof id === 'object' && id.hasOwnProperty('id')) ? id : await activitypub.get('uid', 0, id);
|
||||||
|
|
||||||
// Follow counts
|
// Follow counts
|
||||||
@@ -88,7 +88,7 @@ Actors.assert = async (ids, options = {}) => {
|
|||||||
actor.followingCount = following.totalItems;
|
actor.followingCount = following.totalItems;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// no action required
|
// no action required
|
||||||
winston.verbose(`[activitypub/actor.assert] Unable to retrieve follower counts for ${actor.id}`);
|
// winston.verbose(`[activitypub/actor.assert] Unable to retrieve follower counts for ${actor.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post count
|
// Post count
|
||||||
@@ -97,7 +97,7 @@ Actors.assert = async (ids, options = {}) => {
|
|||||||
actor.postcount = outbox.totalItems;
|
actor.postcount = outbox.totalItems;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// no action required
|
// no action required
|
||||||
winston.verbose(`[activitypub/actor.assert] Unable to retrieve post counts for ${actor.id}`);
|
// winston.verbose(`[activitypub/actor.assert] Unable to retrieve post counts for ${actor.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save url for backreference
|
// Save url for backreference
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ Helpers.query = async (id) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Helpers.generateKeys = async (type, id) => {
|
Helpers.generateKeys = async (type, id) => {
|
||||||
winston.verbose(`[activitypub] Generating RSA key-pair for ${type} ${id}`);
|
// winston.verbose(`[activitypub] Generating RSA key-pair for ${type} ${id}`);
|
||||||
const {
|
const {
|
||||||
publicKey,
|
publicKey,
|
||||||
privateKey,
|
privateKey,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ inbox.create = async (req) => {
|
|||||||
|
|
||||||
const response = await activitypub.notes.assert(0, object);
|
const response = await activitypub.notes.assert(0, object);
|
||||||
if (response) {
|
if (response) {
|
||||||
winston.verbose(`[activitypub/inbox] Parsing ${response.count} notes into topic ${response.tid}`);
|
// winston.verbose(`[activitypub/inbox] Parsing ${response.count} notes into topic ${response.tid}`);
|
||||||
|
|
||||||
// todo: put this somewhere better if need be... maybe this is better as api.activitypub.announce.note?
|
// todo: put this somewhere better if need be... maybe this is better as api.activitypub.announce.note?
|
||||||
const cid = await topics.getTopicField(response.tid, 'cid');
|
const cid = await topics.getTopicField(response.tid, 'cid');
|
||||||
@@ -153,7 +153,7 @@ inbox.delete = async (req) => {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
winston.verbose(`[activitypub/inbox.delete] Object (${object}) does not exist locally. Doing nothing.`);
|
// winston.verbose(`[activitypub/inbox.delete] Object (${object}) does not exist locally. Doing nothing.`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,7 +440,7 @@ inbox.undo = async (req) => {
|
|||||||
id = id || object.object; // remote announces
|
id = id || object.object; // remote announces
|
||||||
const exists = await posts.exists(id);
|
const exists = await posts.exists(id);
|
||||||
if (!exists) {
|
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.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await activitypub.notes.announce.remove(id, actor);
|
await activitypub.notes.announce.remove(id, actor);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ ActivityPub.notes = require('./notes');
|
|||||||
ActivityPub.actors = require('./actors');
|
ActivityPub.actors = require('./actors');
|
||||||
|
|
||||||
ActivityPub.startJobs = () => {
|
ActivityPub.startJobs = () => {
|
||||||
winston.verbose('[activitypub/jobs] Registering jobs.');
|
// winston.verbose('[activitypub/jobs] Registering jobs.');
|
||||||
new CronJob('0 0 * * *', ActivityPub.notes.prune, null, true, null, null, false); // change last argument to true for debugging
|
new CronJob('0 0 * * *', ActivityPub.notes.prune, null, true, null, null, false); // change last argument to true for debugging
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,9 +165,9 @@ ActivityPub.sign = async ({ key, keyId }, url, payload) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ActivityPub.verify = async (req) => {
|
ActivityPub.verify = async (req) => {
|
||||||
winston.verbose('[activitypub/verify] Starting signature verification...');
|
// winston.verbose('[activitypub/verify] Starting signature verification...');
|
||||||
if (!req.headers.hasOwnProperty('signature')) {
|
if (!req.headers.hasOwnProperty('signature')) {
|
||||||
winston.verbose('[activitypub/verify] Failed, no signature header.');
|
// winston.verbose('[activitypub/verify] Failed, no signature header.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,17 +215,17 @@ ActivityPub.verify = async (req) => {
|
|||||||
// Verify the signature string via public key
|
// Verify the signature string via public key
|
||||||
try {
|
try {
|
||||||
// Retrieve public key from remote instance
|
// Retrieve public key from remote instance
|
||||||
winston.verbose(`[activitypub/verify] Retrieving pubkey for ${keyId}`);
|
// winston.verbose(`[activitypub/verify] Retrieving pubkey for ${keyId}`);
|
||||||
const { publicKeyPem } = await ActivityPub.fetchPublicKey(keyId);
|
const { publicKeyPem } = await ActivityPub.fetchPublicKey(keyId);
|
||||||
|
|
||||||
const verify = createVerify('sha256');
|
const verify = createVerify('sha256');
|
||||||
verify.update(signed_string);
|
verify.update(signed_string);
|
||||||
verify.end();
|
verify.end();
|
||||||
winston.verbose('[activitypub/verify] Attempting signed string verification');
|
// winston.verbose('[activitypub/verify] Attempting signed string verification');
|
||||||
const verified = verify.verify(publicKeyPem, signature, 'base64');
|
const verified = verify.verify(publicKeyPem, signature, 'base64');
|
||||||
return verified;
|
return verified;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
winston.verbose('[activitypub/verify] Failed, key retrieval or verification failure.');
|
// winston.verbose('[activitypub/verify] Failed, key retrieval or verification failure.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -239,7 +239,7 @@ ActivityPub.get = async (type, id, uri) => {
|
|||||||
|
|
||||||
const keyData = await ActivityPub.getPrivateKey(type, id);
|
const keyData = await ActivityPub.getPrivateKey(type, id);
|
||||||
const headers = id >= 0 ? await ActivityPub.sign(keyData, uri) : {};
|
const headers = id >= 0 ? await ActivityPub.sign(keyData, uri) : {};
|
||||||
winston.verbose(`[activitypub/get] ${uri}`);
|
// winston.verbose(`[activitypub/get] ${uri}`);
|
||||||
try {
|
try {
|
||||||
const { response, body } = await request.get(uri, {
|
const { response, body } = await request.get(uri, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -278,7 +278,7 @@ pubsub.on(`activitypub-retry-queue:lruCache:del`, (keys) => {
|
|||||||
async function sendMessage(uri, id, type, payload, attempts = 1) {
|
async function sendMessage(uri, id, type, payload, attempts = 1) {
|
||||||
const keyData = await ActivityPub.getPrivateKey(type, id);
|
const keyData = await ActivityPub.getPrivateKey(type, id);
|
||||||
const headers = await ActivityPub.sign(keyData, uri, payload);
|
const headers = await ActivityPub.sign(keyData, uri, payload);
|
||||||
winston.verbose(`[activitypub/send] ${uri}`);
|
// winston.verbose(`[activitypub/send] ${uri}`);
|
||||||
try {
|
try {
|
||||||
const { response, body } = await request.post(uri, {
|
const { response, body } = await request.post(uri, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -289,7 +289,7 @@ async function sendMessage(uri, id, type, payload, attempts = 1) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (String(response.statusCode).startsWith('2')) {
|
if (String(response.statusCode).startsWith('2')) {
|
||||||
winston.verbose(`[activitypub/send] Successfully sent ${payload.type} to ${uri}`);
|
// winston.verbose(`[activitypub/send] Successfully sent ${payload.type} to ${uri}`);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(String(body));
|
throw new Error(String(body));
|
||||||
}
|
}
|
||||||
@@ -302,7 +302,7 @@ async function sendMessage(uri, id, type, payload, attempts = 1) {
|
|||||||
const timeoutId = setTimeout(() => sendMessage(uri, id, type, payload, attempts + 1), timeout);
|
const timeoutId = setTimeout(() => sendMessage(uri, id, type, payload, attempts + 1), timeout);
|
||||||
ActivityPub.retryQueue.set(queueId, timeoutId);
|
ActivityPub.retryQueue.set(queueId, timeoutId);
|
||||||
|
|
||||||
winston.verbose(`[activitypub/send] Added ${payload.type} to ${uri} to retry queue for ${timeout}ms`);
|
// winston.verbose(`[activitypub/send] Added ${payload.type} to ${uri} to retry queue for ${timeout}ms`);
|
||||||
} else {
|
} else {
|
||||||
winston.warn(`[activitypub/send] Max attempts reached for ${payload.type} to ${uri}; giving up on sending`);
|
winston.warn(`[activitypub/send] Max attempts reached for ${payload.type} to ${uri}; giving up on sending`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
members.push(await posts.exists(mainPid));
|
members.push(await posts.exists(mainPid));
|
||||||
if (tid && members.every(Boolean)) {
|
if (tid && members.every(Boolean)) {
|
||||||
// All cached, return early.
|
// All cached, return early.
|
||||||
winston.verbose('[notes/assert] No new notes to process.');
|
// winston.verbose('[notes/assert] No new notes to process.');
|
||||||
unlock(id);
|
unlock(id);
|
||||||
return { tid, count: 0 };
|
return { tid, count: 0 };
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
return post;
|
return post;
|
||||||
}).filter((p, idx) => !members[idx]);
|
}).filter((p, idx) => !members[idx]);
|
||||||
const count = unprocessed.length;
|
const count = unprocessed.length;
|
||||||
winston.verbose(`[notes/assert] ${count} new note(s) found.`);
|
// winston.verbose(`[notes/assert] ${count} new note(s) found.`);
|
||||||
|
|
||||||
const [ids, timestamps] = [
|
const [ids, timestamps] = [
|
||||||
unprocessed.map(n => (utils.isNumber(n.pid) ? parseInt(n.pid, 10) : n.pid)),
|
unprocessed.map(n => (utils.isNumber(n.pid) ? parseInt(n.pid, 10) : n.pid)),
|
||||||
@@ -299,7 +299,7 @@ Notes.syncUserInboxes = async function (tid, uid) {
|
|||||||
const keys = Array.from(uids).map(uid => `uid:${uid}:inbox`);
|
const keys = Array.from(uids).map(uid => `uid:${uid}:inbox`);
|
||||||
const score = await db.sortedSetScore(`cid:${cid}:tids`, tid);
|
const score = await db.sortedSetScore(`cid:${cid}:tids`, tid);
|
||||||
|
|
||||||
winston.verbose(`[activitypub/syncUserInboxes] Syncing tid ${tid} with ${uids.size} inboxes`);
|
// winston.verbose(`[activitypub/syncUserInboxes] Syncing tid ${tid} with ${uids.size} inboxes`);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
db.sortedSetsAdd(keys, keys.map(() => score || Date.now()), tid),
|
db.sortedSetsAdd(keys, keys.map(() => score || Date.now()), tid),
|
||||||
db.setAdd(`tid:${tid}:recipients`, Array.from(uids)),
|
db.setAdd(`tid:${tid}:recipients`, Array.from(uids)),
|
||||||
@@ -381,12 +381,12 @@ Notes.prune = async () => {
|
|||||||
* - Replied to (contains a local reply)
|
* - Replied to (contains a local reply)
|
||||||
* - Post within is liked
|
* - Post within is liked
|
||||||
*/
|
*/
|
||||||
winston.verbose('[notes/prune] Starting scheduled pruning of topics');
|
// winston.verbose('[notes/prune] Starting scheduled pruning of topics');
|
||||||
const start = 0;
|
const start = 0;
|
||||||
const stop = Date.now() - (1000 * 60 * 60 * 24 * 30); // 30 days; todo: make configurable?
|
const stop = Date.now() - (1000 * 60 * 60 * 24 * 30); // 30 days; todo: make configurable?
|
||||||
let tids = await db.getSortedSetRangeByScore('cid:-1:tids', 0, -1, start, stop);
|
let tids = await db.getSortedSetRangeByScore('cid:-1:tids', 0, -1, start, stop);
|
||||||
|
|
||||||
winston.verbose(`[notes/prune] Found ${tids.length} topics older than 30 days (since last activity).`);
|
// winston.verbose(`[notes/prune] Found ${tids.length} topics older than 30 days (since last activity).`);
|
||||||
|
|
||||||
const posters = await db.getSortedSetsMembers(tids.map(tid => `tid:${tid}:posters`));
|
const posters = await db.getSortedSetsMembers(tids.map(tid => `tid:${tid}:posters`));
|
||||||
const hasLocalVoter = await Promise.all(tids.map(async (tid) => {
|
const hasLocalVoter = await Promise.all(tids.map(async (tid) => {
|
||||||
@@ -412,7 +412,7 @@ Notes.prune = async () => {
|
|||||||
return !localPoster && !localVoter;
|
return !localPoster && !localVoter;
|
||||||
});
|
});
|
||||||
|
|
||||||
winston.verbose(`[notes/prune] ${tids.length} topics eligible for pruning`);
|
// winston.verbose(`[notes/prune] ${tids.length} topics eligible for pruning`);
|
||||||
|
|
||||||
await batch.processArray(tids, async (tids) => {
|
await batch.processArray(tids, async (tids) => {
|
||||||
await Promise.all(tids.map(async (tid) => {
|
await Promise.all(tids.map(async (tid) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user