aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/reviewDB/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/reviewDB/Utils')
-rw-r--r--src/plugins/reviewDB/Utils/ReviewDBAPI.ts18
-rw-r--r--src/plugins/reviewDB/Utils/Utils.tsx9
2 files changed, 15 insertions, 12 deletions
diff --git a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts
index 74415bb..b9f48d2 100644
--- a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts
+++ b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts
@@ -19,6 +19,7 @@
import { Settings } from "@api/settings";
import { Review } from "../entities/Review";
+import { ReviewDBUser } from "../entities/User";
import { authorize, showToast } from "./Utils";
const API_URL = "https://manti.vendicated.dev";
@@ -32,8 +33,12 @@ interface Response {
updated: boolean;
}
+const WarningFlag = 0b00000010;
+
export async function getReviews(id: string): Promise<Review[]> {
- const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews`);
+ var flags = 0;
+ if (!Settings.plugins.ReviewDB.showWarning) flags |= WarningFlag;
+ const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews?flags=${flags}`);
const res = (req.status === 200) ? await req.json() as Response : { success: false, message: "An Error occured while fetching reviews. Please try again later.", reviews: [], updated: false };
if (!res.success) {
@@ -43,6 +48,7 @@ export async function getReviews(id: string): Promise<Review[]> {
id: 0,
comment: "An Error occured while fetching reviews. Please try again later.",
star: 0,
+ timestamp: 0,
sender: {
id: 0,
username: "Error",
@@ -108,8 +114,10 @@ export async function reportReview(id: number) {
showToast(await res.message);
}
-export function getLastReviewID(id: string): Promise<number> {
- return fetch(API_URL + "/getLastReviewID?discordid=" + id)
- .then(r => r.text())
- .then(Number);
+export function getCurrentUserInfo(token: string): Promise<ReviewDBUser> {
+ return fetch(API_URL + "/api/reviewdb/users", {
+ body: JSON.stringify({ token }),
+ method: "POST",
+ })
+ .then(r => r.json());
}
diff --git a/src/plugins/reviewDB/Utils/Utils.tsx b/src/plugins/reviewDB/Utils/Utils.tsx
index b3cb6cd..7fb907b 100644
--- a/src/plugins/reviewDB/Utils/Utils.tsx
+++ b/src/plugins/reviewDB/Utils/Utils.tsx
@@ -17,13 +17,13 @@
*/
import { Settings } from "@api/settings";
-import { Devs } from "@utils/constants";
import Logger from "@utils/Logger";
import { openModal } from "@utils/modal";
import { findByProps } from "@webpack";
import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common";
import { Review } from "../entities/Review";
+import { UserType } from "../entities/User";
export async function openUserProfileModal(userId: string) {
await UserUtils.fetchUser(userId);
@@ -86,10 +86,5 @@ export function showToast(text: string) {
export const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
export function canDeleteReview(review: Review, userId: string) {
- if (review.sender.discordID === userId) return true;
-
- const myId = BigInt(userId);
- return myId === Devs.mantikafasi.id ||
- myId === Devs.Ven.id ||
- myId === Devs.rushii.id;
+ if (review.sender.discordID === userId || Settings.plugins.ReviewDB.userType === UserType.Admin) return true;
}