fix: 🐛 strange heart reaction behavior
This commit is contained in:
parent
b121e4bc9d
commit
af730e75b6
@ -4,11 +4,6 @@ import { Emojis } from "@/models/index.js";
|
|||||||
import { toPunyNullable } from "./convert-host.js";
|
import { toPunyNullable } from "./convert-host.js";
|
||||||
import { IsNull } from "typeorm";
|
import { IsNull } from "typeorm";
|
||||||
|
|
||||||
export async function getFallbackReaction() {
|
|
||||||
const meta = await fetchMeta();
|
|
||||||
return meta.defaultReaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function convertReactions(reactions: Record<string, number>) {
|
export function convertReactions(reactions: Record<string, number>) {
|
||||||
const result = new Map();
|
const result = new Map();
|
||||||
|
|
||||||
@ -26,11 +21,11 @@ export async function toDbReaction(
|
|||||||
reaction?: string | null,
|
reaction?: string | null,
|
||||||
reacterHost?: string | null,
|
reacterHost?: string | null,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (!reaction) return await getFallbackReaction();
|
if (!reaction) return (await fetchMeta()).defaultReaction;
|
||||||
|
|
||||||
reacterHost = toPunyNullable(reacterHost);
|
reacterHost = toPunyNullable(reacterHost);
|
||||||
|
|
||||||
if (reaction === "♥️") return "❤️";
|
if (reaction.includes("❤") || reaction.includes("♥️")) return "❤️";
|
||||||
|
|
||||||
// Allow unicode reactions
|
// Allow unicode reactions
|
||||||
const match = emojiRegex.exec(reaction);
|
const match = emojiRegex.exec(reaction);
|
||||||
@ -50,7 +45,7 @@ export async function toDbReaction(
|
|||||||
if (emoji) return reacterHost ? `:${name}@${reacterHost}:` : `:${name}:`;
|
if (emoji) return reacterHost ? `:${name}@${reacterHost}:` : `:${name}:`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await getFallbackReaction();
|
return (await fetchMeta()).defaultReaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
type DecodedReaction = {
|
type DecodedReaction = {
|
||||||
|
Loading…
Reference in New Issue
Block a user