Add api method to set last follower manually

This commit is contained in:
Knut Ahlers 2020-11-23 10:04:44 +01:00
parent 33480e92c6
commit 9d3b9d5c11
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

13
api.go
View file

@ -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")