mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
wip
This commit is contained in:
parent
03481322a9
commit
ab02a99a0e
2 changed files with 12 additions and 10 deletions
|
|
@ -7,7 +7,6 @@ import { Inject, Injectable } from '@nestjs/common';
|
|||
import { DataSource, In, Not } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import {
|
||||
MiPage,
|
||||
MiDriveFile,
|
||||
type UsersRepository,
|
||||
WorldRoomsRepository,
|
||||
|
|
@ -20,6 +19,11 @@ import type { MiUser } from '@/models/User.js';
|
|||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
|
||||
// TODO: やっていく
|
||||
const driveFileReferencingOptions = {
|
||||
tapestry: ['customPicture'],
|
||||
} as Record<string, string[]>;
|
||||
|
||||
@Injectable()
|
||||
export class WorldRoomService {
|
||||
constructor(
|
||||
|
|
@ -74,17 +78,15 @@ export class WorldRoomService {
|
|||
await this.worldRoomsRepository.delete(roomId);
|
||||
}
|
||||
|
||||
// TODO: engineの実装と共通化
|
||||
collectReferencedDriveFileIds(roomState: MiWorldRoom['def']): Set<MiDriveFile['id']> {
|
||||
const fileIds = new Set<MiDriveFile['id']>();
|
||||
for (const o of roomState.installedObjects) {
|
||||
const def = getObjectDef(o.type); // 家具定義をバックエンドで利用するにはcreateInstance定義を分離し、それ以外を別パッケージとして抽出する必要がありそう しかしそれ以外の定義についてもi18nされたlabelなど、バックエンドには相応しくない情報も含まれているのでどうするか
|
||||
for (const schemaRecord of Object.entries(def.options.schema)) {
|
||||
if (schemaRecord[1].type === 'file') {
|
||||
const optionValue = o.options[schemaRecord[0]];
|
||||
if (optionValue != null && optionValue !== '') {
|
||||
fileIds.add(optionValue);
|
||||
}
|
||||
const def = driveFileReferencingOptions[o.type];
|
||||
if (def == null) continue;
|
||||
for (const key of def) {
|
||||
const optionValue = o.options[key];
|
||||
if (optionValue != null && optionValue !== '') {
|
||||
fileIds.add(optionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export type RoomState = {
|
|||
worldScale: number;
|
||||
};
|
||||
|
||||
export function collectAttachmentFileIds(roomState: RoomState) {
|
||||
export function collectReferencedDriveFileIds(roomState: RoomState) {
|
||||
const fileIds = new Set<string>();
|
||||
for (const o of roomState.installedObjects) {
|
||||
const def = getObjectDef(o.type);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue