fix reviewdb auth not working on userscript (#2194)

This commit is contained in:
Manti 2024-02-20 21:13:25 +03:00 committed by GitHub
parent 604f4c49af
commit f922f0bc0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 9 deletions

View file

@ -59,7 +59,7 @@ export function authorize(callback?: any) {
const url = new URL(response.location); const url = new URL(response.location);
url.searchParams.append("clientMod", "vencord"); url.searchParams.append("clientMod", "vencord");
const res = await fetch(url, { const res = await fetch(url, {
headers: new Headers({ Accept: "application/json" }) headers: { Accept: "application/json" }
}); });
if (!res.ok) { if (!res.ok) {

View file

@ -118,10 +118,10 @@ export async function addReview(review: any): Promise<Response | null> {
export async function deleteReview(id: number): Promise<Response | null> { export async function deleteReview(id: number): Promise<Response | null> {
return await rdbRequest(`/users/${id}/reviews`, { return await rdbRequest(`/users/${id}/reviews`, {
method: "DELETE", method: "DELETE",
headers: new Headers({ headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
}), },
body: JSON.stringify({ body: JSON.stringify({
reviewid: id reviewid: id
}) })
@ -135,10 +135,10 @@ export async function deleteReview(id: number): Promise<Response | null> {
export async function reportReview(id: number) { export async function reportReview(id: number) {
const res = await rdbRequest("/reports", { const res = await rdbRequest("/reports", {
method: "PUT", method: "PUT",
headers: new Headers({ headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
}), },
body: JSON.stringify({ body: JSON.stringify({
reviewid: id, reviewid: id,
}) })
@ -150,10 +150,10 @@ export async function reportReview(id: number) {
async function patchBlock(action: "block" | "unblock", userId: string) { async function patchBlock(action: "block" | "unblock", userId: string) {
const res = await rdbRequest("/blocks", { const res = await rdbRequest("/blocks", {
method: "PATCH", method: "PATCH",
headers: new Headers({ headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
}), },
body: JSON.stringify({ body: JSON.stringify({
action: action, action: action,
discordId: userId discordId: userId
@ -180,9 +180,9 @@ export const unblockUser = (userId: string) => patchBlock("unblock", userId);
export async function fetchBlocks(): Promise<ReviewDBUser[]> { export async function fetchBlocks(): Promise<ReviewDBUser[]> {
const res = await rdbRequest("/blocks", { const res = await rdbRequest("/blocks", {
method: "GET", method: "GET",
headers: new Headers({ headers: {
Accept: "application/json", Accept: "application/json",
}) }
}); });
if (!res.ok) throw new Error(`${res.status}: ${res.statusText}`); if (!res.ok) throw new Error(`${res.status}: ${res.statusText}`);