mirror of
https://github.com/writeas/writefreely
synced 2024-12-08 06:31:47 +01:00
Setting activitypub.go back to master version
This commit is contained in:
parent
9ed2687543
commit
4c0fcdf7c6
@ -397,9 +397,7 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if to == nil {
|
if to == nil {
|
||||||
if debugging {
|
log.Error("No to! %v", err)
|
||||||
log.Error("No `to` value!")
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +492,7 @@ func makeActivityPost(hostName string, p *activitystreams.Person, url string, m
|
|||||||
|
|
||||||
r, _ := http.NewRequest("POST", url, bytes.NewBuffer(b))
|
r, _ := http.NewRequest("POST", url, bytes.NewBuffer(b))
|
||||||
r.Header.Add("Content-Type", "application/activity+json")
|
r.Header.Add("Content-Type", "application/activity+json")
|
||||||
r.Header.Set("User-Agent", ServerUserAgent(hostName))
|
r.Header.Set("User-Agent", "Go ("+serverSoftware+"/"+softwareVer+"; +"+hostName+")")
|
||||||
h := sha256.New()
|
h := sha256.New()
|
||||||
h.Write(b)
|
h.Write(b)
|
||||||
r.Header.Add("Digest", "SHA-256="+base64.StdEncoding.EncodeToString(h.Sum(nil)))
|
r.Header.Add("Digest", "SHA-256="+base64.StdEncoding.EncodeToString(h.Sum(nil)))
|
||||||
@ -544,7 +542,7 @@ func resolveIRI(hostName, url string) ([]byte, error) {
|
|||||||
|
|
||||||
r, _ := http.NewRequest("GET", url, nil)
|
r, _ := http.NewRequest("GET", url, nil)
|
||||||
r.Header.Add("Accept", "application/activity+json")
|
r.Header.Add("Accept", "application/activity+json")
|
||||||
r.Header.Set("User-Agent", ServerUserAgent(hostName))
|
r.Header.Set("User-Agent", "Go ("+serverSoftware+"/"+softwareVer+"; +"+hostName+")")
|
||||||
|
|
||||||
if debugging {
|
if debugging {
|
||||||
dump, err := httputil.DumpRequestOut(r, true)
|
dump, err := httputil.DumpRequestOut(r, true)
|
||||||
@ -631,17 +629,6 @@ func federatePost(app *App, p *PublicPost, collID int64, isUpdate bool) error {
|
|||||||
log.Info("Federating new post!")
|
log.Info("Federating new post!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If app is private, do not federate
|
|
||||||
if app.cfg.App.Private {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not federate posts from private or protected blogs
|
|
||||||
if p.Collection.Visibility == CollPrivate || p.Collection.Visibility == CollProtected {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
actor := p.Collection.PersonObject(collID)
|
actor := p.Collection.PersonObject(collID)
|
||||||
na := p.ActivityObject(app)
|
na := p.ActivityObject(app)
|
||||||
|
|
||||||
@ -710,10 +697,6 @@ func federatePost(app *App, p *PublicPost, collID int64, isUpdate bool) error {
|
|||||||
// I don't believe we'd ever have too many mentions in a single post that this
|
// I don't believe we'd ever have too many mentions in a single post that this
|
||||||
// could become a burden.
|
// could become a burden.
|
||||||
remoteUser, err := getRemoteUser(app, tag.HRef)
|
remoteUser, err := getRemoteUser(app, tag.HRef)
|
||||||
if err != nil {
|
|
||||||
log.Error("Unable to find remote user %s. Skipping: %v", tag.HRef, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
err = makeActivityPost(app.cfg.App.Host, actor, remoteUser.Inbox, activity)
|
err = makeActivityPost(app.cfg.App.Host, actor, remoteUser.Inbox, activity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Couldn't post! %v", err)
|
log.Error("Couldn't post! %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user