Skip to content

Commit

Permalink
Add ignore endpoints to button repository
Browse files Browse the repository at this point in the history
  • Loading branch information
luminamystere committed Jul 13, 2024
1 parent c0130b5 commit 73a2847
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Fluff4me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
}));

}
}

Expand Down
56 changes: 56 additions & 0 deletions src/dev/ButtonRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, IButtonImplementation<any[]>>;

0 comments on commit 73a2847

Please sign in to comment.