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,31 @@
import { db } from "../../db/postgre.js";
import { NoteReaction } from "../entities/note-reaction.js";
import { Notes, Users } from "../index.js";
import { convertLegacyReaction } from "../../misc/reaction-lib.js";
export const NoteReactionRepository = db.getRepository(NoteReaction).extend({
async pack (src, me, options) {
const opts = Object.assign({
withNote: false
}, options);
const reaction = typeof src === "object" ? src : await this.findOneByOrFail({
id: src
});
return {
id: reaction.id,
createdAt: reaction.createdAt.toISOString(),
user: await Users.pack(reaction.user ?? reaction.userId, me),
type: convertLegacyReaction(reaction.reaction),
...opts.withNote ? {
// may throw error
note: await Notes.pack(reaction.note ?? reaction.noteId, me)
} : {}
};
},
async packMany (src, me, options) {
const reactions = await Promise.allSettled(src.map((reaction)=>this.pack(reaction, me, options)));
// filter out rejected promises, only keep fulfilled values
return reactions.flatMap((result)=>result.status === "fulfilled" ? [
result.value
] : []);
}
});