diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go index 2e872d2dbe..bcd248e21a 100644 --- a/modules/activitypub/client.go +++ b/modules/activitypub/client.go @@ -11,6 +11,7 @@ import ( "encoding/pem" "fmt" "net/http" + "strings" "time" user_model "code.gitea.io/gitea/models/user" @@ -106,7 +107,7 @@ func (c *Client) NewRequest(b []byte, to string) (req *http.Request, err error) } req.Header.Add("Content-Type", ActivityStreamsContentType) req.Header.Add("Accept-Charset", "utf-8") - req.Header.Add("Date", fmt.Sprintf("%s UTC", time.Now().UTC().Format(time.RFC1123))) + req.Header.Add("Date", strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT")) signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.postHeaders, httpsig.Signature, httpsigExpirationTime) if err != nil { diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go index 22f00c01e0..bb3b2b23e3 100644 --- a/routers/api/v1/activitypub/person.go +++ b/routers/api/v1/activitypub/person.go @@ -56,13 +56,13 @@ func Person(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "Set PreferredUsername", err) return } - + person.URL = ap.IRI(setting.AppURL + username) person.Icon = ap.Image{ - Type: ap.ImageType, + Type: ap.ImageType, MediaType: "image/png", - URL: ap.IRI(user.AvatarLink()), + URL: ap.IRI(user.AvatarLink()), } person.Inbox = nil @@ -91,12 +91,12 @@ func Person(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "Unmarshall", err) } - jsonmap["@context"] = []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"} + jsonmap["@context"] = []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"} ctx.Resp.Header().Add("Content-Type", "application/activity+json") ctx.Resp.WriteHeader(http.StatusOK) binary, _ = json.Marshal(jsonmap) - ctx.Resp.Write(binary) + _, _ = ctx.Resp.Write(binary) } // PersonInbox function diff --git a/routers/api/v1/activitypub/reqsignature.go b/routers/api/v1/activitypub/reqsignature.go index 906be714da..ffc69aa8de 100644 --- a/routers/api/v1/activitypub/reqsignature.go +++ b/routers/api/v1/activitypub/reqsignature.go @@ -13,6 +13,7 @@ import ( "io" "net/http" "net/url" + "strings" "time" "code.gitea.io/gitea/modules/activitypub" @@ -50,7 +51,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 UTC", time.Now().UTC().Format(time.RFC1123))) + req.Header("Date", strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT")) resp, err := req.Response() if err != nil { return