summaryrefslogtreecommitdiff
path: root/internal/api/client/account
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/client/account')
-rw-r--r--internal/api/client/account/account_test.go2
-rw-r--r--internal/api/client/account/accountcreate.go6
-rw-r--r--internal/api/client/account/accountget.go6
-rw-r--r--internal/api/client/account/accountupdate.go9
-rw-r--r--internal/api/client/account/accountverify.go9
-rw-r--r--internal/api/client/account/block.go6
-rw-r--r--internal/api/client/account/follow.go6
-rw-r--r--internal/api/client/account/followers.go6
-rw-r--r--internal/api/client/account/following.go6
-rw-r--r--internal/api/client/account/relationships.go9
-rw-r--r--internal/api/client/account/statuses.go9
-rw-r--r--internal/api/client/account/unblock.go6
-rw-r--r--internal/api/client/account/unfollow.go9
13 files changed, 84 insertions, 5 deletions
diff --git a/internal/api/client/account/account_test.go b/internal/api/client/account/account_test.go
index f7dfa4520..b642dbcb4 100644
--- a/internal/api/client/account/account_test.go
+++ b/internal/api/client/account/account_test.go
@@ -95,5 +95,7 @@ func (suite *AccountStandardTestSuite) newContext(recorder *httptest.ResponseRec
ctx.Request.Header.Set("Content-Type", bodyContentType)
}
+ ctx.Request.Header.Set("accept", "application/json")
+
return ctx
}
diff --git a/internal/api/client/account/accountcreate.go b/internal/api/client/account/accountcreate.go
index ae9d7b0d7..7219fae94 100644
--- a/internal/api/client/account/accountcreate.go
+++ b/internal/api/client/account/accountcreate.go
@@ -27,6 +27,7 @@ import (
"github.com/spf13/viper"
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
@@ -78,6 +79,11 @@ func (m *Module) AccountCreatePOSTHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
l.Trace("parsing request form")
form := &model.AccountCreateRequest{}
if err := c.ShouldBind(form); err != nil || form == nil {
diff --git a/internal/api/client/account/accountget.go b/internal/api/client/account/accountget.go
index 8bac1360b..2bda3c0bd 100644
--- a/internal/api/client/account/accountget.go
+++ b/internal/api/client/account/accountget.go
@@ -22,6 +22,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -64,6 +65,11 @@ func (m *Module) AccountGETHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"})
diff --git a/internal/api/client/account/accountupdate.go b/internal/api/client/account/accountupdate.go
index 8534f5805..2a3882206 100644
--- a/internal/api/client/account/accountupdate.go
+++ b/internal/api/client/account/accountupdate.go
@@ -20,11 +20,13 @@ package account
import (
"fmt"
- "github.com/sirupsen/logrus"
"net/http"
"strconv"
+ "github.com/sirupsen/logrus"
+
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -110,6 +112,11 @@ func (m *Module) AccountUpdateCredentialsPATCHHandler(c *gin.Context) {
}
l.Tracef("retrieved account %+v", authed.Account.ID)
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
form, err := parseUpdateAccountForm(c)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
diff --git a/internal/api/client/account/accountverify.go b/internal/api/client/account/accountverify.go
index 6b8d1f92c..1da0251a3 100644
--- a/internal/api/client/account/accountverify.go
+++ b/internal/api/client/account/accountverify.go
@@ -19,10 +19,12 @@
package account
import (
- "github.com/sirupsen/logrus"
"net/http"
+ "github.com/sirupsen/logrus"
+
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -60,6 +62,11 @@ func (m *Module) AccountVerifyGETHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
acctSensitive, err := m.processor.AccountGet(c.Request.Context(), authed, authed.Account.ID)
if err != nil {
l.Debugf("error getting account from processor: %s", err)
diff --git a/internal/api/client/account/block.go b/internal/api/client/account/block.go
index 243f90c5e..2de754a33 100644
--- a/internal/api/client/account/block.go
+++ b/internal/api/client/account/block.go
@@ -22,6 +22,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -66,6 +67,11 @@ func (m *Module) AccountBlockPOSTHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"})
diff --git a/internal/api/client/account/follow.go b/internal/api/client/account/follow.go
index 8f3f7ad0a..afdb6d23d 100644
--- a/internal/api/client/account/follow.go
+++ b/internal/api/client/account/follow.go
@@ -22,6 +22,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -87,6 +88,11 @@ func (m *Module) AccountFollowPOSTHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"})
diff --git a/internal/api/client/account/followers.go b/internal/api/client/account/followers.go
index 4f30e9939..3ccb3d393 100644
--- a/internal/api/client/account/followers.go
+++ b/internal/api/client/account/followers.go
@@ -22,6 +22,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -68,6 +69,11 @@ func (m *Module) AccountFollowersGETHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"})
diff --git a/internal/api/client/account/following.go b/internal/api/client/account/following.go
index baac2c9d3..78ab610c8 100644
--- a/internal/api/client/account/following.go
+++ b/internal/api/client/account/following.go
@@ -22,6 +22,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -68,6 +69,11 @@ func (m *Module) AccountFollowingGETHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"})
diff --git a/internal/api/client/account/relationships.go b/internal/api/client/account/relationships.go
index bb942d18a..22ae835f0 100644
--- a/internal/api/client/account/relationships.go
+++ b/internal/api/client/account/relationships.go
@@ -1,10 +1,12 @@
package account
import (
- "github.com/sirupsen/logrus"
"net/http"
+ "github.com/sirupsen/logrus"
+
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -57,6 +59,11 @@ func (m *Module) AccountRelationshipsGETHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAccountIDs := c.QueryArray("id[]")
if len(targetAccountIDs) == 0 {
// check fallback -- let's be generous and see if maybe it's just set as 'id'?
diff --git a/internal/api/client/account/statuses.go b/internal/api/client/account/statuses.go
index 9a60e80ee..49c15987e 100644
--- a/internal/api/client/account/statuses.go
+++ b/internal/api/client/account/statuses.go
@@ -19,11 +19,13 @@
package account
import (
- "github.com/sirupsen/logrus"
"net/http"
"strconv"
+ "github.com/sirupsen/logrus"
+
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -118,6 +120,11 @@ func (m *Module) AccountStatusesGETHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
l.Debug("no account id specified in query")
diff --git a/internal/api/client/account/unblock.go b/internal/api/client/account/unblock.go
index 7b16ac887..f075d14ed 100644
--- a/internal/api/client/account/unblock.go
+++ b/internal/api/client/account/unblock.go
@@ -22,6 +22,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -66,6 +67,11 @@ func (m *Module) AccountUnblockPOSTHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no account id specified"})
diff --git a/internal/api/client/account/unfollow.go b/internal/api/client/account/unfollow.go
index b18903c8a..2ee812f5a 100644
--- a/internal/api/client/account/unfollow.go
+++ b/internal/api/client/account/unfollow.go
@@ -19,10 +19,12 @@
package account
import (
- "github.com/sirupsen/logrus"
"net/http"
+ "github.com/sirupsen/logrus"
+
"github.com/gin-gonic/gin"
+ "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
@@ -69,6 +71,11 @@ func (m *Module) AccountUnfollowPOSTHandler(c *gin.Context) {
return
}
+ if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
+ c.JSON(http.StatusNotAcceptable, gin.H{"error": err.Error()})
+ return
+ }
+
targetAcctID := c.Param(IDKey)
if targetAcctID == "" {
l.Debug(err)