mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
fix: better logic for choosing webfinger lookups
This commit is contained in:
@@ -31,8 +31,9 @@ Actors.assert = async (ids, options = {}) => {
|
|||||||
// Translate webfinger handles to uris
|
// Translate webfinger handles to uris
|
||||||
ids = (await Promise.all(ids.map(async (id) => {
|
ids = (await Promise.all(ids.map(async (id) => {
|
||||||
const originalId = id;
|
const originalId = id;
|
||||||
if (id.includes('@')) {
|
const isUri = activitypub.helpers.isUri(id);
|
||||||
const isUri = activitypub.helpers.isUri(id);
|
// only look up webfinger if the id is not a supported URI
|
||||||
|
if (id.includes('@') && !(isUri && activitypub._constants.acceptedProtocols.includes(new URL(id).protocol.slice(0, -1)))) {
|
||||||
const host = isUri ? new URL(id).host : id.split('@')[1];
|
const host = isUri ? new URL(id).host : id.split('@')[1];
|
||||||
if (host === nconf.get('url_parsed').host) { // do not assert loopback ids
|
if (host === nconf.get('url_parsed').host) { // do not assert loopback ids
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -22,15 +22,10 @@ Helpers.isUri = (value) => {
|
|||||||
value = String(value);
|
value = String(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const protocols = ['https'];
|
|
||||||
if (process.env.CI === 'true') {
|
|
||||||
protocols.push('http');
|
|
||||||
}
|
|
||||||
|
|
||||||
return validator.isURL(value, {
|
return validator.isURL(value, {
|
||||||
require_protocol: true,
|
require_protocol: true,
|
||||||
require_host: true,
|
require_host: true,
|
||||||
protocols,
|
protocols: activitypub._constants.acceptedProtocols,
|
||||||
require_valid_protocol: true,
|
require_valid_protocol: true,
|
||||||
require_tld: false, // temporary — for localhost
|
require_tld: false, // temporary — for localhost
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ ActivityPub._constants = Object.freeze({
|
|||||||
acceptedPostTypes: [
|
acceptedPostTypes: [
|
||||||
'Note', 'Page', 'Article', 'Question',
|
'Note', 'Page', 'Article', 'Question',
|
||||||
],
|
],
|
||||||
|
acceptedProtocols: ['https', ...(process.env.CI === 'true' ? ['http'] : [])],
|
||||||
});
|
});
|
||||||
ActivityPub._cache = requestCache;
|
ActivityPub._cache = requestCache;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user