Add support for default actor name for webfinger
This commit is contained in:
parent
057a9df07a
commit
0db4c4f6b6
9
http.go
9
http.go
|
@ -46,8 +46,11 @@ func Serve() {
|
|||
re := regexp.MustCompile(`^acct:(.*)@` + regexp.QuoteMeta(urlBaseUrl.Host) + `$`)
|
||||
name = re.ReplaceAllString(name, "$1")
|
||||
actor := actors[name]
|
||||
// error out if this actor does not exist
|
||||
if actor == nil {
|
||||
if actor == nil && len(defaultActor) > 0 {
|
||||
// return default actor
|
||||
actor = actors[defaultActor]
|
||||
} else if actor == nil {
|
||||
// error out if this actor does not exist
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
@ -169,4 +172,4 @@ func sendWebmention(client *webmention.Client, actor *Actor, mentioningLink, men
|
|||
return
|
||||
}
|
||||
log.Println("Sent webmention to " + mentionedLink)
|
||||
}
|
||||
}
|
||||
|
|
9
setup.go
9
setup.go
|
@ -10,6 +10,7 @@ var slash = string(os.PathSeparator)
|
|||
var baseURL string
|
||||
var storage = "storage"
|
||||
var actors = make(map[string]*Actor)
|
||||
var defaultActor = ""
|
||||
|
||||
const libName = "jsonpub"
|
||||
const version = "0.0.1"
|
||||
|
@ -66,4 +67,10 @@ func SetupActors() {
|
|||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
defaultName := os.Getenv("DEFAULT_NAME")
|
||||
if len(defaultName) < 1 {
|
||||
fmt.Printf("DEFAULT_NAME not configured")
|
||||
} else {
|
||||
defaultActor = defaultName
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue