mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 17:29:54 +01:00
Improve chat endpoints
This commit is contained in:
20
ober.go
20
ober.go
@@ -155,11 +155,20 @@ func ChatGet(ctx *fasthttp.RequestCtx) {
|
||||
ctx.SetStatusCode(fasthttp.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
found, err := CheckAnimeExistInDb(animeId)
|
||||
if err != nil {
|
||||
addErrorToCtx(ctx, err)
|
||||
return
|
||||
}
|
||||
if !found {
|
||||
ctx.SetStatusCode(fasthttp.StatusNotFound)
|
||||
return
|
||||
}
|
||||
text, err := ReadChat(animeId)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "not found") {
|
||||
ctx.WriteString(err.Error())
|
||||
ctx.SetStatusCode(fasthttp.StatusNotFound)
|
||||
ctx.SetStatusCode(fasthttp.StatusNoContent)
|
||||
return
|
||||
}
|
||||
addErrorToCtx(ctx, err)
|
||||
@@ -367,6 +376,15 @@ func ChatPost(ctx *fasthttp.RequestCtx) {
|
||||
ctx.SetStatusCode(fasthttp.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
found, err := CheckAnimeExistInDb(animeId)
|
||||
if err != nil {
|
||||
addErrorToCtx(ctx, err)
|
||||
return
|
||||
}
|
||||
if !found {
|
||||
ctx.SetStatusCode(fasthttp.StatusNotFound)
|
||||
return
|
||||
}
|
||||
sent := strings.TrimSpace(string(ctx.PostBody()))
|
||||
if sent == "" {
|
||||
ctx.SetStatusCode(fasthttp.StatusBadRequest)
|
||||
|
||||
Reference in New Issue
Block a user