aboutsummaryrefslogtreecommitdiff
path: root/modules/activitypub/send.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/activitypub/send.go')
-rw-r--r--modules/activitypub/send.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/modules/activitypub/send.go b/modules/activitypub/send.go
index cf65660e2..96b64d205 100644
--- a/modules/activitypub/send.go
+++ b/modules/activitypub/send.go
@@ -9,8 +9,6 @@ import (
"io"
"net/http"
"net/url"
- "strings"
- "time"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/httplib"
@@ -24,8 +22,7 @@ import (
func Fetch(iri *url.URL) (b []byte, err error) {
req := httplib.NewRequest(iri.String(), http.MethodGet)
req.Header("Accept", ActivityStreamsContentType)
- req.Header("Accept-Charset", "utf-8")
- req.Header("Date", strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT"))
+ req.Header("User-Agent", "Gitea/"+setting.AppVer)
resp, err := req.Response()
if err != nil {
return
@@ -36,7 +33,7 @@ func Fetch(iri *url.URL) (b []byte, err error) {
err = fmt.Errorf("url IRI fetch [%s] failed with status (%d): %s", iri, resp.StatusCode, resp.Status)
return
}
- b, err = io.ReadAll(resp.Body)
+ b, err = io.ReadAll(io.LimitReader(resp.Body, setting.Federation.MaxSize))
return
}
@@ -56,7 +53,7 @@ func Send(user *user_model.User, activity *ap.Activity) {
for _, to := range activity.To {
client, _ := NewClient(user, setting.AppURL+"api/v1/activitypub/user/"+user.Name+"#main-key")
resp, _ := client.Post(body, to.GetID().String())
- respBody, _ := io.ReadAll(resp.Body)
+ respBody, _ := io.ReadAll(io.LimitReader(resp.Body, setting.Federation.MaxSize))
log.Debug(string(respBody))
}
}