1
+ import { getLogger } from "@logtape/logtape" ;
1
2
import { desc , inArray , isNotNull , ne } from "drizzle-orm" ;
2
3
import { Hono } from "hono" ;
3
4
import mime from "mime" ;
@@ -7,6 +8,8 @@ import { loginRequired } from "../login";
7
8
import { accounts , customEmojis , posts , reactions } from "../schema" ;
8
9
import { disk , getAssetUrl } from "../storage" ;
9
10
11
+ const logger = getLogger ( [ "hollo" , "pages" , "emojis" ] ) ;
12
+
10
13
const emojis = new Hono ( ) ;
11
14
12
15
emojis . use ( loginRequired ) ;
@@ -368,13 +371,16 @@ emojis.post("/import", async (c) => {
368
371
? ( form . get ( "new" ) ?. toString ( ) ?? "" )
369
372
: null ;
370
373
const imports = form . getAll ( "import" ) . map ( ( i ) => JSON . parse ( i . toString ( ) ) ) ;
371
- await db . insert ( customEmojis ) . values (
372
- imports . map ( ( { shortcode, url } ) => ( {
373
- category,
374
- shortcode,
375
- url,
376
- } ) ) ,
377
- ) ;
374
+ for ( const { shortcode, url } of imports ) {
375
+ try {
376
+ await db . insert ( customEmojis ) . values ( { category, shortcode, url } ) ;
377
+ } catch ( error ) {
378
+ logger . error (
379
+ "Failed to import emoji {shortcode} to {category}: {error}" ,
380
+ { category, shortcode, error } ,
381
+ ) ;
382
+ }
383
+ }
378
384
return c . redirect ( "/emojis" ) ;
379
385
} ) ;
380
386
0 commit comments