fix: 🐛 properly decode reaction

This commit is contained in:
ThatOneCalculator 2023-09-20 22:35:10 -07:00
parent 238f80ae02
commit baba9b068b
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
2 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import { NoteReaction } from "@/models/entities/note-reaction.js";
import { Notes, Users } from "../index.js";
import type { Packed } from "@/misc/schema.js";
import type { User } from "@/models/entities/user.js";
import { decodeReaction } from "@/misc/reaction-lib.js";
export const NoteReactionRepository = db.getRepository(NoteReaction).extend({
async pack(
@ -26,7 +27,7 @@ export const NoteReactionRepository = db.getRepository(NoteReaction).extend({
id: reaction.id,
createdAt: reaction.createdAt.toISOString(),
user: await Users.pack(reaction.user ?? reaction.userId, me),
type: reaction.reaction,
type: decodeReaction(reaction.reaction).reaction,
...(opts.withNote
? {
note: await Notes.pack(reaction.note ?? reaction.noteId, me),

View File

@ -73,7 +73,7 @@ async function populateMyReaction(
if (_hint_?.myReactions) {
const reaction = _hint_.myReactions.get(note.id);
if (reaction) {
return reaction.reaction;
return decodeReaction(reaction.reaction).reaction;
} else if (reaction === null) {
return undefined;
}
@ -86,7 +86,7 @@ async function populateMyReaction(
});
if (reaction) {
return reaction.reaction;
return decodeReaction(reaction.reaction).reaction;
}
return undefined;
@ -103,7 +103,7 @@ export const NoteRepository = db.getRepository(Note).extend({
return true;
} else {
// 指定されているかどうか
return note.visibleUserIds.some((id: string) => meId === id);
return note.visibleUserIds.some((id: any) => meId === id);
}
}