summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2025-05-30 20:45:55 +0000
committerdakkar <dakkar@thenautilus.net>2025-05-30 20:45:55 +0000
commit993bd03134076fe6b3d1a769293fbf6f58e01186 (patch)
treec36f942ba577ef369b2211d8d165fc5bf127c5fe
parentmerge: Add web optimization for video files during processing (!1054) (diff)
parentblock remote interactions with local-only posts (diff)
downloadsharkey-993bd03134076fe6b3d1a769293fbf6f58e01186.tar.gz
sharkey-993bd03134076fe6b3d1a769293fbf6f58e01186.tar.bz2
sharkey-993bd03134076fe6b3d1a769293fbf6f58e01186.zip
merge: Block remote interactions with local-only posts (resolves #972) (!1070)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1070 Closes #972 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
-rw-r--r--packages/backend/src/core/activitypub/ApInboxService.ts8
-rw-r--r--packages/backend/src/core/activitypub/models/ApNoteService.ts11
2 files changed, 19 insertions, 0 deletions
diff --git a/packages/backend/src/core/activitypub/ApInboxService.ts b/packages/backend/src/core/activitypub/ApInboxService.ts
index b8526a972c..92c91f47de 100644
--- a/packages/backend/src/core/activitypub/ApInboxService.ts
+++ b/packages/backend/src/core/activitypub/ApInboxService.ts
@@ -217,6 +217,10 @@ export class ApInboxService {
const note = await this.apNoteService.resolveNote(object, { resolver });
if (!note) return `skip: target note not found ${targetUri}`;
+ if (note.userHost == null && note.localOnly) {
+ throw new IdentifiableError('12e23cec-edd9-442b-aa48-9c21f0c3b215', 'Cannot react to local-only note');
+ }
+
await this.apNoteService.extractEmojis(activity.tag ?? [], actor.host).catch(() => null);
try {
@@ -371,6 +375,10 @@ export class ApInboxService {
return 'skip: invalid actor for this activity';
}
+ if (renote.userHost == null && renote.localOnly) {
+ throw new IdentifiableError('12e23cec-edd9-442b-aa48-9c21f0c3b215', 'Cannot renote a local-only note');
+ }
+
this.logger.info(`Creating the (Re)Note: ${uri}`);
const activityAudience = await this.apAudienceService.parseAudience(actor, activity.to, activity.cc, resolver);
diff --git a/packages/backend/src/core/activitypub/models/ApNoteService.ts b/packages/backend/src/core/activitypub/models/ApNoteService.ts
index 7811b81795..5b66031bee 100644
--- a/packages/backend/src/core/activitypub/models/ApNoteService.ts
+++ b/packages/backend/src/core/activitypub/models/ApNoteService.ts
@@ -285,6 +285,13 @@ export class ApNoteService {
const quote = await this.getQuote(note, entryUri, resolver);
const processErrors = quote === null ? ['quoteUnavailable'] : null;
+ if (reply && reply.userHost == null && reply.localOnly) {
+ throw new IdentifiableError('12e23cec-edd9-442b-aa48-9c21f0c3b215', 'Cannot reply to local-only note');
+ }
+ if (quote && quote.userHost == null && quote.localOnly) {
+ throw new IdentifiableError('12e23cec-edd9-442b-aa48-9c21f0c3b215', 'Cannot quote a local-only note');
+ }
+
// vote
if (reply && reply.hasPoll) {
const poll = await this.pollsRepository.findOneByOrFail({ noteId: reply.id });
@@ -482,6 +489,10 @@ export class ApNoteService {
const quote = await this.getQuote(note, entryUri, resolver);
const processErrors = quote === null ? ['quoteUnavailable'] : null;
+ if (quote && quote.userHost == null && quote.localOnly) {
+ throw new IdentifiableError('12e23cec-edd9-442b-aa48-9c21f0c3b215', 'Cannot quote a local-only note');
+ }
+
// vote
if (reply && reply.hasPoll) {
const poll = await this.pollsRepository.findOneByOrFail({ noteId: reply.id });