This commit is contained in:
thororen 2024-04-27 10:54:30 -04:00
parent 86d6fc60ab
commit 8268f70518

View file

@ -25,13 +25,12 @@ import definePlugin, { OptionType } from "@utils/types";
import style from "./index.css?managed"; import style from "./index.css?managed";
const API_URL = "https://usrbg.is-hardly.online/users"; const API_URL = "https://usrbg.is-hardly.online/users";
const cachebust = Date.now();
interface UsrbgApiReturn { interface UsrbgApiReturn {
endpoint: string; endpoint: string;
bucket: string; bucket: string;
prefix: string; prefix: string;
users: string[]; users: { [id: string]: string; };
} }
const settings = definePluginSettings({ const settings = definePluginSettings({
@ -122,7 +121,7 @@ export default definePlugin({
userHasBackground(userId: string) { userHasBackground(userId: string) {
if (this.data === null) return false; if (this.data === null) return false;
return this.data.users.includes(userId); return this.data.users[userId] !== undefined;
}, },
getImageUrl(userId: string): string | null { getImageUrl(userId: string): string | null {
@ -130,8 +129,13 @@ export default definePlugin({
return null; return null;
} }
const etag = this.data.users[userId];
if (etag === undefined) {
return null;
}
const { endpoint, bucket, prefix } = this.data; const { endpoint, bucket, prefix } = this.data;
return `${endpoint}/${bucket}/${prefix}${userId}?${cachebust}`; return `${endpoint}/${bucket}/${prefix}${userId}?${etag}`;
}, },
async start() { async start() {