mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-01 18:50:40 +01:00
Export notes with file detail (#11293)
This commit is contained in:
parent
96cde67b2c
commit
4417412787
1 changed files with 8 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue