mirror of
https://github.com/Luzifer/twitch-manager.git
synced 2024-12-20 20:01:18 +00:00
Add api method to set last follower manually
This commit is contained in:
parent
33480e92c6
commit
9d3b9d5c11
1 changed files with 10 additions and 3 deletions
13
api.go
13
api.go
|
@ -92,13 +92,20 @@ var upgrader = websocket.Upgrader{
|
|||
}
|
||||
|
||||
func registerAPI(r *mux.Router) {
|
||||
r.HandleFunc("/api/follows/clear-last", handleClearLastFollower)
|
||||
r.HandleFunc("/api/follows/clear-last", handleSetLastFollower)
|
||||
r.HandleFunc("/api/follows/set-last/{name}", handleSetLastFollower)
|
||||
r.HandleFunc("/api/subscribe", handleUpdateSocket)
|
||||
r.HandleFunc("/api/webhook/{type}", handleWebHookPush)
|
||||
}
|
||||
|
||||
func handleClearLastFollower(w http.ResponseWriter, r *http.Request) {
|
||||
store.Followers.Last = nil
|
||||
func handleSetLastFollower(w http.ResponseWriter, r *http.Request) {
|
||||
name := mux.Vars(r)["name"]
|
||||
|
||||
if name == "" {
|
||||
store.Followers.Last = nil
|
||||
} else {
|
||||
store.Followers.Last = &name
|
||||
}
|
||||
|
||||
if err := store.Save(cfg.StoreFile); err != nil {
|
||||
log.WithError(err).Error("Unable to update persistent store")
|
||||
|
|
Loading…
Reference in a new issue