From 5db5bbd1cd25f83640d4dd01de14e7774d9370db Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 5 Feb 2019 19:50:14 +0900 Subject: 自分の投稿情報をエクスポートできるように (#4144) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * wip * 正しいJSONを生成するように * データを整形 --- src/queue/index.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/queue/index.ts') diff --git a/src/queue/index.ts b/src/queue/index.ts index 65c52d864c..cf8af17a48 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -1,9 +1,9 @@ import * as Queue from 'bee-queue'; import config from '../config'; -import http from './processors/http'; + import { ILocalUser } from '../models/user'; -import Logger from '../misc/logger'; import { program } from '../argv'; +import handler from './processors'; const enableQueue = config.redis != null && !program.disableQueue; @@ -36,7 +36,7 @@ export function createHttpJob(data: any) { .backoff('exponential', 16384) // 16s .save(); } else { - return http({ data }, () => {}); + return handler({ data }, () => {}); } } @@ -51,10 +51,18 @@ export function deliver(user: ILocalUser, content: any, to: any) { }); } -export const queueLogger = new Logger('queue'); +export function createExportNotesJob(user: ILocalUser) { + if (!enableQueue) throw 'queue disabled'; + + return queue.createJob({ + type: 'exportNotes', + user: user + }) + .save(); +} export default function() { if (enableQueue) { - queue.process(128, http); + queue.process(128, handler); } } -- cgit v1.2.3-freya