diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-03-10 22:27:25 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-03-10 22:27:25 +0900 |
| commit | c6cdfa2f5a0fe3b83acf25d5e27f5b6b80a3540c (patch) | |
| tree | b5589f3a0c362ae4315a892d72e467adc5376ef1 /src/remote/activitypub/models/note.ts | |
| parent | Remove debug code (diff) | |
| download | sharkey-c6cdfa2f5a0fe3b83acf25d5e27f5b6b80a3540c.tar.gz sharkey-c6cdfa2f5a0fe3b83acf25d5e27f5b6b80a3540c.tar.bz2 sharkey-c6cdfa2f5a0fe3b83acf25d5e27f5b6b80a3540c.zip | |
Ignore 4xx references in AP (#4463)
* Ignore 4xx references
* remove unnecessary comment
Diffstat (limited to 'src/remote/activitypub/models/note.ts')
| -rw-r--r-- | src/remote/activitypub/models/note.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index a87257dffc..7078eb2ce1 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -111,11 +111,22 @@ export async function createNote(value: any, resolver?: Resolver, silent = false note.attachment = Array.isArray(note.attachment) ? note.attachment : note.attachment ? [note.attachment] : []; const files = note.attachment .map(attach => attach.sensitive = note.sensitive) - ? await Promise.all(note.attachment.map(x => limit(() => resolveImage(actor, x)) as Promise<IDriveFile>)) + ? (await Promise.all(note.attachment.map(x => limit(() => resolveImage(actor, x)) as Promise<IDriveFile>))) + .filter(image => image != null) : []; // リプライ - const reply = note.inReplyTo ? await resolveNote(note.inReplyTo, resolver) : null; + const reply = note.inReplyTo + ? await resolveNote(note.inReplyTo, resolver).catch(e => { + // 4xxの場合はリプライしてないことにする + if (e.statusCode >= 400 && e.statusCode < 500) { + logger.warn(`Ignored inReplyTo ${note.inReplyTo} - ${e.statusCode} `); + return null; + } + logger.warn(`Error in inReplyTo ${note.inReplyTo} - ${e.statusCode || e}`); + throw e; + }) + : null; // 引用 let quote: INote; |