Kaynağa Gözat

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

Improve resource use for federation
pull/262/head
Matt Baer 4 yıl önce
committed by GitHub
ebeveyn
işleme
ab2b8dff7f
Veri tabanında bu imza için bilinen anahtar bulunamadı GPG Anahtar Kimliği: 4AEE18F83AFDEB23
1 değiştirilmiş dosya ile 13 ekleme ve 6 silme
  1. +13
    -6
      activitypub.go

+ 13
- 6
activitypub.go Dosyayı Görüntüle

@@ -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
}


Yükleniyor…
İptal
Kaydet