mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Code cleanup
This commit is contained in:
		@@ -32,8 +32,6 @@ func TestActivityPubPerson(t *testing.T) {
 | 
				
			|||||||
		resp := MakeRequest(t, req, http.StatusOK)
 | 
							resp := MakeRequest(t, req, http.StatusOK)
 | 
				
			||||||
		body := resp.Body.Bytes()
 | 
							body := resp.Body.Bytes()
 | 
				
			||||||
		assert.Contains(t, string(body), "@context")
 | 
							assert.Contains(t, string(body), "@context")
 | 
				
			||||||
		var m map[string]interface{}
 | 
					 | 
				
			||||||
		DecodeJSON(t, resp, &m)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		var person ap.Person
 | 
							var person ap.Person
 | 
				
			||||||
		err := person.UnmarshalJSON(body)
 | 
							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()))
 | 
						person := ap.PersonNew(ap.IRI(keyID.String()))
 | 
				
			||||||
	err = person.UnmarshalJSON(b)
 | 
						err = person.UnmarshalJSON(b)
 | 
				
			||||||
	if err != nil {
 | 
						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
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pkey := person.PublicKey
 | 
						pkey := person.PublicKey
 | 
				
			||||||
@@ -50,7 +50,7 @@ func fetch(iri *url.URL) (b []byte, err error) {
 | 
				
			|||||||
	req := httplib.NewRequest(iri.String(), http.MethodGet)
 | 
						req := httplib.NewRequest(iri.String(), http.MethodGet)
 | 
				
			||||||
	req.Header("Accept", activitypub.ActivityStreamsContentType)
 | 
						req.Header("Accept", activitypub.ActivityStreamsContentType)
 | 
				
			||||||
	req.Header("Accept-Charset", "utf-8")
 | 
						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()
 | 
						resp, err := req.Response()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
@@ -89,7 +89,7 @@ func verifyHTTPSignatures(ctx *gitea_context.APIContext) (authenticated bool, er
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	// 3. Verify the other actor's key
 | 
						// 3. Verify the other actor's key
 | 
				
			||||||
	algo := httpsig.Algorithm(setting.Federation.Algorithms[0])
 | 
						algo := httpsig.Algorithm(setting.Federation.Algorithms[0])
 | 
				
			||||||
	authenticated = nil == v.Verify(pKey, algo)
 | 
						authenticated = v.Verify(pKey, algo) == nil
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -645,8 +645,10 @@ func Routes() *web.Route {
 | 
				
			|||||||
		if setting.Federation.Enabled {
 | 
							if setting.Federation.Enabled {
 | 
				
			||||||
			m.Get("/nodeinfo", misc.NodeInfo)
 | 
								m.Get("/nodeinfo", misc.NodeInfo)
 | 
				
			||||||
			m.Group("/activitypub", func() {
 | 
								m.Group("/activitypub", func() {
 | 
				
			||||||
				m.Get("/user/{username}", activitypub.Person)
 | 
									m.Group("/user/{username}", func() {
 | 
				
			||||||
				m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInbox)
 | 
										m.Get("", activitypub.Person)
 | 
				
			||||||
 | 
										m.Post("/inbox", activitypub.ReqSignature(), activitypub.PersonInbox)
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		m.Get("/signing-key.gpg", misc.SigningKey)
 | 
							m.Get("/signing-key.gpg", misc.SigningKey)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user