summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/api/client/accounts/accountcreate.go6
-rw-r--r--internal/api/util/errorhandling.go3
-rw-r--r--internal/cache/util.go1
-rw-r--r--internal/db/bundb/basic.go2
-rw-r--r--internal/federation/federatingdb/reject.go13
-rw-r--r--internal/gotosocial/gotosocial.go6
-rw-r--r--internal/processing/fromcommon.go6
-rw-r--r--internal/processing/fromfederator.go18
8 files changed, 15 insertions, 40 deletions
diff --git a/internal/api/client/accounts/accountcreate.go b/internal/api/client/accounts/accountcreate.go
index 6af3b41e5..5999c46c1 100644
--- a/internal/api/client/accounts/accountcreate.go
+++ b/internal/api/client/accounts/accountcreate.go
@@ -141,9 +141,5 @@ func validateCreateAccount(form *apimodel.AccountCreateRequest) error {
return err
}
- if err := validate.SignUpReason(form.Reason, config.GetAccountsReasonRequired()); err != nil {
- return err
- }
-
- return nil
+ return validate.SignUpReason(form.Reason, config.GetAccountsReasonRequired())
}
diff --git a/internal/api/util/errorhandling.go b/internal/api/util/errorhandling.go
index 8c0251e57..9128ce499 100644
--- a/internal/api/util/errorhandling.go
+++ b/internal/api/util/errorhandling.go
@@ -117,7 +117,8 @@ func ErrorHandler(c *gin.Context, errWithCode gtserror.WithCode, instanceGet fun
// or if we should just use a json. Normally we would want to
// check for a returned error, but if an error occurs here we
// can just fall back to default behavior (serve json error).
- accept, _ := NegotiateAccept(c, JSONOrHTMLAcceptHeaders...)
+ // Prefer provided offers, fall back to JSON or HTML.
+ accept, _ := NegotiateAccept(c, append(offers, JSONOrHTMLAcceptHeaders...)...)
if errWithCode.Code() == http.StatusNotFound {
// Use our special not found handler with useful status text.
diff --git a/internal/cache/util.go b/internal/cache/util.go
index 2d7badf68..a0adfd366 100644
--- a/internal/cache/util.go
+++ b/internal/cache/util.go
@@ -36,6 +36,7 @@ var SentinelError = errors.New("BUG: error should not be returned") //nolint:rev
// caches, which specifically catches and ignores our sentinel error type.
func ignoreErrors(err error) bool {
return errorsv2.Comparable(
+ err,
SentinelError,
context.DeadlineExceeded,
context.Canceled,
diff --git a/internal/db/bundb/basic.go b/internal/db/bundb/basic.go
index c7bcf4b71..6406ede35 100644
--- a/internal/db/bundb/basic.go
+++ b/internal/db/bundb/basic.go
@@ -160,7 +160,7 @@ func (b *basicDB) DropTable(ctx context.Context, i interface{}) db.Error {
}
func (b *basicDB) IsHealthy(ctx context.Context) db.Error {
- return b.conn.Ping()
+ return b.conn.PingContext(ctx)
}
func (b *basicDB) Stop(ctx context.Context) db.Error {
diff --git a/internal/federation/federatingdb/reject.go b/internal/federation/federatingdb/reject.go
index ceaee83ef..17f0f84d0 100644
--- a/internal/federation/federatingdb/reject.go
+++ b/internal/federation/federatingdb/reject.go
@@ -70,11 +70,7 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
return errors.New("Reject: follow object account and inbox account were not the same")
}
- if err := f.state.DB.RejectFollowRequest(ctx, followReq.AccountID, followReq.TargetAccountID); err != nil {
- return err
- }
-
- return nil
+ return f.state.DB.RejectFollowRequest(ctx, followReq.AccountID, followReq.TargetAccountID)
}
}
@@ -90,20 +86,19 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
if !ok {
return errors.New("Reject: couldn't parse follow into vocab.ActivityStreamsFollow")
}
+
// convert the follow to something we can understand
gtsFollow, err := f.typeConverter.ASFollowToFollow(ctx, asFollow)
if err != nil {
return fmt.Errorf("Reject: error converting asfollow to gtsfollow: %s", err)
}
+
// make sure the addressee of the original follow is the same as whatever inbox this landed in
if gtsFollow.AccountID != receivingAccount.ID {
return errors.New("Reject: follow object account and inbox account were not the same")
}
- if err := f.state.DB.RejectFollowRequest(ctx, gtsFollow.AccountID, gtsFollow.TargetAccountID); err != nil {
- return err
- }
- return nil
+ return f.state.DB.RejectFollowRequest(ctx, gtsFollow.AccountID, gtsFollow.TargetAccountID)
}
}
diff --git a/internal/gotosocial/gotosocial.go b/internal/gotosocial/gotosocial.go
index 7ce70980d..4c6846ff9 100644
--- a/internal/gotosocial/gotosocial.go
+++ b/internal/gotosocial/gotosocial.go
@@ -72,8 +72,6 @@ func (gts *gotosocial) Stop(ctx context.Context) error {
if err := gts.apiRouter.Stop(ctx); err != nil {
return err
}
- if err := gts.db.Stop(ctx); err != nil {
- return err
- }
- return nil
+
+ return gts.db.Stop(ctx)
}
diff --git a/internal/processing/fromcommon.go b/internal/processing/fromcommon.go
index 0adb576bc..03ebb1f1a 100644
--- a/internal/processing/fromcommon.go
+++ b/internal/processing/fromcommon.go
@@ -434,11 +434,7 @@ func (p *Processor) wipeStatus(ctx context.Context, statusToDelete *gtsmodel.Sta
}
// delete the status itself
- if err := p.state.DB.DeleteStatusByID(ctx, statusToDelete.ID); err != nil {
- return err
- }
-
- return nil
+ return p.state.DB.DeleteStatusByID(ctx, statusToDelete.ID)
}
// deleteStatusFromTimelines completely removes the given status from all timelines.
diff --git a/internal/processing/fromfederator.go b/internal/processing/fromfederator.go
index f91f5ae8b..17d60c77f 100644
--- a/internal/processing/fromfederator.go
+++ b/internal/processing/fromfederator.go
@@ -167,11 +167,7 @@ func (p *Processor) processCreateStatusFromFederator(ctx context.Context, federa
}
}
- if err := p.timelineAndNotifyStatus(ctx, status); err != nil {
- return err
- }
-
- return nil
+ return p.timelineAndNotifyStatus(ctx, status)
}
// processCreateFaveFromFederator handles Activity Create and Object Like
@@ -208,11 +204,7 @@ func (p *Processor) processCreateFaveFromFederator(ctx context.Context, federato
incomingFave.Account = a
}
- if err := p.notifyFave(ctx, incomingFave); err != nil {
- return err
- }
-
- return nil
+ return p.notifyFave(ctx, incomingFave)
}
// processCreateFollowRequestFromFederator handles Activity Create and Object Follow
@@ -327,11 +319,7 @@ func (p *Processor) processCreateAnnounceFromFederator(ctx context.Context, fede
return err
}
- if err := p.notifyAnnounce(ctx, incomingAnnounce); err != nil {
- return err
- }
-
- return nil
+ return p.notifyAnnounce(ctx, incomingAnnounce)
}
// processCreateBlockFromFederator handles Activity Create and Object Block