mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: tests, save actor URL into userRemote hash
This commit is contained in:
@@ -25,7 +25,7 @@ Mocks.profile = async (actors) => {
|
||||
|
||||
const uid = actor.id;
|
||||
let {
|
||||
preferredUsername, published, icon, image,
|
||||
url, preferredUsername, published, icon, image,
|
||||
name, summary, followerCount, followingCount,
|
||||
postcount, inbox, endpoints,
|
||||
} = actor;
|
||||
@@ -59,6 +59,7 @@ Mocks.profile = async (actors) => {
|
||||
followerCount,
|
||||
followingCount,
|
||||
|
||||
url,
|
||||
inbox,
|
||||
sharedInbox: endpoints ? endpoints.sharedInbox : null,
|
||||
};
|
||||
|
||||
@@ -185,7 +185,7 @@ async function assertRelation(post) {
|
||||
// Local user is mentioned
|
||||
const { tag } = post._activitypub;
|
||||
let uids = [];
|
||||
if (tag.length) {
|
||||
if (tag && tag.length) {
|
||||
const slugs = tag.reduce((slugs, tag) => {
|
||||
if (tag.type === 'Mention') {
|
||||
const [slug, hostname] = tag.name.slice(1).split('@');
|
||||
|
||||
@@ -477,6 +477,7 @@ describe('ActivityPub integration', () => {
|
||||
|
||||
activitypub._cache.set(`0;${id}`, remoteNote);
|
||||
activitypub._cache.set(`0;https://example.org/user/foobar`, remoteUser);
|
||||
await db.sortedSetAdd(`followersRemote:${remoteUser.id}`, Date.now(), 1); // fake a follow
|
||||
await controllers.activitypub.postInbox({
|
||||
body: {
|
||||
type: 'Create',
|
||||
@@ -561,4 +562,48 @@ describe('ActivityPub integration', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Actor asserton', () => {
|
||||
let uid;
|
||||
let actorUri;
|
||||
|
||||
before(async () => {
|
||||
uid = utils.generateUUID().slice(0, 8);
|
||||
actorUri = `https://example.org/user/${uid}`;
|
||||
activitypub._cache.set(`0;${actorUri}`, {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: actorUri,
|
||||
url: actorUri,
|
||||
|
||||
type: 'Person',
|
||||
name: 'example',
|
||||
preferredUsername: 'example',
|
||||
|
||||
publicKey: {
|
||||
id: `${actorUri}#key`,
|
||||
owner: actorUri,
|
||||
publicKeyPem: 'somekey',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should return true if successfully asserted', async () => {
|
||||
const result = await activitypub.actors.assert([actorUri]);
|
||||
assert(result);
|
||||
});
|
||||
|
||||
it('should contain a representation of that remote user in the database', async () => {
|
||||
const exists = await db.exists(`userRemote:${actorUri}`);
|
||||
assert(exists);
|
||||
|
||||
const userData = await user.getUserData(actorUri);
|
||||
assert(userData);
|
||||
assert.strictEqual(userData.uid, actorUri);
|
||||
});
|
||||
|
||||
it('should save the actor\'s publicly accessible URL in the hash as well', async () => {
|
||||
const url = await user.getUserField(actorUri, 'url');
|
||||
assert.strictEqual(url, actorUri);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user