Code cleanup
This commit is contained in:
parent
7658649d61
commit
6074222377
|
@ -32,8 +32,6 @@ func TestActivityPubPerson(t *testing.T) {
|
|||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
body := resp.Body.Bytes()
|
||||
assert.Contains(t, string(body), "@context")
|
||||
var m map[string]interface{}
|
||||
DecodeJSON(t, resp, &m)
|
||||
|
||||
var person ap.Person
|
||||
err := person.UnmarshalJSON(body)
|
||||
|
|
|
@ -28,7 +28,7 @@ func getPublicKeyFromResponse(ctx context.Context, b []byte, keyID *url.URL) (p
|
|||
person := ap.PersonNew(ap.IRI(keyID.String()))
|
||||
err = person.UnmarshalJSON(b)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %T", b)
|
||||
err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %v", err)
|
||||
return
|
||||
}
|
||||
pkey := person.PublicKey
|
||||
|
@ -50,7 +50,7 @@ func fetch(iri *url.URL) (b []byte, err error) {
|
|||
req := httplib.NewRequest(iri.String(), http.MethodGet)
|
||||
req.Header("Accept", activitypub.ActivityStreamsContentType)
|
||||
req.Header("Accept-Charset", "utf-8")
|
||||
req.Header("Date", fmt.Sprintf("%s GMT", time.Now().UTC().Format(time.RFC1123)))
|
||||
req.Header("Date", fmt.Sprintf("%s UTC", time.Now().UTC().Format(time.RFC1123)))
|
||||
resp, err := req.Response()
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -89,7 +89,7 @@ func verifyHTTPSignatures(ctx *gitea_context.APIContext) (authenticated bool, er
|
|||
}
|
||||
// 3. Verify the other actor's key
|
||||
algo := httpsig.Algorithm(setting.Federation.Algorithms[0])
|
||||
authenticated = nil == v.Verify(pKey, algo)
|
||||
authenticated = v.Verify(pKey, algo) == nil
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -645,8 +645,10 @@ func Routes() *web.Route {
|
|||
if setting.Federation.Enabled {
|
||||
m.Get("/nodeinfo", misc.NodeInfo)
|
||||
m.Group("/activitypub", func() {
|
||||
m.Get("/user/{username}", activitypub.Person)
|
||||
m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInbox)
|
||||
m.Group("/user/{username}", func() {
|
||||
m.Get("", activitypub.Person)
|
||||
m.Post("/inbox", activitypub.ReqSignature(), activitypub.PersonInbox)
|
||||
})
|
||||
})
|
||||
}
|
||||
m.Get("/signing-key.gpg", misc.SigningKey)
|
||||
|
|
Loading…
Reference in New Issue