throw error if failed

This commit is contained in:
Namekuji 2023-07-02 22:21:19 -04:00
parent 284c0db1fd
commit b36cc31e9b
2 changed files with 4 additions and 14 deletions

View file

@ -6,7 +6,7 @@ import { ApiError } from "../../../error.js";
import rndstr from "rndstr"; import rndstr from "rndstr";
import { publishBroadcastStream } from "@/services/stream.js"; import { publishBroadcastStream } from "@/services/stream.js";
import { db } from "@/db/postgre.js"; import { db } from "@/db/postgre.js";
import { type Size, getEmojiSize } from "@/misc/emoji-meta.js"; import { getEmojiSize } from "@/misc/emoji-meta.js";
export const meta = { export const meta = {
tags: ["admin"], tags: ["admin"],
@ -40,12 +40,7 @@ export default define(meta, paramDef, async (ps, me) => {
? file.name.split(".")[0] ? file.name.split(".")[0]
: `_${rndstr("a-z0-9", 8)}_`; : `_${rndstr("a-z0-9", 8)}_`;
let size: Size = { width: 0, height: 0 }; const size = await getEmojiSize(file.url);
try {
size = await getEmojiSize(file.url);
} catch {
/* skip if any error happens */
}
const emoji = await Emojis.insert({ const emoji = await Emojis.insert({
id: genId(), id: genId(),

View file

@ -6,7 +6,7 @@ import type { DriveFile } from "@/models/entities/drive-file.js";
import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; import { uploadFromUrl } from "@/services/drive/upload-from-url.js";
import { publishBroadcastStream } from "@/services/stream.js"; import { publishBroadcastStream } from "@/services/stream.js";
import { db } from "@/db/postgre.js"; import { db } from "@/db/postgre.js";
import { type Size, getEmojiSize } from "@/misc/emoji-meta.js"; import { getEmojiSize } from "@/misc/emoji-meta.js";
export const meta = { export const meta = {
tags: ["admin"], tags: ["admin"],
@ -65,12 +65,7 @@ export default define(meta, paramDef, async (ps, me) => {
throw new ApiError(); throw new ApiError();
} }
let size: Size = { width: 0, height: 0 }; const size = await getEmojiSize(driveFile.url);
try {
size = await getEmojiSize(driveFile.url);
} catch {
/* skip if any error happens */
}
const copied = await Emojis.insert({ const copied = await Emojis.insert({
id: genId(), id: genId(),