Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(backend): inbox queue error in update note #389

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/backend/src/core/activitypub/ApInboxService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
if (isActor(object)) {
await this.apPersonService.updatePerson(actor.uri, resolver, object);
return 'ok: Person updated';
} /*else if (getApType(object) === 'Question') {

Check failure on line 797 in packages/backend/src/core/activitypub/ApInboxService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Closing curly brace does not appear on the same line as the subsequent block
await this.apQuestionService.updateQuestion(object, resolver).catch(err => console.error(err));
return 'ok: Question updated';
}*/ else if (getApType(object) === 'Note' || getApType(object) === 'Question') {
Expand Down Expand Up @@ -824,9 +824,9 @@
const unlock = await this.appLockService.getApLock(uri);

try {
//const exist = await this.apNoteService.fetchNote(note);
//if (exist) return 'skip: note exists';
await this.apNoteService.updateNote(note, resolver, silent);
const target = await this.notesRepository.findOneBy({uri: uri});

Check failure on line 827 in packages/backend/src/core/activitypub/ApInboxService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

A space is required after '{'

Check failure on line 827 in packages/backend/src/core/activitypub/ApInboxService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

A space is required before '}'
if (!target) return `skip: target note not located: ${uri}`;
await this.apNoteService.updateNote(note, target, resolver, silent);
return 'ok';
} catch (err) {
if (err instanceof StatusError && err.isClientError) {
Expand Down
11 changes: 2 additions & 9 deletions packages/backend/src/core/activitypub/models/ApNoteService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class ApNoteService {
}

@bindThis
public async updateNote(value: string | IObject, resolver?: Resolver, silent = false): Promise<MiNote | null> {
public async updateNote(value: string | IObject, target: MiNote, resolver?: Resolver, silent = false): Promise<MiNote | null> {
if (resolver == null) resolver = this.apResolverService.createResolver();

const object = await resolver.resolve(value);
Expand Down Expand Up @@ -370,13 +370,6 @@ export class ApNoteService {
throw new Error('actor has been suspended');
}

const b_note = await this.notesRepository.findOneBy({
uri: entryUri
}).then(x => {
if (x == null) throw new Error('note not found');
return x;
});

const limit = promiseLimit<MiDriveFile>(2);
const files = (await Promise.all(toArray(note.attachment).map(attach => (
limit(() => this.apImageService.resolveImage(actor, {
Expand Down Expand Up @@ -418,7 +411,7 @@ export class ApNoteService {
apHashtags,
apEmojis,
poll,
}, b_note, silent);
}, target, silent);
} catch (err: any) {
this.logger.warn(`note update failed: ${err}`);
return err;
Expand Down
Loading