From a4b497c2a959c4008ec027b9e3ebf6904c9fa607 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Feb 2024 15:46:38 +0100 Subject: [PATCH] Add postingRestrictedToMods to channels AP objects See https://github.com/LemmyNet/lemmy/issues/3837 --- packages/models/src/activitypub/activitypub-actor.ts | 3 +++ server/core/helpers/activity-pub-utils.ts | 3 +++ server/core/models/video/video-channel.ts | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/models/src/activitypub/activitypub-actor.ts b/packages/models/src/activitypub/activitypub-actor.ts index 6340de287..d3d4aefde 100644 --- a/packages/models/src/activitypub/activitypub-actor.ts +++ b/packages/models/src/activitypub/activitypub-actor.ts @@ -27,6 +27,9 @@ export interface ActivityPubActor { publicKeyPem: string } + // Lemmy attribute for groups + postingRestrictedToMods?: boolean + image?: ActivityIconObject | ActivityIconObject[] icon?: ActivityIconObject | ActivityIconObject[] diff --git a/server/core/helpers/activity-pub-utils.ts b/server/core/helpers/activity-pub-utils.ts index 7ea701d34..fdbd36d4a 100644 --- a/server/core/helpers/activity-pub-utils.ts +++ b/server/core/helpers/activity-pub-utils.ts @@ -192,6 +192,9 @@ const contextStore: { [ id in ContextType ]: (string | { [ id: string ]: string '@id': 'pt:support' }, + lemmy: 'https://join-lemmy.org/ns#', + postingRestrictedToMods: 'lemmy:postingRestrictedToMods', + // TODO: remove in a few versions, introduced in 4.2 icons: 'as:icon' }), diff --git a/server/core/models/video/video-channel.ts b/server/core/models/video/video-channel.ts index 115e80b68..3b8795d07 100644 --- a/server/core/models/video/video-channel.ts +++ b/server/core/models/video/video-channel.ts @@ -825,16 +825,19 @@ export class VideoChannelModel extends SequelizeModel { async toActivityPubObject (this: MChannelAP): Promise { const obj = await this.Actor.toActivityPubObject(this.name) - return Object.assign(obj, { + return { + ...obj, + summary: this.description, support: this.support, + postingRestrictedToMods: true, attributedTo: [ { type: 'Person' as 'Person', id: this.Account.Actor.url } ] - }) + } } // Avoid error when running this method on MAccount... | MChannel...