Skip to content

Commit 99ca6df

Browse files
committed
fix: do not persist capabilities sent to outbox but send them
1 parent 3d73ebd commit 99ca6df

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • src/middleware/packages/activitypub/services/activitypub/subservices

src/middleware/packages/activitypub/services/activitypub/subservices/outbox.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,24 @@ const OutboxService = {
9696
webId: actorUri
9797
});
9898

99+
// -- Persist Capability --
100+
// There might be a capability attached which should not be persisted
101+
// because other's could otherwise read it from the (public) outbox.
102+
let { capability, ...activityToPersist } = activity;
103+
99104
activityUri = await ctx.call('activitypub.activity.post', {
100105
containerUri: activitiesContainerUri,
101-
resource: activity,
106+
resource: activityToPersist,
102107
contentType: MIME_TYPES.JSON,
103108
webId: 'system' // Post as system since there is no write permission to the activities container
104109
});
105110

106-
activity = await ctx.call('activitypub.activity.get', { resourceUri: activityUri, webId: 'system' });
111+
// Refetch because persisting has side-effects.
112+
// And reattach capability for further processing (if present).
113+
activity = {
114+
...(await ctx.call('activitypub.activity.get', { resourceUri: activityUri, webId: 'system' })),
115+
capability
116+
};
107117
}
108118

109119
try {

0 commit comments

Comments
 (0)