mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: tests
This commit is contained in:
@@ -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})`);
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user