Skip to content

Commit

Permalink
Update test works buttons to require author vanity
Browse files Browse the repository at this point in the history
  • Loading branch information
luminamystere committed Sep 9, 2024
1 parent 0f423b9 commit a96c231
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/Fluff4me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default class Fluff4me {
await BUTTON_REGISTRY.createChapter.execute("big story 3", "aaaa", "bigstory", "Public");
await BUTTON_REGISTRY.createChapter.execute("big story 4", "aaaaaaa", "bigstory", "Public");
await BUTTON_REGISTRY.createChapter.execute("big story 5", "aaaaaaaaaaaaaaaaaaa", "bigstory", "Public");
await BUTTON_REGISTRY.viewWork.execute("big story five chapters", "bigstory");
await BUTTON_REGISTRY.viewWork.execute("big story five chapters", "justonestory", "bigstory");
// await BUTTON_REGISTRY.follow.execute("work", "debut");

},
Expand Down Expand Up @@ -185,13 +185,13 @@ export default class Fluff4me {
await BUTTON_REGISTRY.createAuthor.execute("new follows", "thefollower");
await BUTTON_REGISTRY.createWork.execute("wow a work", "test pls ignore", "wowawork", "Ongoing", "Public");
await BUTTON_REGISTRY.follow.execute("author", "thefollower");
await BUTTON_REGISTRY.follow.execute("work", "wowawork");
await BUTTON_REGISTRY.followWork.execute("thefollower", "wowawork");
await BUTTON_REGISTRY.getFollow.execute("author", "thefollower");
await BUTTON_REGISTRY.getAllFollows.execute("work");
await BUTTON_REGISTRY.getAllFollowsMerged.execute();
await BUTTON_REGISTRY.unignore.execute("work", "wowawork");
await BUTTON_REGISTRY.unignoreWork.execute("thefollower", "wowawork");
// await BUTTON_REGISTRY.unfollow.execute("work", "wowawork");
await BUTTON_REGISTRY.getFollow.execute("work", "wowawork");
await BUTTON_REGISTRY.getFollowWork.execute("thefollower", "wowawork");
},
}));

Expand Down
100 changes: 86 additions & 14 deletions src/dev/ButtonRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export const BUTTON_REGISTRY = {

updateWork: {
name: "Update Work",
async execute (url: string, name?: string, description?: string, vanity?: string, status?: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/${url}/update`, {
async execute (author: string, url: string, name?: string, description?: string, vanity?: string, status?: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/${author}/${url}/update`, {
method: "POST",
credentials: "include",
headers: {
Expand All @@ -130,8 +130,8 @@ export const BUTTON_REGISTRY = {

deleteWork: {
name: "Delete Work",
async execute (url: string) {
await fetch(`${Env.API_ORIGIN}work/${url}/delete`, {
async execute (author: string, url: string) {
await fetch(`${Env.API_ORIGIN}work/${author}/${url}/delete`, {
method: "POST",
credentials: "include",
headers: {
Expand All @@ -143,8 +143,8 @@ export const BUTTON_REGISTRY = {

viewWork: {
name: "View Work",
async execute (label: string, url: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${url}/get`, {
async execute (label: string, author: string, url: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${author}/${url}/get`, {
credentials: "include",
}).then(response => response.json());
console.log(label, response);
Expand All @@ -153,8 +153,8 @@ export const BUTTON_REGISTRY = {

createChapter: {
name: "Create Chapter",
async execute (name: string, body: string, work_url: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/${work_url}/chapter/create`, {
async execute (author: string, work_url: string, name: string, body: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/${author}/${work_url}/chapter/create`, {
method: "POST",
credentials: "include",
headers: {
Expand All @@ -171,8 +171,8 @@ export const BUTTON_REGISTRY = {

updateChapter: {
name: "Update Chapter",
async execute (workVanity: string, index: number, name?: string, body?: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/${workVanity}/chapter/${index}/update`, {
async execute (author: string, work_url: string, index: number, name?: string, body?: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/${author}/${work_url}/chapter/${index}/update`, {
method: "POST",
credentials: "include",
headers: {
Expand All @@ -189,8 +189,8 @@ export const BUTTON_REGISTRY = {

deleteChapter: {
name: "Delete Chapter",
async execute (work_url: string, index: number) {
await fetch(`${Env.API_ORIGIN}work/${work_url}/chapter/${index}/delete`, {
async execute (author: string, work_url: string, index: number) {
await fetch(`${Env.API_ORIGIN}work/${author}/${work_url}/chapter/${index}/delete`, {
method: "POST",
credentials: "include",
headers: {
Expand All @@ -202,8 +202,8 @@ export const BUTTON_REGISTRY = {

viewChapter: {
name: "View Chapter",
async execute (label: string, work_url: string, index: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${work_url}/chapter/${index}/get`, {
async execute (label: string, author: string, work_url: string, index: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${author}/${work_url}/chapter/${index}/get`, {
credentials: "include",
}).then(response => response.json());
console.log(label, response);
Expand All @@ -223,6 +223,19 @@ export const BUTTON_REGISTRY = {
},
},

followWork: {
name: "Follow",
async execute (author_vanity: string, work_vanity: string) {
await fetch(`${Env.API_ORIGIN}follow/work/${author_vanity}/${work_vanity}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
});
},
},

unfollow: {
name: "Unfollow",
async execute (type: string, vanity: string) {
Expand All @@ -236,6 +249,19 @@ export const BUTTON_REGISTRY = {
},
},

unfollowWork: {
name: "Unfollow",
async execute (author_vanity: string, work_vanity: string) {
await fetch(`${Env.API_ORIGIN}unfollow/work/${author_vanity}/${work_vanity}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
});
},
},

getFollow: {
name: "Get Follow",
async execute (type: string, vanity: string) {
Expand All @@ -246,6 +272,16 @@ export const BUTTON_REGISTRY = {
},
},

getFollowWork: {
name: "Get Follow",
async execute (author_vanity: string, work_vanity: string) {
const response = await fetch(`${Env.API_ORIGIN}follows/work/${author_vanity}/${work_vanity}`, {
credentials: "include",
}).then(response => response.json());
console.log(response);
},
},

getAllFollows: {
name: "Get All Follows",
async execute (type: string, page: number = 0) {
Expand Down Expand Up @@ -279,6 +315,19 @@ export const BUTTON_REGISTRY = {
},
},

ignoreWork: {
name: "Ignore",
async execute (author_vanity: string, work_vanity: string) {
await fetch(`${Env.API_ORIGIN}ignore/work/${author_vanity}/${work_vanity}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
});
},
},

unignore: {
name: "Unignore",
async execute (type: string, vanity: string) {
Expand All @@ -292,6 +341,19 @@ export const BUTTON_REGISTRY = {
},
},

unignoreWork: {
name: "Unignore",
async execute (author_vanity: string, work_vanity: string) {
await fetch(`${Env.API_ORIGIN}unignore/work/${author_vanity}/${work_vanity}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
});
},
},

getIgnore: {
name: "Get Ignore",
async execute (type: string, vanity: string) {
Expand All @@ -302,6 +364,16 @@ export const BUTTON_REGISTRY = {
},
},

getIgnoreWork: {
name: "Get Ignore",
async execute (author_vanity: string, work_vanity: string) {
const response = await fetch(`${Env.API_ORIGIN}ignores/work/${author_vanity}/${work_vanity}`, {
credentials: "include",
}).then(response => response.json());
console.log(response);
},
},

getAllIgnores: {
name: "Get All Ignores",
async execute (type: string, page: number = 0) {
Expand Down

0 comments on commit a96c231

Please sign in to comment.