diff --git a/src/schemas.ts b/src/schemas.ts index e79d8a8..a438efe 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -7,7 +7,8 @@ export const ActorInfoSchema = Type.Object({ actorUrl: Type.String(), publicKeyId: Type.String(), keypair: KeyPairSchema, - announce: Type.Boolean({ default: false }) + announce: Type.Optional(Type.Boolean({ default: false })), + manuallyApprovesFollowers: Type.Optional(Type.Boolean({ default: false })) }) export type ActorInfo = Static diff --git a/src/server/announcements.ts b/src/server/announcements.ts index 3430496..1dd0cdc 100644 --- a/src/server/announcements.ts +++ b/src/server/announcements.ts @@ -51,7 +51,6 @@ export class Announcements { outbox: `${actorInfo.actorUrl}outbox`, publicKey: { id: `${actorInfo.actorUrl}#main-key`, - owner: actorInfo.actorUrl, publicKeyPem: actorInfo.keypair.publicKeyPem } @@ -79,7 +78,8 @@ export class Announcements { privateKeyPem, publicKeyPem }, - announce: false + announce: false, + manuallyApprovesFollowers: false }) } } @@ -123,10 +123,10 @@ export class Announcements { const actor = this.store const activities = await actor.outbox.list() const orderedItems = activities - // XXX: maybe `new Date()` doesn't correctly parse possible dates? + .filter(a => a.type !== 'Note') + // XXX: maybe `new Date()` doesn't correctly parse possible dates? .map(a => ({ ...a, published: typeof a.published === 'string' ? new Date(a.published) : a.published })) .sort((a, b) => +(b.published ?? 0) - +(a.published ?? 0)) - .filter(a => a.type !== 'Note') .map(a => a.id) .filter((id): id is string => id !== undefined) diff --git a/src/server/apsystem.ts b/src/server/apsystem.ts index 5eb45e3..d4f90c5 100644 --- a/src/server/apsystem.ts +++ b/src/server/apsystem.ts @@ -342,9 +342,13 @@ export default class ActivityPubSystem { const actorStore = this.store.forActor(fromActor) + const { manuallyApprovesFollowers } = await actorStore.getInfo() + await actorStore.inbox.add(activity) - if (activityType === 'Undo') { + if (activityType === 'Follow' && (manuallyApprovesFollowers !== true)) { + await this.approveActivity(fromActor, activityId) + } else if (activityType === 'Undo') { await this.performUndo(fromActor, activity) } else if (moderationState === BLOCKED) { // TODO: Notify of blocks?