This commit is contained in:
Dot-Rar 2020-06-12 19:05:27 +01:00
parent e508294e81
commit 7c1b4193cf
4 changed files with 38 additions and 3 deletions

View File

@ -0,0 +1,24 @@
package api
import (
"github.com/TicketsBot/GoPanel/database"
"github.com/gin-gonic/gin"
)
func WhitelabelGetErrors(ctx *gin.Context) {
userId := ctx.Keys["userid"].(uint64)
errors, err := database.Client.WhitelabelErrors.GetRecent(userId, 10)
if err != nil {
ctx.JSON(500, gin.H{
"success": false,
"error": err.Error(),
})
return
}
ctx.JSON(200, gin.H{
"success": true,
"errors": errors,
})
}

View File

@ -114,6 +114,7 @@ func StartServer() {
userGroup.GET("/guilds", api.GetGuilds)
userGroup.GET("/whitelabel", api.WhitelabelGet)
userGroup.GET("/whitelabel/errors", api.WhitelabelGetErrors)
userGroup.Group("/").Use(createLimiter(10, time.Minute)).POST("/whitelabel", api.WhitelabelPost)
userGroup.Group("/").Use(createLimiter(1, time.Second * 5)).POST("/whitelabel/status", api.WhitelabelStatusPost)

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20200425115930-0ca198cc8306
github.com/TicketsBot/common v0.0.0-20200529141045-7426ad13f1a4
github.com/TicketsBot/database v0.0.0-20200612175645-63696c6f8675
github.com/TicketsBot/database v0.0.0-20200612180221-a26ff96874ea
github.com/apex/log v1.1.2
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible

View File

@ -151,7 +151,7 @@
showToast('Success', 'Updated status successfully')
}
async function loadDetails() {
async function loadStatus() {
const res = await axios.get('/user/whitelabel');
if (res.status !== 200 || !res.data.success) {
showToast('Error', res.data.error);
@ -160,6 +160,16 @@
// set status
document.getElementById('status').value = res.data.status;
}
loadStatus();
async function loadErrors() {
const res = await axios.get('/user/whitelabel/errors');
if (res.status !== 200 || !res.data.success) {
showToast('Error', res.data.error);
return;
}
// append errors
for (error of res.data.errors) {
@ -169,6 +179,6 @@
}
}
loadDetails();
loadErrors();
</script>
{{end}}