fix: drive content not being loaded

This commit is contained in:
Marie 2024-11-03 03:39:19 +01:00
parent 2528508cff
commit 4f58b8de20
No known key found for this signature in database
GPG key ID: 7ADF6C9CD9A28555
7 changed files with 13 additions and 35 deletions

View file

@ -6,7 +6,7 @@
import ms from 'ms';
import { In } from 'typeorm';
import { Inject, Injectable } from '@nestjs/common';
import { isPureRenote } from 'cherrypick-js/note.js';
import { isPureRenote } from '@/misc/is-renote.js';
import type { MiUser } from '@/models/User.js';
import type {
UsersRepository,
@ -19,7 +19,6 @@ import type {
import type { MiDriveFile } from '@/models/DriveFile.js';
import type { MiNote } from '@/models/Note.js';
import type { MiChannel } from '@/models/Channel.js';
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js';
import { QueueService } from '@/core/QueueService.js';
@ -129,7 +128,6 @@ export const paramDef = {
} },
cw: { type: 'string', nullable: true, minLength: 1, maxLength: 100 },
reactionAcceptance: { type: 'string', nullable: true, enum: [null, 'likeOnly', 'likeOnlyForRemote', 'nonSensitiveOnly', 'nonSensitiveOnlyForLocalLikeOnlyForRemote'], default: null },
disableRightClick: { type: 'boolean', default: false },
noExtractMentions: { type: 'boolean', default: false },
noExtractHashtags: { type: 'boolean', default: false },
noExtractEmojis: { type: 'boolean', default: false },
@ -141,7 +139,6 @@ export const paramDef = {
text: {
type: 'string',
minLength: 1,
maxLength: MAX_NOTE_TEXT_LENGTH,
nullable: true,
},
fileIds: {
@ -175,16 +172,6 @@ export const paramDef = {
},
required: ['choices'],
},
event: {
type: 'object',
nullable: true,
properties: {
title: { type: 'string', minLength: 1, maxLength: 128, nullable: false },
start: { type: 'integer', nullable: false },
end: { type: 'integer', nullable: true },
metadata: { type: 'object' },
},
},
scheduleNote: {
type: 'object',
nullable: false,
@ -227,11 +214,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private queueService: QueueService,
private roleService: RoleService,
private idService: IdService,
private idService: IdService,
) {
super({
...meta,
}, paramDef, async (ps, me) => {
super(meta, paramDef, async (ps, me) => {
const scheduleNoteCount = await this.noteScheduleRepository.countBy({ userId: me.id });
const scheduleNoteMax = (await this.roleService.getUserPolicies(me.id)).scheduleNoteMax;
if (scheduleNoteCount >= scheduleNoteMax) {
@ -358,13 +343,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
apMentions: ps.noExtractMentions ? [] : undefined,
apHashtags: ps.noExtractHashtags ? [] : undefined,
apEmojis: ps.noExtractEmojis ? [] : undefined,
event: ps.event ? {
start: new Date(ps.event.start!).toISOString(),
end: ps.event.end ? new Date(ps.event.end).toISOString() : null,
title: ps.event.title!,
metadata: ps.event.metadata ?? {},
} : undefined,
disableRightClick: ps.disableRightClick,
};
if (ps.scheduleNote.scheduledAt) {

View file

@ -9,6 +9,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js';
import type { MiNote, MiNoteSchedule, NoteScheduleRepository } from '@/models/_.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
import { QueryService } from '@/core/QueryService.js';
import { Packed } from '@/misc/json-schema.js';
import { noteVisibilities } from '@/types.js';
@ -81,6 +82,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private noteScheduleRepository: NoteScheduleRepository,
private userEntityService: UserEntityService,
private driveFileEntityService: DriveFileEntityService,
private queryService: QueryService,
) {
super(meta, paramDef, async (ps, me) => {
@ -115,6 +117,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
reactionAcceptance: item.note.reactionAcceptance ?? null,
visibleUsers: item.note.visibleUsers ? await userEntityService.packMany(item.note.visibleUsers.map(u => u.id), me) : [],
fileIds: item.note.files ? item.note.files : [],
files: await this.driveFileEntityService.packManyByIds(item.note.files),
createdAt: item.scheduledAt.toISOString(),
isSchedule: true,
id: item.id,