summaryrefslogtreecommitdiff
path: root/src/queue/processors/db/export-notes.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2021-05-08 18:56:21 +0900
committerGitHub <noreply@github.com>2021-05-08 18:56:21 +0900
commit591a5c277cdf197f043e5b24743dbdb346e65c4f (patch)
treeb84126eec671a7a1f1172b472cd9143060357f00 /src/queue/processors/db/export-notes.ts
parentCreate get-index-stats.ts (diff)
downloadsharkey-591a5c277cdf197f043e5b24743dbdb346e65c4f.tar.gz
sharkey-591a5c277cdf197f043e5b24743dbdb346e65c4f.tar.bz2
sharkey-591a5c277cdf197f043e5b24743dbdb346e65c4f.zip
Add queue types (#7504)
Diffstat (limited to 'src/queue/processors/db/export-notes.ts')
-rw-r--r--src/queue/processors/db/export-notes.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/queue/processors/db/export-notes.ts b/src/queue/processors/db/export-notes.ts
index f76a47aacd..2d09c0d201 100644
--- a/src/queue/processors/db/export-notes.ts
+++ b/src/queue/processors/db/export-notes.ts
@@ -9,10 +9,11 @@ import { Users, Notes, Polls } from '../../../models';
import { MoreThan } from 'typeorm';
import { Note } from '../../../models/entities/note';
import { Poll } from '../../../models/entities/poll';
+import { DbUserJobData } from '@/queue/types';
const logger = queueLogger.createSubLogger('export-notes');
-export async function exportNotes(job: Bull.Job, done: any): Promise<void> {
+export async function exportNotes(job: Bull.Job<DbUserJobData>, done: any): Promise<void> {
logger.info(`Exporting notes of ${job.data.user.id} ...`);
const user = await Users.findOne(job.data.user.id);
@@ -33,7 +34,7 @@ export async function exportNotes(job: Bull.Job, done: any): Promise<void> {
const stream = fs.createWriteStream(path, { flags: 'a' });
- await new Promise((res, rej) => {
+ await new Promise<void>((res, rej) => {
stream.write('[', err => {
if (err) {
logger.error(err);
@@ -72,7 +73,7 @@ export async function exportNotes(job: Bull.Job, done: any): Promise<void> {
poll = await Polls.findOneOrFail({ noteId: note.id });
}
const content = JSON.stringify(serialize(note, poll));
- await new Promise((res, rej) => {
+ await new Promise<void>((res, rej) => {
stream.write(exportedNotesCount === 0 ? content : ',\n' + content, err => {
if (err) {
logger.error(err);
@@ -92,7 +93,7 @@ export async function exportNotes(job: Bull.Job, done: any): Promise<void> {
job.progress(exportedNotesCount / total);
}
- await new Promise((res, rej) => {
+ await new Promise<void>((res, rej) => {
stream.write(']', err => {
if (err) {
logger.error(err);