mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-30 03:14:29 +01:00 
			
		
		
		
	Cleanup, handle invalid usernames for ActivityPub person GET request
Signed-off-by: Anthony Wang <ta180m@pm.me>
This commit is contained in:
		
							parent
							
								
									ebef769703
								
							
						
					
					
						commit
						46973f99fa
					
				| @ -35,6 +35,9 @@ func Person(ctx *context.APIContext) { | |||||||
| 	//     "$ref": "#/responses/ActivityPub" | 	//     "$ref": "#/responses/ActivityPub" | ||||||
| 
 | 
 | ||||||
| 	user := user.GetUserByParamsName(ctx, "username") | 	user := user.GetUserByParamsName(ctx, "username") | ||||||
|  | 	if user == nil { | ||||||
|  | 	    return | ||||||
|  | 	} | ||||||
| 	username := ctx.Params("username") | 	username := ctx.Params("username") | ||||||
| 
 | 
 | ||||||
| 	person := streams.NewActivityStreamsPerson() | 	person := streams.NewActivityStreamsPerson() | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ import ( | |||||||
| 	"io" | 	"io" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/url" | 	"net/url" | ||||||
|  | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"code.gitea.io/gitea/modules/activitypub" | 	"code.gitea.io/gitea/modules/activitypub" | ||||||
| 	gitea_context "code.gitea.io/gitea/modules/context" | 	gitea_context "code.gitea.io/gitea/modules/context" | ||||||
| @ -99,7 +100,7 @@ func fetch(iri *url.URL) (b []byte, err error) { | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	req.Header.Add("Date", fmt.Sprintf("%s GMT", clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05"))) | 	req.Header.Add("Date", fmt.Sprintf("%s GMT", clock.Now().UTC().Format(time.RFC1123))) | ||||||
| 	var resp *http.Response | 	var resp *http.Response | ||||||
| 	client := &http.Client{} | 	client := &http.Client{} | ||||||
| 	resp, err = client.Do(req) | 	resp, err = client.Do(req) | ||||||
|  | |||||||
| @ -599,9 +599,7 @@ func Routes(sessioner func(http.Handler) http.Handler) *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.Group("/user/{username}", func() { | 				m.Get("/user/{username}", activitypub.Person) | ||||||
| 					m.Get("", activitypub.Person) |  | ||||||
| 				}) |  | ||||||
| 				m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInbox) | 				m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInbox) | ||||||
| 			}) | 			}) | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user