Finished basic channel ban DB mgmt and ajax calls.

This commit is contained in:
rainbow napkin 2024-11-30 06:38:38 -05:00
parent 2b52fe7f2f
commit ef79e9941c
4 changed files with 293 additions and 3 deletions

View file

@ -324,8 +324,8 @@ class canopyAjaxUtils{
}
}
async getChannelRank(channel){
var response = await fetch(`/api/channel/rank?chanName=${channel}`,{
async getChannelRank(chanName){
var response = await fetch(`/api/channel/rank?chanName=${chanName}`,{
method: "GET"
});
@ -380,6 +380,53 @@ class canopyAjaxUtils{
utils.ux.displayResponseError(await response.json());
}
}
async getChanBans(chanName){
var response = await fetch(`/api/channel/ban?chanName=${chanName}`,{
method: "GET",
headers: {
"Content-Type": "application/json"
}
});
if(response.status == 200){
return await response.json();
}else{
utils.ux.displayResponseError(await response.json());
}
}
async chanBan(chanName, user, expirationDays, banAlts){
var response = await fetch(`/api/channel/ban`,{
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({chanName, user, expirationDays, banAlts})
});
if(response.status == 200){
return await response.json();
}else{
utils.ux.displayResponseError(await response.json());
}
}
async chanUnban(chanName, user){
var response = await fetch(`/api/channel/ban`,{
method: "DELETE",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({chanName, user})
});
if(response.status == 200){
return await response.json();
}else{
utils.ux.displayResponseError(await response.json());
}
}
}
const utils = new canopyUtils()