mirror of
https://git.joinfirefish.org/firefish/firefish.git
synced 2024-05-18 20:11:10 +02:00
don't change column names for now
There are so many untyped raw SQL queries and I'm afraid of breaking them reverts95883f73
1cff0364
1507ddb3
This commit is contained in:
parent
d513a6d170
commit
7a49e42bb6
|
@ -4,7 +4,6 @@ DELETE FROM "migrations" WHERE name IN (
|
|||
'UserprofileJsonbToArray1714270605574',
|
||||
'DropUnusedUserprofileColumns1714259023878',
|
||||
'AntennaJsonbToArray1714192520471',
|
||||
'RenameType1714191375157',
|
||||
'DropUnusedIndexes1714643926317',
|
||||
'AlterAkaType1714099399879',
|
||||
'AddDriveFileUsage1713451569342',
|
||||
|
@ -69,12 +68,6 @@ INSERT INTO "MZvVSjHzYcGXmGmz" ("id", "kws") SELECT "id", jsonb_agg("X"."w") FRO
|
|||
UPDATE "antenna" SET "excludeKeywords" = "kws" FROM "MZvVSjHzYcGXmGmz" WHERE "antenna"."id" = "MZvVSjHzYcGXmGmz"."id";
|
||||
ALTER TABLE "antenna" DROP COLUMN "excludeKeywords_old";
|
||||
|
||||
-- rename-type
|
||||
ALTER TABLE "drive_file" RENAME COLUMN "mimeType" TO "type";
|
||||
ALTER TABLE "emoji" RENAME COLUMN "mimeType" TO "type";
|
||||
ALTER TABLE "moderation_log" RENAME COLUMN "kind" TO "type";
|
||||
ALTER TABLE "notification" RENAME COLUMN "kind" TO "type";
|
||||
|
||||
-- drop-unused-indexes
|
||||
CREATE INDEX "IDX_01f4581f114e0ebd2bbb876f0b" ON "note_reaction" ("createdAt");
|
||||
CREATE INDEX "IDX_0610ebcfcfb4a18441a9bcdab2" ON "poll" ("userId");
|
||||
|
|
8
packages/backend-rs/index.d.ts
vendored
8
packages/backend-rs/index.d.ts
vendored
|
@ -434,7 +434,7 @@ export interface DriveFile {
|
|||
userHost: string | null
|
||||
md5: string
|
||||
name: string
|
||||
mimeType: string
|
||||
type: string
|
||||
size: number
|
||||
comment: string | null
|
||||
properties: Json
|
||||
|
@ -470,7 +470,7 @@ export interface Emoji {
|
|||
host: string | null
|
||||
originalUrl: string
|
||||
uri: string | null
|
||||
mimeType: string | null
|
||||
type: string | null
|
||||
aliases: Array<string>
|
||||
category: string | null
|
||||
publicUrl: string
|
||||
|
@ -671,7 +671,7 @@ export interface ModerationLog {
|
|||
id: string
|
||||
createdAt: Date
|
||||
userId: string
|
||||
kind: string
|
||||
type: string
|
||||
info: Json
|
||||
}
|
||||
export interface MutedNote {
|
||||
|
@ -781,7 +781,7 @@ export interface Notification {
|
|||
reaction: string | null
|
||||
choice: number | null
|
||||
followRequestId: string | null
|
||||
kind: NotificationTypeEnum
|
||||
type: NotificationTypeEnum
|
||||
userGroupInvitationId: string | null
|
||||
customBody: string | null
|
||||
customHeader: string | null
|
||||
|
|
|
@ -21,8 +21,7 @@ pub struct Model {
|
|||
pub user_host: Option<String>,
|
||||
pub md5: String,
|
||||
pub name: String,
|
||||
#[sea_orm(column_name = "mimeType")]
|
||||
pub mime_type: String,
|
||||
pub r#type: String,
|
||||
pub size: i32,
|
||||
pub comment: Option<String>,
|
||||
#[sea_orm(column_type = "JsonBinary")]
|
||||
|
|
|
@ -19,8 +19,7 @@ pub struct Model {
|
|||
#[sea_orm(column_name = "originalUrl")]
|
||||
pub original_url: String,
|
||||
pub uri: Option<String>,
|
||||
#[sea_orm(column_name = "mimeType")]
|
||||
pub mime_type: Option<String>,
|
||||
pub r#type: Option<String>,
|
||||
pub aliases: Vec<String>,
|
||||
pub category: Option<String>,
|
||||
#[sea_orm(column_name = "publicUrl")]
|
||||
|
|
|
@ -16,7 +16,7 @@ pub struct Model {
|
|||
pub created_at: DateTime,
|
||||
#[sea_orm(column_name = "userId")]
|
||||
pub user_id: String,
|
||||
pub kind: String,
|
||||
pub r#type: String,
|
||||
#[sea_orm(column_type = "JsonBinary")]
|
||||
pub info: Json,
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ pub struct Model {
|
|||
pub choice: Option<i32>,
|
||||
#[sea_orm(column_name = "followRequestId")]
|
||||
pub follow_request_id: Option<String>,
|
||||
pub kind: NotificationTypeEnum,
|
||||
pub r#type: NotificationTypeEnum,
|
||||
#[sea_orm(column_name = "userGroupInvitationId")]
|
||||
pub user_group_invitation_id: Option<String>,
|
||||
#[sea_orm(column_name = "customBody")]
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
import type { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class RenameType1714191375157 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
queryRunner.query(
|
||||
`ALTER TABLE "drive_file" RENAME COLUMN "type" TO "mimeType"`,
|
||||
);
|
||||
queryRunner.query(`ALTER TABLE "emoji" RENAME COLUMN "type" TO "mimeType"`);
|
||||
queryRunner.query(
|
||||
`ALTER TABLE "moderation_log" RENAME COLUMN "type" TO "kind"`,
|
||||
);
|
||||
queryRunner.query(
|
||||
`ALTER TABLE "notification" RENAME COLUMN "type" TO "kind"`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
queryRunner.query(
|
||||
`ALTER TABLE "drive_file" RENAME COLUMN "mimeType" TO "type"`,
|
||||
);
|
||||
queryRunner.query(`ALTER TABLE "emoji" RENAME COLUMN "mimeType" TO "type"`);
|
||||
queryRunner.query(
|
||||
`ALTER TABLE "moderation_log" RENAME COLUMN "kind" TO "type"`,
|
||||
);
|
||||
queryRunner.query(
|
||||
`ALTER TABLE "notification" RENAME COLUMN "kind" TO "type"`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ export class DriveFile {
|
|||
length: 128,
|
||||
comment: "The content type (MIME) of the DriveFile.",
|
||||
})
|
||||
public mimeType: string;
|
||||
public type: string;
|
||||
|
||||
@Column("integer", {
|
||||
comment: "The file size (bytes) of the DriveFile.",
|
||||
|
|
|
@ -54,7 +54,7 @@ export class Emoji {
|
|||
length: 64,
|
||||
nullable: true,
|
||||
})
|
||||
public mimeType: string | null;
|
||||
public type: string | null;
|
||||
|
||||
@Column("varchar", {
|
||||
array: true,
|
||||
|
|
|
@ -27,7 +27,7 @@ export class ModerationLog {
|
|||
@Column("varchar", {
|
||||
length: 128,
|
||||
})
|
||||
public kind: string;
|
||||
public type: string;
|
||||
|
||||
@Column("jsonb")
|
||||
public info: Record<string, any>;
|
||||
|
|
|
@ -66,7 +66,7 @@ export class Notification {
|
|||
enum: notificationTypes,
|
||||
comment: "The type of the Notification.",
|
||||
})
|
||||
public kind: (typeof notificationTypes)[number];
|
||||
public type: (typeof notificationTypes)[number];
|
||||
|
||||
/**
|
||||
* Whether the notification was read.
|
||||
|
|
|
@ -68,9 +68,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({
|
|||
}
|
||||
}
|
||||
|
||||
const isImage =
|
||||
file.mimeType &&
|
||||
[
|
||||
const isImage = [
|
||||
"image/png",
|
||||
"image/apng",
|
||||
"image/gif",
|
||||
|
@ -78,7 +76,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({
|
|||
"image/webp",
|
||||
"image/svg+xml",
|
||||
"image/avif",
|
||||
].includes(file.mimeType);
|
||||
].includes(file.type);
|
||||
|
||||
return thumbnail
|
||||
? file.thumbnailUrl || (isImage ? file.webpublicUrl || file.url : null)
|
||||
|
@ -148,7 +146,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({
|
|||
id: file.id,
|
||||
createdAt: file.createdAt.toISOString(),
|
||||
name: file.name,
|
||||
type: file.mimeType,
|
||||
type: file.type,
|
||||
md5: file.md5,
|
||||
size: file.size,
|
||||
isSensitive: file.isSensitive,
|
||||
|
@ -190,7 +188,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({
|
|||
id: file.id,
|
||||
createdAt: file.createdAt.toISOString(),
|
||||
name: file.name,
|
||||
type: file.mimeType,
|
||||
type: file.type,
|
||||
md5: file.md5,
|
||||
size: file.size,
|
||||
isSensitive: file.isSensitive,
|
||||
|
|
|
@ -11,7 +11,7 @@ export const ModerationLogRepository = db.getRepository(ModerationLog).extend({
|
|||
return await awaitAll({
|
||||
id: log.id,
|
||||
createdAt: log.createdAt.toISOString(),
|
||||
type: log.kind,
|
||||
type: log.type,
|
||||
info: log.info,
|
||||
userId: log.userId,
|
||||
user: Users.pack(log.user || log.userId, null, {
|
||||
|
|
|
@ -35,13 +35,13 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
return await awaitAll({
|
||||
id: notification.id,
|
||||
createdAt: notification.createdAt.toISOString(),
|
||||
type: notification.kind,
|
||||
type: notification.type,
|
||||
isRead: notification.isRead,
|
||||
userId: notification.notifierId,
|
||||
user: notification.notifierId
|
||||
? Users.pack(notification.notifier || notification.notifierId)
|
||||
: null,
|
||||
...(notification.kind === "mention"
|
||||
...(notification.type === "mention"
|
||||
? {
|
||||
note: Notes.pack(
|
||||
notification.note || notification.noteId!,
|
||||
|
@ -53,7 +53,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
),
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "reply"
|
||||
...(notification.type === "reply"
|
||||
? {
|
||||
note: Notes.pack(
|
||||
notification.note || notification.noteId!,
|
||||
|
@ -65,7 +65,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
),
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "renote"
|
||||
...(notification.type === "renote"
|
||||
? {
|
||||
note: Notes.pack(
|
||||
notification.note || notification.noteId!,
|
||||
|
@ -77,7 +77,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
),
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "quote"
|
||||
...(notification.type === "quote"
|
||||
? {
|
||||
note: Notes.pack(
|
||||
notification.note || notification.noteId!,
|
||||
|
@ -89,7 +89,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
),
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "reaction"
|
||||
...(notification.type === "reaction"
|
||||
? {
|
||||
note: Notes.pack(
|
||||
notification.note || notification.noteId!,
|
||||
|
@ -102,7 +102,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
reaction: notification.reaction,
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "pollVote"
|
||||
...(notification.type === "pollVote"
|
||||
? {
|
||||
note: Notes.pack(
|
||||
notification.note || notification.noteId!,
|
||||
|
@ -115,7 +115,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
choice: notification.choice,
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "pollEnded"
|
||||
...(notification.type === "pollEnded"
|
||||
? {
|
||||
note: Notes.pack(
|
||||
notification.note || notification.noteId!,
|
||||
|
@ -127,14 +127,14 @@ export const NotificationRepository = db.getRepository(Notification).extend({
|
|||
),
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "groupInvited"
|
||||
...(notification.type === "groupInvited"
|
||||
? {
|
||||
invitation: UserGroupInvitations.pack(
|
||||
notification.userGroupInvitationId!,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
...(notification.kind === "app"
|
||||
...(notification.type === "app"
|
||||
? {
|
||||
body: notification.customBody,
|
||||
header: notification.customHeader || token?.name,
|
||||
|
|
|
@ -67,7 +67,7 @@ export async function exportCustomEmojis(
|
|||
});
|
||||
|
||||
for (const emoji of customEmojis) {
|
||||
const ext = mime.extension(emoji.mimeType);
|
||||
const ext = mime.extension(emoji.type);
|
||||
const fileName = emoji.name + (ext ? `.${ext}` : "");
|
||||
const emojiPath = `${path}/${fileName}`;
|
||||
fs.writeFileSync(emojiPath, "", "binary");
|
||||
|
|
|
@ -105,7 +105,7 @@ export async function importCustomEmojis(
|
|||
aliases: emojiInfo.aliases,
|
||||
originalUrl: driveFile.url,
|
||||
publicUrl: driveFile.webpublicUrl ?? driveFile.url,
|
||||
mimeType: driveFile.webpublicType ?? driveFile.mimeType,
|
||||
type: driveFile.webpublicType ?? driveFile.type,
|
||||
license: emojiInfo.license,
|
||||
width: size.width || null,
|
||||
height: size.height || null,
|
||||
|
@ -160,7 +160,7 @@ export async function importCustomEmojis(
|
|||
aliases: [],
|
||||
originalUrl: driveFile.url,
|
||||
publicUrl: driveFile.webpublicUrl ?? driveFile.url,
|
||||
mimeType: driveFile.webpublicType ?? driveFile.mimeType,
|
||||
type: driveFile.webpublicType ?? driveFile.type,
|
||||
license: null,
|
||||
width: size.width || null,
|
||||
height: size.height || null,
|
||||
|
|
|
@ -36,7 +36,7 @@ export async function importFollowing(
|
|||
|
||||
let linenum = 0;
|
||||
|
||||
if (file.mimeType.endsWith("json")) {
|
||||
if (file.type.endsWith("json")) {
|
||||
for (const acct of JSON.parse(csv)) {
|
||||
try {
|
||||
const { username, host } = stringToAcct(acct);
|
||||
|
|
|
@ -654,10 +654,10 @@ export async function updateNote(value: string | IObject, resolver?: Resolver) {
|
|||
)
|
||||
).filter((file) => file != null);
|
||||
const fileIds = driveFiles.map((file) => file.id);
|
||||
const fileTypes = driveFiles.map((file) => file.mimeType);
|
||||
const fileTypes = driveFiles.map((file) => file.type);
|
||||
|
||||
const apEmojis = (
|
||||
await extractEmojis(post.tag || [], actor.host).catch((e) => [])
|
||||
await extractEmojis(post.tag || [], actor.host).catch((_) => [])
|
||||
).map((emoji) => emoji.name);
|
||||
const apMentions = await extractApMentions(post.tag);
|
||||
const apHashtags = await extractApHashtags(post.tag);
|
||||
|
|
|
@ -3,7 +3,7 @@ import { DriveFiles } from "@/models/index.js";
|
|||
|
||||
export default (file: DriveFile) => ({
|
||||
type: "Document",
|
||||
mediaType: file.mimeType,
|
||||
mediaType: file.type,
|
||||
url: DriveFiles.getPublicUrl(file),
|
||||
name: file.comment,
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ export default (emoji: Emoji) => ({
|
|||
: new Date().toISOString,
|
||||
icon: {
|
||||
type: "Image",
|
||||
mediaType: emoji.mimeType || "image/png",
|
||||
mediaType: emoji.type || "image/png",
|
||||
url: emoji.publicUrl || emoji.originalUrl, // || emoji.originalUrl してるのは後方互換性のため
|
||||
},
|
||||
});
|
||||
|
|
|
@ -71,11 +71,11 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
|
||||
if (ps.type) {
|
||||
if (ps.type.endsWith("/*")) {
|
||||
query.andWhere("file.mimeType like :type", {
|
||||
query.andWhere("file.type like :type", {
|
||||
type: `${ps.type.replace("/*", "/")}%`,
|
||||
});
|
||||
} else {
|
||||
query.andWhere("file.mimeType = :type", { type: ps.type });
|
||||
query.andWhere("file.type = :type", { type: ps.type });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
aliases: [],
|
||||
originalUrl: file.url,
|
||||
publicUrl: file.webpublicUrl ?? file.url,
|
||||
mimeType: file.webpublicType ?? file.mimeType,
|
||||
type: file.webpublicType ?? file.type,
|
||||
license: null,
|
||||
width: size?.width || null,
|
||||
height: size?.height || null,
|
||||
|
|
|
@ -98,7 +98,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
aliases: [],
|
||||
originalUrl: driveFile.url,
|
||||
publicUrl: driveFile.webpublicUrl ?? driveFile.url,
|
||||
mimeType: driveFile.webpublicType ?? driveFile.mimeType,
|
||||
type: driveFile.webpublicType ?? driveFile.type,
|
||||
license: emoji.license,
|
||||
width: size?.width ?? null,
|
||||
height: size?.height ?? null,
|
||||
|
|
|
@ -21,7 +21,7 @@ export const paramDef = {
|
|||
export default define(meta, paramDef, async () => {
|
||||
const now = Date.now();
|
||||
const emojis: Emoji[] = await Emojis.find({
|
||||
where: { host: IsNull(), mimeType: In(FILE_TYPE_BROWSERSAFE) },
|
||||
where: { host: IsNull(), type: In(FILE_TYPE_BROWSERSAFE) },
|
||||
select: ["name", "originalUrl", "publicUrl", "category"],
|
||||
});
|
||||
|
||||
|
|
|
@ -58,11 +58,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
if (ps.type) {
|
||||
if (ps.type.endsWith("/*")) {
|
||||
query.andWhere("file.mimeType like :type", {
|
||||
query.andWhere("file.type like :type", {
|
||||
type: `${ps.type.replace("/*", "/")}%`,
|
||||
});
|
||||
} else {
|
||||
query.andWhere("file.mimeType = :type", { type: ps.type });
|
||||
query.andWhere("file.type = :type", { type: ps.type });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
if (ps.type) {
|
||||
if (ps.type.endsWith("/*")) {
|
||||
query.andWhere("file.mimeType like :type", {
|
||||
query.andWhere("file.type like :type", {
|
||||
type: `${ps.type.replace("/*", "/")}%`,
|
||||
});
|
||||
} else {
|
||||
query.andWhere("file.mimeType = :type", { type: ps.type });
|
||||
query.andWhere("file.type = :type", { type: ps.type });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.mimeType.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
if (file.size > 50000) throw new ApiError(meta.errors.tooBigFile);
|
||||
if (file.size === 0) throw new ApiError(meta.errors.emptyFile);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.mimeType.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
if (file.size > 2_000_000) throw new ApiError(meta.errors.tooBigFile);
|
||||
if (file.size === 0) throw new ApiError(meta.errors.emptyFile);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.mimeType.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
if (file.size > 50000) throw new ApiError(meta.errors.tooBigFile);
|
||||
if (file.size === 0) throw new ApiError(meta.errors.emptyFile);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.mimeType.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
if (file.size > 30000) throw new ApiError(meta.errors.tooBigFile);
|
||||
if (file.size === 0) throw new ApiError(meta.errors.emptyFile);
|
||||
|
||||
|
|
|
@ -150,11 +150,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
|
||||
if (ps.includeTypes && ps.includeTypes.length > 0) {
|
||||
query.andWhere("notification.kind IN (:...includeTypes)", {
|
||||
query.andWhere("notification.type IN (:...includeTypes)", {
|
||||
includeTypes: ps.includeTypes,
|
||||
});
|
||||
} else if (ps.excludeTypes && ps.excludeTypes.length > 0) {
|
||||
query.andWhere("notification.kind NOT IN (:...excludeTypes)", {
|
||||
query.andWhere("notification.type NOT IN (:...excludeTypes)", {
|
||||
excludeTypes: ps.excludeTypes,
|
||||
});
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
const notes = notifications
|
||||
.filter((notification) =>
|
||||
["mention", "reply", "quote"].includes(notification.kind),
|
||||
["mention", "reply", "quote"].includes(notification.type),
|
||||
)
|
||||
.map((notification) => notification.note!);
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
|||
|
||||
if (avatar == null || avatar.userId !== user.id)
|
||||
throw new ApiError(meta.errors.noSuchAvatar);
|
||||
if (!avatar.mimeType.startsWith("image/"))
|
||||
if (!avatar.type.startsWith("image/"))
|
||||
throw new ApiError(meta.errors.avatarNotAnImage);
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
|||
|
||||
if (banner == null || banner.userId !== user.id)
|
||||
throw new ApiError(meta.errors.noSuchBanner);
|
||||
if (!banner.mimeType.startsWith("image/"))
|
||||
if (!banner.type.startsWith("image/"))
|
||||
throw new ApiError(meta.errors.bannerNotAnImage);
|
||||
}
|
||||
|
||||
|
|
|
@ -595,7 +595,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
files.find((file) => file.id === fileId),
|
||||
);
|
||||
update.attachedFileTypes = attachedFiles.map(
|
||||
(file) => file?.mimeType || "application/octet-stream",
|
||||
(file) => file?.type || "application/octet-stream",
|
||||
);
|
||||
} else {
|
||||
update.attachedFileTypes = undefined;
|
||||
|
|
|
@ -146,8 +146,8 @@ export default async function (ctx: Koa.Context) {
|
|||
|
||||
fileHandle = await InternalStorage.open(key, "r");
|
||||
} else {
|
||||
(contentType = FILE_TYPE_BROWSERSAFE.includes(file.mimeType)
|
||||
? file.mimeType
|
||||
(contentType = FILE_TYPE_BROWSERSAFE.includes(file.type)
|
||||
? file.type
|
||||
: "application/octet-stream"),
|
||||
(filename = file.name);
|
||||
fileHandle = await InternalStorage.open(file.accessKey!, "r");
|
||||
|
|
|
@ -134,16 +134,16 @@ export default async function (
|
|||
: [];
|
||||
let fileEle = "";
|
||||
for (const file of files) {
|
||||
if (file.mimeType.startsWith("image/")) {
|
||||
if (file.type.startsWith("image/")) {
|
||||
fileEle += ` <br><img src="${DriveFiles.getPublicUrl(file)}">`;
|
||||
} else if (file.mimeType.startsWith("audio/")) {
|
||||
} else if (file.type.startsWith("audio/")) {
|
||||
fileEle += ` <br><audio controls src="${DriveFiles.getPublicUrl(
|
||||
file,
|
||||
)}" type="${file.mimeType}">`;
|
||||
} else if (file.mimeType.startsWith("video/")) {
|
||||
)}" type="${file.type}">`;
|
||||
} else if (file.type.startsWith("video/")) {
|
||||
fileEle += ` <br><video controls src="${DriveFiles.getPublicUrl(
|
||||
file,
|
||||
)}" type="${file.mimeType}">`;
|
||||
)}" type="${file.type}">`;
|
||||
} else {
|
||||
fileEle += ` <br><a href="${DriveFiles.getPublicUrl(file)}" download="${
|
||||
file.name
|
||||
|
|
|
@ -15,7 +15,7 @@ import { sendEmailNotification } from "./send-email-notification.js";
|
|||
|
||||
export async function createNotification(
|
||||
notifieeId: User["id"],
|
||||
type: Notification["kind"],
|
||||
type: Notification["type"],
|
||||
data: Partial<Notification>,
|
||||
) {
|
||||
if (data.notifierId && notifieeId === data.notifierId) {
|
||||
|
@ -62,7 +62,7 @@ export async function createNotification(
|
|||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
notifieeId: notifieeId,
|
||||
kind: type,
|
||||
type,
|
||||
// 相手がこの通知をミュートしているようなら、既読を予めつけておく
|
||||
isRead: isMuted,
|
||||
...data,
|
||||
|
|
|
@ -158,7 +158,7 @@ async function save(
|
|||
file.webpublicAccessKey = webpublicKey;
|
||||
file.webpublicType = alts.webpublic?.type ?? null;
|
||||
file.name = name;
|
||||
file.mimeType = type;
|
||||
file.type = type;
|
||||
file.md5 = hash;
|
||||
file.size = size;
|
||||
file.storedInternal = false;
|
||||
|
@ -203,7 +203,7 @@ async function save(
|
|||
file.webpublicAccessKey = webpublicAccessKey;
|
||||
file.webpublicType = alts.webpublic?.type ?? null;
|
||||
file.name = name;
|
||||
file.mimeType = type;
|
||||
file.type = type;
|
||||
file.md5 = hash;
|
||||
file.size = size;
|
||||
file.usageHint = usage ?? null;
|
||||
|
@ -622,7 +622,7 @@ export async function addFile({
|
|||
file.size = 0;
|
||||
file.md5 = fileInfo.md5;
|
||||
file.name = detectedName;
|
||||
file.mimeType = fileInfo.mime;
|
||||
file.type = fileInfo.mime;
|
||||
file.storedInternal = false;
|
||||
|
||||
file = await DriveFiles.insert(file).then((x) =>
|
||||
|
|
|
@ -11,7 +11,7 @@ export async function insertModerationLog(
|
|||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
userId: moderator.id,
|
||||
kind: type,
|
||||
type,
|
||||
info: info || {},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue