allow editing watchers too

This commit is contained in:
Andre Medeiros 2021-10-13 11:11:28 -04:00
parent db3268b0d0
commit 08fd2ef9a5

View file

@ -163,12 +163,7 @@ func (a *api) editWatcherHandler(w http.ResponseWriter, r *http.Request) {
} }
ewr := &createWatcherRequest{ ewr := &createWatcherRequest{
Criteria: watcherCriteria{ Criteria: watcherCriteria{},
Upvotes: 0,
Keyword: "",
Flair: "",
Domain: "",
},
} }
if err := json.NewDecoder(r.Body).Decode(ewr); err != nil { if err := json.NewDecoder(r.Body).Decode(ewr); err != nil {
@ -177,10 +172,12 @@ func (a *api) editWatcherHandler(w http.ResponseWriter, r *http.Request) {
} }
watcher.Label = ewr.Label watcher.Label = ewr.Label
watcher.Author = strings.ToLower(ewr.Criteria.Author)
watcher.Subreddit = strings.ToLower(ewr.Criteria.Subreddit)
watcher.Upvotes = ewr.Criteria.Upvotes watcher.Upvotes = ewr.Criteria.Upvotes
watcher.Keyword = ewr.Criteria.Keyword watcher.Keyword = strings.ToLower(ewr.Criteria.Keyword)
watcher.Flair = ewr.Criteria.Flair watcher.Flair = strings.ToLower(ewr.Criteria.Flair)
watcher.Domain = ewr.Criteria.Domain watcher.Domain = strings.ToLower(ewr.Criteria.Domain)
if err := a.watcherRepo.Update(ctx, &watcher); err != nil { if err := a.watcherRepo.Update(ctx, &watcher); err != nil {
a.errorResponse(w, r, 500, err.Error()) a.errorResponse(w, r, 500, err.Error())