mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 17:29:54 +01:00
More struct work
This commit is contained in:
10
ober.go
10
ober.go
@@ -64,19 +64,19 @@ func WatchGet(ctx *fasthttp.RequestCtx) {
|
||||
}
|
||||
userId = user.MalID
|
||||
}
|
||||
animes, err := ReadAnimes()
|
||||
animes, err := ReadAnimeUsers()
|
||||
if err != nil {
|
||||
// check if no anime were inserted
|
||||
if err != nutsdb.ErrBucketEmpty {
|
||||
addErrorToCtx(ctx, err)
|
||||
return
|
||||
}
|
||||
animes = make([]Anime, 0)
|
||||
animes = make([]AnimeUser, 0)
|
||||
}
|
||||
|
||||
// apply single user logic
|
||||
if usrVal != nil {
|
||||
filteredAnimes := make([]Anime, 0)
|
||||
filteredAnimes := make([]AnimeUser, 0)
|
||||
for _, a := range animes {
|
||||
for _, u := range a.Users {
|
||||
if u.MalID == userId {
|
||||
@@ -226,7 +226,7 @@ func processUpdateReq(ctx *fasthttp.RequestCtx, update bool) {
|
||||
}
|
||||
|
||||
body := ctx.PostBody()
|
||||
var animes []Anime
|
||||
var animes []AnimeUser
|
||||
err := json.Unmarshal(body, &animes)
|
||||
if err != nil || len(animes) == 0 {
|
||||
ctx.WriteString(err.Error())
|
||||
@@ -248,7 +248,7 @@ func processUpdateReq(ctx *fasthttp.RequestCtx, update bool) {
|
||||
}
|
||||
}
|
||||
|
||||
var animeData *Anime
|
||||
var animeData *AnimeUser
|
||||
// update or delete request
|
||||
if update {
|
||||
// anime exitsts => save
|
||||
|
||||
Reference in New Issue
Block a user