Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
@@ -0,0 +1,33 @@
import { db } from "../../db/postgre.js";
import { GalleryPost } from "../entities/gallery-post.js";
import { Users, DriveFiles, GalleryLikes } from "../index.js";
import { awaitAll } from "../../prelude/await-all.js";
export const GalleryPostRepository = db.getRepository(GalleryPost).extend({
async pack (src, me) {
const meId = me ? me.id : null;
const post = typeof src === "object" ? src : await this.findOneByOrFail({
id: src
});
return await awaitAll({
id: post.id,
createdAt: post.createdAt.toISOString(),
updatedAt: post.updatedAt.toISOString(),
userId: post.userId,
user: Users.pack(post.user || post.userId, me),
title: post.title,
description: post.description,
fileIds: post.fileIds,
files: DriveFiles.packMany(post.fileIds),
tags: post.tags.length > 0 ? post.tags : undefined,
isSensitive: post.isSensitive,
likedCount: post.likedCount,
isLiked: meId ? await GalleryLikes.findOneBy({
postId: post.id,
userId: meId
}).then((x)=>x != null) : undefined
});
},
packMany (posts, me) {
return Promise.all(posts.map((x)=>this.pack(x, me)));
}
});