mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-24 05:47:00 -04:00
Remove ReviewDB
abuse / harassment has gotten pretty bad. i proposed the ability to allow users to delete comments from their own profile, but there seems to be no interest among the reviewdb owners. i don't want vencord to harbour harassment, so i'm removing the plugin for now
This commit is contained in:
parent
377cf60055
commit
390987e4a9
12 changed files with 0 additions and 1238 deletions
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { DataStore } from "@api/index";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { openModal } from "@utils/modal";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { showToast, Toasts, UserStore } from "@webpack/common";
|
||||
|
||||
import { ReviewDBAuth } from "./entities";
|
||||
|
||||
const DATA_STORE_KEY = "rdb-auth";
|
||||
|
||||
const OAuth = findByPropsLazy("OAuth2AuthorizeModal");
|
||||
|
||||
export let Auth: ReviewDBAuth = {};
|
||||
|
||||
export async function initAuth() {
|
||||
Auth = await getAuth() ?? {};
|
||||
}
|
||||
|
||||
export async function getAuth(): Promise<ReviewDBAuth | undefined> {
|
||||
const auth = await DataStore.get(DATA_STORE_KEY);
|
||||
return auth?.[UserStore.getCurrentUser()?.id];
|
||||
}
|
||||
|
||||
export async function getToken() {
|
||||
const auth = await getAuth();
|
||||
return auth?.token;
|
||||
}
|
||||
|
||||
export async function updateAuth(newAuth: ReviewDBAuth) {
|
||||
return DataStore.update(DATA_STORE_KEY, auth => {
|
||||
auth ??= {};
|
||||
Auth = auth[UserStore.getCurrentUser().id] ??= {};
|
||||
|
||||
if (newAuth.token) Auth.token = newAuth.token;
|
||||
if (newAuth.user) Auth.user = newAuth.user;
|
||||
|
||||
return auth;
|
||||
});
|
||||
}
|
||||
|
||||
export function authorize(callback?: any) {
|
||||
openModal(props =>
|
||||
<OAuth.OAuth2AuthorizeModal
|
||||
{...props}
|
||||
scopes={["identify"]}
|
||||
responseType="code"
|
||||
redirectUri="https://manti.vendicated.dev/api/reviewdb/auth"
|
||||
permissions={0n}
|
||||
clientId="915703782174752809"
|
||||
cancelCompletesFlow={false}
|
||||
callback={async (response: any) => {
|
||||
try {
|
||||
const url = new URL(response.location);
|
||||
url.searchParams.append("clientMod", "vencord");
|
||||
const res = await fetch(url, {
|
||||
headers: new Headers({ Accept: "application/json" })
|
||||
});
|
||||
const { token, success } = await res.json();
|
||||
if (success) {
|
||||
updateAuth({ token });
|
||||
showToast("Successfully logged in!");
|
||||
callback?.();
|
||||
} else if (res.status === 1) {
|
||||
showToast("An Error occurred while logging in.", Toasts.Type.FAILURE);
|
||||
}
|
||||
} catch (e) {
|
||||
new Logger("ReviewDB").error("Failed to authorize", e);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue