From 79640d686104a301abe40b20519375350699f971 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 7 May 2018 18:20:15 +0900 Subject: [PATCH] Fix bug --- src/queue/index.ts | 3 ++- src/queue/processors/http/deliver.ts | 1 + src/services/note/create.ts | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/queue/index.ts b/src/queue/index.ts index 32fd043f7..3f82b30b3 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -2,6 +2,7 @@ import { createQueue } from 'kue'; import config from '../config'; import http from './processors/http'; +import { ILocalUser } from '../models/user'; const queue = createQueue({ redis: { @@ -20,7 +21,7 @@ export function createHttp(data) { .backoff({ delay: 16384, type: 'exponential' }); } -export function deliver(user, content, to) { +export function deliver(user: ILocalUser, content, to) { createHttp({ title: 'deliver', type: 'deliver', diff --git a/src/queue/processors/http/deliver.ts b/src/queue/processors/http/deliver.ts index cf843fad0..0a228c187 100644 --- a/src/queue/processors/http/deliver.ts +++ b/src/queue/processors/http/deliver.ts @@ -7,6 +7,7 @@ export default async (job: kue.Job, done): Promise => { await request(job.data.user, job.data.to, job.data.content); done(); } catch (res) { + if (res.statusCode == null) return done(); if (res.statusCode >= 400 && res.statusCode < 500) { // HTTPステータスコード4xxはクライアントエラーであり、それはつまり // 何回再送しても成功することはないということなのでエラーにはしないでおく diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 634c2e263..9320889c2 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -295,9 +295,11 @@ export default async (user: IUser, data: { nm.push(u._id, 'mention'); }); - mentionedUsers.filter(u => isRemoteUser(u)).forEach(async u => { - deliver(user, await render(), (u as IRemoteUser).inbox); - }); + if (isLocalUser(user)) { + mentionedUsers.filter(u => isRemoteUser(u)).forEach(async u => { + deliver(user, await render(), (u as IRemoteUser).inbox); + }); + } // Append mentions data if (mentionedUsers.length > 0) {