mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 08:53:48 +01:00
[mastodon-client] Use actual default reaction
This commit is contained in:
parent
f57239fc58
commit
f29fee74a0
@ -284,7 +284,7 @@ export function apiStatusMastodon(router: Router): void {
|
||||
const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
|
||||
const accessTokens = ctx.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
const react = await getFirstReaction(BASE_URL, accessTokens);
|
||||
const react = await NoteHelpers.getDefaultReaction();
|
||||
try {
|
||||
const a = (await client.createEmojiReaction(
|
||||
convertId(ctx.params.id, IdType.IceshrimpId),
|
||||
@ -306,7 +306,7 @@ export function apiStatusMastodon(router: Router): void {
|
||||
const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
|
||||
const accessTokens = ctx.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
const react = await getFirstReaction(BASE_URL, accessTokens);
|
||||
const react = await NoteHelpers.getDefaultReaction();
|
||||
try {
|
||||
const data = await client.deleteEmojiReaction(
|
||||
convertId(ctx.params.id, IdType.IceshrimpId),
|
||||
@ -541,25 +541,3 @@ export function apiStatusMastodon(router: Router): void {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async function getFirstReaction(
|
||||
BASE_URL: string,
|
||||
accessTokens: string | undefined,
|
||||
) {
|
||||
const accessTokenArr = accessTokens?.split(" ") ?? [null];
|
||||
const accessToken = accessTokenArr[accessTokenArr.length - 1];
|
||||
let react = "⭐";
|
||||
try {
|
||||
const api = await axios.post(`${BASE_URL}/api/i/registry/get-unsecure`, {
|
||||
scope: ["client", "base"],
|
||||
key: "reactions",
|
||||
i: accessToken,
|
||||
});
|
||||
const reactRaw = api.data;
|
||||
react = Array.isArray(reactRaw) ? api.data[0] : "⭐";
|
||||
console.log(api.data);
|
||||
return react;
|
||||
} catch (e) {
|
||||
return react;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js";
|
||||
import { Notes } from "@/models/index.js";
|
||||
import { Metas, Notes } from "@/models/index.js";
|
||||
import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js";
|
||||
import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js";
|
||||
import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js";
|
||||
@ -10,6 +10,13 @@ import { getNote } from "@/server/api/common/getters.js";
|
||||
import { ObjectLiteral, SelectQueryBuilder } from "typeorm";
|
||||
|
||||
export class NoteHelpers {
|
||||
public static async getDefaultReaction(): Promise<string> {
|
||||
return Metas.createQueryBuilder()
|
||||
.select('"defaultReaction"')
|
||||
.execute()
|
||||
.then(p => p[0].defaultReaction);
|
||||
}
|
||||
|
||||
public static async getNoteDescendants(note: Note | string, user: ILocalUser | null, limit: number = 10, depth: number = 2): Promise<Note[]> {
|
||||
const noteId = typeof note === "string" ? note : note.id;
|
||||
const query = makePaginationQuery(Notes.createQueryBuilder("note"))
|
||||
|
Loading…
Reference in New Issue
Block a user