Skip to content
Permalink
Browse files

Merge pull request #249 from writeas/fix-activitypub-client

Improve resource use for federation
  • Loading branch information
thebaer committed Feb 9, 2020
2 parents 859702f + bf8dcff commit ab2b8dff7f3a32e45f1ce3e890bf3cba4c0e5da6
Showing with 13 additions and 6 deletions.
  1. +13 −6 activitypub.go
@@ -65,6 +65,12 @@ func (ru *RemoteUser) AsPerson() *activitystreams.Person {
}
}

func activityPubClient() *http.Client {
return &http.Client{
Timeout: 15 * time.Second,
}
}

func handleFetchCollectionActivities(app *App, w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Server", serverSoftware)

@@ -389,6 +395,11 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request
}

go func() {
if to == nil {
log.Error("No to! %v", err)
return
}

time.Sleep(2 * time.Second)
am, err := a.Serialize()
if err != nil {
@@ -397,10 +408,6 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request
}
am["@context"] = []string{activitystreams.Namespace}

if to == nil {
log.Error("No to! %v", err)
return
}
err = makeActivityPost(app.cfg.App.Host, p, fullActor.Inbox, am)
if err != nil {
log.Error("Unable to make activity POST: %v", err)
@@ -509,7 +516,7 @@ func makeActivityPost(hostName string, p *activitystreams.Person, url string, m
}
}

resp, err := http.DefaultClient.Do(r)
resp, err := activityPubClient().Do(r)
if err != nil {
return err
}
@@ -545,7 +552,7 @@ func resolveIRI(hostName, url string) ([]byte, error) {
}
}

resp, err := http.DefaultClient.Do(r)
resp, err := activityPubClient().Do(r)
if err != nil {
return nil, err
}

0 comments on commit ab2b8df

Please sign in to comment.
You can’t perform that action at this time.