mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: convert some more verbose logging to use ap logging helper
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const winston = require('winston');
|
|
||||||
|
|
||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const posts = require('../posts');
|
const posts = require('../posts');
|
||||||
const topics = require('../topics');
|
const topics = require('../topics');
|
||||||
@@ -31,17 +29,17 @@ Contexts.get = async (uid, id) => {
|
|||||||
try {
|
try {
|
||||||
({ context } = await activitypub.get('uid', uid, id, { headers }));
|
({ context } = await activitypub.get('uid', uid, id, { headers }));
|
||||||
if (!context) {
|
if (!context) {
|
||||||
winston.verbose(`[activitypub/context] ${id} contains no context.`);
|
activitypub.helpers.log(`[activitypub/context] ${id} contains no context.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
({ type } = await activitypub.get('uid', uid, context));
|
({ type } = await activitypub.get('uid', uid, context));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code === 'ap_get_304') {
|
if (e.code === 'ap_get_304') {
|
||||||
winston.verbose(`[activitypub/context] ${id} context unchanged.`);
|
activitypub.helpers.log(`[activitypub/context] ${id} context unchanged.`);
|
||||||
return { tid };
|
return { tid };
|
||||||
}
|
}
|
||||||
|
|
||||||
winston.verbose(`[activitypub/context] ${id} context not resolvable.`);
|
activitypub.helpers.log(`[activitypub/context] ${id} context not resolvable.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +55,7 @@ Contexts.getItems = async (uid, id, options) => {
|
|||||||
options.root = true;
|
options.root = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
winston.verbose(`[activitypub/context] Retrieving context ${id}`);
|
activitypub.helpers.log(`[activitypub/context] Retrieving context ${id}`);
|
||||||
let { type, items, orderedItems, first, next } = await activitypub.get('uid', uid, id);
|
let { type, items, orderedItems, first, next } = await activitypub.get('uid', uid, id);
|
||||||
if (!acceptableTypes.includes(type)) {
|
if (!acceptableTypes.includes(type)) {
|
||||||
return [];
|
return [];
|
||||||
@@ -71,7 +69,7 @@ Contexts.getItems = async (uid, id, options) => {
|
|||||||
items = await Promise.all(items
|
items = await Promise.all(items
|
||||||
.map(async item => (activitypub.helpers.isUri(item) ? parseString(uid, item) : parseItem(uid, item))));
|
.map(async item => (activitypub.helpers.isUri(item) ? parseString(uid, item) : parseItem(uid, item))));
|
||||||
items = items.filter(Boolean);
|
items = items.filter(Boolean);
|
||||||
winston.verbose(`[activitypub/context] Found ${items.length} items.`);
|
activitypub.helpers.log(`[activitypub/context] Found ${items.length} items.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const chain = new Set(items || []);
|
const chain = new Set(items || []);
|
||||||
@@ -85,7 +83,7 @@ Contexts.getItems = async (uid, id, options) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (next) {
|
if (next) {
|
||||||
winston.verbose('[activitypub/context] Fetching next page...');
|
activitypub.helpers.log('[activitypub/context] Fetching next page...');
|
||||||
Array
|
Array
|
||||||
.from(await Contexts.getItems(uid, next, {
|
.from(await Contexts.getItems(uid, next, {
|
||||||
...options,
|
...options,
|
||||||
@@ -120,12 +118,12 @@ async function parseString(uid, item) {
|
|||||||
// No local copy, fetch from source
|
// No local copy, fetch from source
|
||||||
try {
|
try {
|
||||||
const object = await activitypub.get('uid', uid, pid);
|
const object = await activitypub.get('uid', uid, pid);
|
||||||
winston.verbose(`[activitypub/context] Retrieved ${pid}`);
|
activitypub.helpers.log(`[activitypub/context] Retrieved ${pid}`);
|
||||||
|
|
||||||
return parseItem(uid, object);
|
return parseItem(uid, object);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Unresolvable, either temporarily or permanent, ignore for now.
|
// Unresolvable, either temporarily or permanent, ignore for now.
|
||||||
winston.verbose(`[activitypub/context] Cannot retrieve ${pid}`);
|
activitypub.helpers.log(`[activitypub/context] Cannot retrieve ${pid}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,6 +148,6 @@ async function parseItem(uid, item) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
winston.verbose(`[activitypub/context] Parsing ${pid}`);
|
activitypub.helpers.log(`[activitypub/context] Parsing ${pid}`);
|
||||||
return await activitypub.mocks.post(item);
|
return await activitypub.mocks.post(item);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user