From 73a284782150cfc16cbdc6f59a5ba184d498ddac Mon Sep 17 00:00:00 2001 From: Lumina Mystere Date: Sat, 13 Jul 2024 21:04:23 +1200 Subject: [PATCH] Add ignore endpoints to button repository --- src/Fluff4me.ts | 17 +++++++++++- src/dev/ButtonRegistry.ts | 56 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/Fluff4me.ts b/src/Fluff4me.ts index 635e553..2c275cd 100644 --- a/src/Fluff4me.ts +++ b/src/Fluff4me.ts @@ -231,13 +231,28 @@ export default class Fluff4me { name: "Spam Create Follow Work Test", async execute () { await BUTTON_REGISTRY.createAuthor.execute("spam create works", "manyworks"); - for (let i = 0; i < 30; i++) { + for (let i = 0; i < 100; i++) { await BUTTON_REGISTRY.createWork.execute(`rapid story ${i}`, "aaaaaaaaa", `rapidstory${i}`, "Ongoing", "Public"); await BUTTON_REGISTRY.follow.execute("work", `rapidstory${i}`); } }, })); + testButtons.append(createButton({ + name: "Test Ignore Endpoints", + async execute () { + await BUTTON_REGISTRY.createAuthor.execute("ignoring myself", "ignorepls"); + await BUTTON_REGISTRY.createWork.execute("to ignore", "testing ignoring", "worktoignore", "Ongoing", "Public"); + await BUTTON_REGISTRY.ignore.execute("author", "ignorepls"); + await BUTTON_REGISTRY.ignore.execute("work", "worktoignore"); + await BUTTON_REGISTRY.getIgnore.execute("author", "ignorepls"); + await BUTTON_REGISTRY.getIgnore.execute("work", "worktoignore"); + await BUTTON_REGISTRY.getAllIgnores.execute("author"); + await BUTTON_REGISTRY.getAllIgnores.execute("work"); + await BUTTON_REGISTRY.getAllIgnoresMerged.execute(); + }, + })); + } } diff --git a/src/dev/ButtonRegistry.ts b/src/dev/ButtonRegistry.ts index 58fd733..ee4beea 100644 --- a/src/dev/ButtonRegistry.ts +++ b/src/dev/ButtonRegistry.ts @@ -252,4 +252,60 @@ export const BUTTON_REGISTRY = { }, }, + ignore: { + name: "Ignore", + async execute (type: string, vanity: string) { + await fetch(`${Env.API_ORIGIN}ignore/${type}/${vanity}`, { + method: "POST", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + }); + }, + }, + + unignore: { + name: "Unignore", + async execute (type: string, vanity: string) { + await fetch(`${Env.API_ORIGIN}unignore/${type}/${vanity}`, { + method: "POST", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + }); + }, + }, + + getIgnore: { + name: "Get Ignore", + async execute (type: string, vanity: string) { + const response = await fetch(`${Env.API_ORIGIN}ignores/${type}/${vanity}`, { + credentials: "include", + }).then(response => response.json()); + console.log(response); + }, + }, + + getAllIgnores: { + name: "Get All Ignores", + async execute (type: string, page: number = 0) { + const response = await fetch(`${Env.API_ORIGIN}ignoring/${type}?page=${page}`, { + credentials: "include", + }).then(response => response.json()); + console.log(response); + }, + }, + + getAllIgnoresMerged: { + name: "Get All Ignores Merged", + async execute (page: number = 0) { + const response = await fetch(`${Env.API_ORIGIN}ignoring?page=${page}`, { + credentials: "include", + }).then(response => response.json()); + console.log(response); + }, + }, + } satisfies Record>;