refactor: split activitypub tests to subfolder files

This commit is contained in:
Julian Lam
2024-04-26 11:30:08 -04:00
parent 5e776088c9
commit 94eafe1df3
6 changed files with 231 additions and 196 deletions

View File

@@ -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) {

View File

@@ -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 };

View File

@@ -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}`,