diff options
Diffstat (limited to 'internal/api/client/account/unfollow.go')
-rw-r--r-- | internal/api/client/account/unfollow.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/internal/api/client/account/unfollow.go b/internal/api/client/account/unfollow.go index e681e2773..d92278f95 100644 --- a/internal/api/client/account/unfollow.go +++ b/internal/api/client/account/unfollow.go @@ -19,12 +19,12 @@ package account import ( + "errors" "net/http" - "github.com/sirupsen/logrus" - "github.com/gin-gonic/gin" "github.com/superseriousbusiness/gotosocial/internal/api" + "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/oauth" ) @@ -56,37 +56,38 @@ import ( // description: Your relationship to this account. // schema: // "$ref": "#/definitions/accountRelationship" -// '401': -// description: unauthorized // '400': // description: bad request +// '401': +// description: unauthorized // '404': // description: not found +// '406': +// description: not acceptable +// '500': +// description: internal server error func (m *Module) AccountUnfollowPOSTHandler(c *gin.Context) { - l := logrus.WithField("func", "AccountUnfollowPOSTHandler") authed, err := oauth.Authed(c, true, true, true, true) if err != nil { - l.Debug(err) - c.JSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"}) + api.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGet) return } if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil { - c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()}) + api.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGet) return } targetAcctID := c.Param(IDKey) if targetAcctID == "" { - l.Debug(err) - c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"}) + err := errors.New("no account id specified") + api.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGet) return } relationship, errWithCode := m.processor.AccountFollowRemove(c.Request.Context(), authed, targetAcctID) if errWithCode != nil { - l.Debug(errWithCode.Error()) - c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()}) + api.ErrorHandler(c, errWithCode, m.processor.InstanceGet) return } |