Skip to content
Snippets Groups Projects
Unverified Commit 44174127 authored by CGsama's avatar CGsama Committed by GitHub
Browse files

Export notes with file detail (#11293)

parent 96cde67b
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,8 @@ import { bindThis } from '@/decorators.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
import type * as Bull from 'bullmq';
import type { DbJobDataWithUser } from '../types.js';
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
import { Packed } from '@/misc/json-schema.js';
@Injectable()
export class ExportNotesProcessorService {
......@@ -34,6 +36,8 @@ export class ExportNotesProcessorService {
private driveService: DriveService,
private queueLoggerService: QueueLoggerService,
private driveFileEntityService: DriveFileEntityService,
) {
this.logger = this.queueLoggerService.logger.createSubLogger('export-notes');
}
......@@ -97,7 +101,8 @@ export class ExportNotesProcessorService {
if (note.hasPoll) {
poll = await this.pollsRepository.findOneByOrFail({ noteId: note.id });
}
const content = JSON.stringify(serialize(note, poll));
const files = await this.driveFileEntityService.packManyByIds(note.fileIds);
const content = JSON.stringify(serialize(note, poll, files));
const isFirst = exportedNotesCount === 0;
await write(isFirst ? content : ',\n' + content);
exportedNotesCount++;
......@@ -125,12 +130,13 @@ export class ExportNotesProcessorService {
}
}
function serialize(note: Note, poll: Poll | null = null): Record<string, unknown> {
function serialize(note: Note, poll: Poll | null = null, files: Map<Packed<'DriveFile'>['id'], Packed<'DriveFile'>>): Record<string, unknown> {
return {
id: note.id,
text: note.text,
createdAt: note.createdAt,
fileIds: note.fileIds,
files: files,
replyId: note.replyId,
renoteId: note.renoteId,
poll: poll,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment