Make "Me" configurable in backend.json

This commit is contained in:
Peter Stuifzand 2018-05-16 19:41:05 +02:00
parent b62f719221
commit d28f0d85c2
2 changed files with 7 additions and 1 deletions

View File

@ -169,7 +169,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
if token.Me != "https://publog.stuifzandapp.com/" {
if token.Me != h.Backend.(*memoryBackend).Me {
log.Printf("Missing \"me\" in token response: %#v\n", token)
http.Error(w, "Wrong me", 403)
return

View File

@ -38,6 +38,7 @@ type memoryBackend struct {
Channels map[string]microsub.Channel
Feeds map[string][]microsub.Feed
NextUid int
Me string
ticker *time.Ticker
quit chan struct{}
@ -128,6 +129,11 @@ func createMemoryBackend() microsub.Microsub {
backend.Channels[c.UID] = c
}
backend.NextUid = 1002
backend.Me = "https://example.com/"
log.Println(`Config file "backend.json" is created in the current directory.`)
log.Println(`Update "Me" variable to your website address "https://example.com/"`)
return &backend
}