Various improvements
This commit is contained in:
parent
ffadbe80c8
commit
26c021287a
15
actor.go
15
actor.go
|
@ -133,7 +133,7 @@ func (a *Actor) PostArticle(url string) error {
|
|||
if err != nil {
|
||||
return errors.New("failed to decode fetched article")
|
||||
}
|
||||
create["object"] = article
|
||||
create["object"] = url
|
||||
a.sendToFollowers(create)
|
||||
// Boost article if it contains "inReplyTo"
|
||||
if article["inReplyTo"] != nil {
|
||||
|
@ -178,13 +178,13 @@ func (a *Actor) signedHTTPPost(content map[string]interface{}, to string) (err e
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.postSignMutex.Lock()
|
||||
req.Header.Add("Accept-Charset", "utf-8")
|
||||
req.Header.Add("Date", time.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")+" GMT")
|
||||
req.Header.Add("User-Agent", fmt.Sprintf("%s %s", libName, version))
|
||||
req.Header.Add("Host", iri.Host)
|
||||
req.Header.Add("Accept", "application/activity+json; charset=utf-8")
|
||||
req.Header.Add("Content-Type", "application/activity+json; charset=utf-8")
|
||||
a.postSignMutex.Lock()
|
||||
err = a.postSigner.SignRequest(a.privateKey, a.publicKeyID, req, byteCopy)
|
||||
a.postSignMutex.Unlock()
|
||||
if err != nil {
|
||||
|
@ -217,14 +217,9 @@ func (a *Actor) RemoveFollower(iri string) error {
|
|||
|
||||
// send to followers sends a batch of http posts to each one of the followers
|
||||
func (a *Actor) sendToFollowers(activity map[string]interface{}) {
|
||||
recipients := make([]string, len(a.followers))
|
||||
i := 0
|
||||
for _, inbox := range a.followers {
|
||||
recipients[i] = inbox.(string)
|
||||
i++
|
||||
}
|
||||
for _, v := range recipients {
|
||||
_ = a.signedHTTPPost(activity, v)
|
||||
for _, follower := range a.followers {
|
||||
inbox := follower.(string)
|
||||
go func() { _ = a.signedHTTPPost(activity, inbox) }()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Reference in New Issue