aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel0 <77419041+FChannel0@users.noreply.github.com>2022-07-29 14:30:21 +0000
committerGitHub <noreply@github.com>2022-07-29 14:30:21 +0000
commit301c160caf31d23ec53754df71c779c552bde891 (patch)
treeb916a6523f5096a423366874e55b44a92d1b036d
parent3a7664d404bca40cb3234924fa969c0ae133d085 (diff)
parent0a318777ad611e5b0080807e19d5030bbe5e8431 (diff)
Merge pull request #69 from KushBlazingJudah/masterHEADmaster
Fix fail with posting to a down instance's thread
-rw-r--r--activitypub/activity.go6
-rw-r--r--activitypub/webfinger.go21
-rw-r--r--post/util.go10
3 files changed, 23 insertions, 14 deletions
diff --git a/activitypub/activity.go b/activitypub/activity.go
index bd57778..b05de07 100644
--- a/activitypub/activity.go
+++ b/activitypub/activity.go
@@ -41,7 +41,11 @@ func (activity Activity) AddFollowersTo() (Activity, error) {
reqActivity := Activity{Id: e + "/followers"}
aFollowers, err := reqActivity.GetCollection()
if err != nil {
- return activity, util.MakeError(err, "AddFollowersTo")
+ // Safely fail so we can continue to federate
+ config.Log.Printf("failed to get collection from %s: %v", reqActivity.Id, err)
+ continue
+
+ // return activity, util.MakeError(err, "AddFollowersTo")
}
// get followers of activity actor
diff --git a/activitypub/webfinger.go b/activitypub/webfinger.go
index 8dce506..ff6111b 100644
--- a/activitypub/webfinger.go
+++ b/activitypub/webfinger.go
@@ -74,15 +74,21 @@ func FingerActor(path string) (Actor, error) {
if ActorCache[actor+"@"+instance].Id != "" {
nActor = ActorCache[actor+"@"+instance]
} else {
- resp, _ := FingerRequest(actor, instance)
+ resp, err := FingerRequest(actor, instance)
+ if err != nil {
+ return nActor, util.MakeError(err, "FingerActor finger request")
+ }
if resp != nil && resp.StatusCode == 200 {
defer resp.Body.Close()
- body, _ := ioutil.ReadAll(resp.Body)
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return nActor, util.MakeError(err, "FingerActor read resp")
+ }
if err := json.Unmarshal(body, &nActor); err != nil {
- return nActor, util.MakeError(err, "FingerActor")
+ return nActor, util.MakeError(err, "FingerActor unmarshal")
}
ActorCache[actor+"@"+instance] = nActor
@@ -104,15 +110,16 @@ func FingerRequest(actor string, instance string) (*http.Response, error) {
resp, err := util.RouteProxy(req)
if err != nil {
- return resp, nil
+ return resp, err
}
var finger Webfinger
if resp.StatusCode == 200 {
- defer resp.Body.Close()
-
- body, _ := ioutil.ReadAll(resp.Body)
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return resp, err
+ }
if err := json.Unmarshal(body, &finger); err != nil {
return resp, util.MakeError(err, "FingerRequest")
diff --git a/post/util.go b/post/util.go
index 922dd11..bb24c90 100644
--- a/post/util.go
+++ b/post/util.go
@@ -287,12 +287,10 @@ func ObjectFromForm(ctx *fiber.Ctx, obj activitypub.ObjectBase) (activitypub.Obj
if originalPost.Id != "" {
if local, _ := activity.IsLocal(); !local {
actor, err := activitypub.FingerActor(originalPost.Id)
- if err != nil {
- return obj, util.MakeError(err, "ObjectFromForm")
- }
-
- if !util.IsInStringArray(obj.To, actor.Id) {
- obj.To = append(obj.To, actor.Id)
+ if err == nil { // Keep things moving if it fails
+ if !util.IsInStringArray(obj.To, actor.Id) {
+ obj.To = append(obj.To, actor.Id)
+ }
}
} else if err != nil {
return obj, util.MakeError(err, "ObjectFromForm")