Log inbox to file
This commit is contained in:
parent
b284e4e922
commit
eac57a4d40
21
http.go
21
http.go
|
@ -7,6 +7,7 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"willnorris.com/go/webmention"
|
||||
)
|
||||
|
@ -50,13 +51,21 @@ func Serve() {
|
|||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
actor := actors[mux.Vars(r)["actor"]]
|
||||
if actor == nil {
|
||||
// actor doesn't exist
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
f, err := os.OpenFile(storage+slash+"actors"+slash+actor.Name+slash+"inbox", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer func() { _ = f.Close() }()
|
||||
_, _ = f.Write(b)
|
||||
_, _ = f.WriteString("\n---\n")
|
||||
if activity["type"] == "Follow" {
|
||||
actor := actors[mux.Vars(r)["actor"]]
|
||||
// error out if this actor does not exist
|
||||
if actor == nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
actor.Accept(activity)
|
||||
} else if activity["type"] == "Undo" {
|
||||
// TODO: Implement unfollow
|
||||
|
|
Reference in New Issue