fix: tests

This commit is contained in:
Julian Lam
2024-03-12 12:03:16 -04:00
parent 01f7af9291
commit 4b2495b5aa
3 changed files with 19 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ inbox.create = async (req) => {
}
const tid = await activitypub.notes.assertTopic(0, object.id);
winston.info(`[activitypub/inbox] Parsing note ${object.id} into topic ${tid}`);
winston.verbose(`[activitypub/inbox] Parsing note ${object.id} into topic ${tid}`);
};
inbox.update = async (req) => {
@@ -47,7 +47,7 @@ inbox.update = async (req) => {
privileges.posts.can('posts:edit', object.id, activitypub._constants.uid),
]);
if (!exists || !allowed) {
winston.info(`[activitypub/inbox.update] ${object.id} not allowed to be edited.`);
winston.warn(`[activitypub/inbox.update] ${object.id} not allowed to be edited.`);
return activitypub.send('uid', 0, actor, {
type: 'Reject',
object: {
@@ -62,7 +62,7 @@ inbox.update = async (req) => {
if (postData) {
await activitypub.notes.assert(0, [postData], { update: true });
winston.info(`[activitypub/inbox.update] Updating note ${postData.pid}`);
winston.verbose(`[activitypub/inbox.update] Updating note ${postData.pid}`);
} else {
winston.warn(`[activitypub/inbox.update] Received note did not parse properly (id: ${object.id})`);
}

View File

@@ -82,7 +82,7 @@ module.exports = function (Topics) {
const { uid } = data;
const [categoryExists, canCreate, canTag, isAdmin] = await Promise.all([
categories.exists(data.cid),
parseInt(data.cid, 10) > 0 ? categories.exists(data.cid) : true,
privileges.categories.can('topics:create', data.cid, uid),
privileges.categories.can('topics:tag', data.cid, uid),
privileges.users.isAdministrator(uid),

View File

@@ -455,6 +455,20 @@ describe('ActivityPub integration', () => {
mediaType: 'text/markdown',
},
};
const remoteUser = {
'@context': 'https://www.w3.org/ns/activitystreams',
id: 'https://example.org/user/foobar',
url: 'https://example.org/user/foobar',
type: 'Person',
name: 'Foo Bar',
preferredUsername: 'foobar',
publicKey: {
id: 'https://example.org/user/foobar#key',
owner: 'https://example.org/user/foobar',
publicKeyPem: 'publickey',
},
};
let topic;
@@ -462,6 +476,7 @@ describe('ActivityPub integration', () => {
const controllers = require('../src/controllers');
activitypub._cache.set(`0;${id}`, remoteNote);
activitypub._cache.set(`0;https://example.org/user/foobar`, remoteUser);
await controllers.activitypub.postInbox({
body: {
type: 'Create',