Skip to content

Commit

Permalink
check actor
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid committed Dec 28, 2024
1 parent 7c5db4b commit e7ba414
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/backend/src/core/activitypub/models/ApNoteService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ export class ApNoteService {
return new IdentifiableError('d450b8a9-48e4-4dab-ae36-f4db763fda7c', 'invalid Note: published timestamp is malformed');
}

if (actor) {
const attribution = (object.attributedTo) ? getOneApId(object.attributedTo) : actor.uri;
if (actor?.uri) {
if (object.id && !this.utilityService.isRelatedUris(object.id, actor.uri)) {
return new IdentifiableError('d450b8a9-48e4-4dab-ae36-f4db763fda7c', `invalid Note: id has unrelated host to actor. actor: ${actor.uri}, id: ${object.id}`);
}

if (attribution !== actor.uri) {
return new IdentifiableError('d450b8a9-48e4-4dab-ae36-f4db763fda7c', `invalid Note: attribution does not match the actor that send it. attribution: ${attribution}, actor: ${actor.uri}`);
const attributedTo = object.attributedTo && getOneApId(object.attributedTo);
if (attributedTo && !this.utilityService.isRelatedUris(attributedTo, actor.uri)) {
return new IdentifiableError('d450b8a9-48e4-4dab-ae36-f4db763fda7c', `invalid Note: attributedTo has unrelated host to actor. actor: ${actor.uri}, attributedTo: ${attributedTo}`);
}
}

Expand Down

0 comments on commit e7ba414

Please sign in to comment.