mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-29 07:15:58 +02:00
refactor: split activitypub tests to subfolder files
This commit is contained in:
@@ -36,7 +36,7 @@ Actors.assert = async (ids, options = {}) => {
|
||||
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];
|
||||
if (host === nconf.get('url_parsed').host) { // do not assert loopback ids
|
||||
return null;
|
||||
return 'loopback';
|
||||
}
|
||||
|
||||
({ actorUri: id } = await activitypub.helpers.query(id));
|
||||
@@ -53,10 +53,7 @@ Actors.assert = async (ids, options = {}) => {
|
||||
}
|
||||
|
||||
// Filter out loopback uris
|
||||
ids = ids.filter((uri) => {
|
||||
const { host } = new URL(uri);
|
||||
return host !== nconf.get('url_parsed').host;
|
||||
});
|
||||
ids = ids.filter(uri => uri !== 'loopback' && new URL(uri).host !== nconf.get('url_parsed').host);
|
||||
|
||||
// Filter out existing
|
||||
if (!options.update) {
|
||||
|
||||
@@ -136,6 +136,7 @@ Helpers.resolveLocalId = async (input) => {
|
||||
|
||||
return { type: null, id: null };
|
||||
} else if (String(input).indexOf('@') !== -1) { // Webfinger
|
||||
input = decodeURIComponent(input);
|
||||
const [slug] = input.replace(/^acct:/, '').split('@');
|
||||
const uid = await user.getUidByUserslug(slug);
|
||||
return { type: 'user', id: uid };
|
||||
|
||||
@@ -228,7 +228,7 @@ Mocks.note = async (post) => {
|
||||
inReplyTo = utils.isNumber(post.topic.mainPid) ? `${nconf.get('url')}/post/${post.topic.mainPid}` : post.topic.mainPid;
|
||||
to.add(utils.isNumber(post.topic.uid) ? `${nconf.get('url')}/uid/${post.topic.uid}` : post.topic.uid);
|
||||
} else { // new topic
|
||||
name = await topics.getTitleByPid(post.pid);
|
||||
({ titleRaw: name } = await topics.getTopicFields(post.tid, ['title']));
|
||||
tag = post.topic.tags.map(tag => ({
|
||||
type: 'Hashtag',
|
||||
href: `${nconf.get('url')}/tags/${tag.valueEncoded}`,
|
||||
|
||||
Reference in New Issue
Block a user