mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-06-12 10:19:23 +00:00
prevent moved accounts from taking create-type actions
This commit is contained in:
parent
1bcdf1da3b
commit
13e10875e9
|
@ -97,6 +97,12 @@ func (m *Module) AccountFollowPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package accounts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -72,6 +73,14 @@ func (m *Module) AccountLookupGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
// For moving/moved accounts, just return
|
||||
// empty to avoid breaking client apps.
|
||||
const text = "no results"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotFound(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package accounts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -81,6 +82,12 @@ func (m *Module) AccountNotePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -113,6 +113,13 @@ func (m *Module) AccountSearchGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
// For moving/moved accounts, just return
|
||||
// empty to avoid breaking client apps.
|
||||
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -148,6 +148,13 @@ func (m *Module) AccountStatusesGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() && targetAcctID != authed.Account.ID {
|
||||
// For moving/moved accounts, allow the
|
||||
// account to view its own statuses only.
|
||||
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
|
||||
return
|
||||
}
|
||||
|
||||
limit := 30
|
||||
limitString := c.Query(LimitKey)
|
||||
if limitString != "" {
|
||||
|
|
|
@ -99,6 +99,12 @@ func (m *Module) AccountActionPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
form := &apimodel.AdminActionRequest{}
|
||||
if err := c.ShouldBind(form); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1)
|
||||
|
|
|
@ -107,6 +107,12 @@ func (m *Module) DomainKeysExpirePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -75,6 +75,12 @@ func (m *Module) createDomainPermissions(
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
@ -178,6 +184,12 @@ func (m *Module) deleteDomainPermission(
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/mail"
|
||||
|
@ -93,6 +94,12 @@ func (m *Module) EmailTestPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -110,6 +110,12 @@ func (m *Module) EmojiCreatePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -87,6 +87,12 @@ func (m *Module) EmojiDELETEHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -137,6 +137,12 @@ func (m *Module) EmojiPATCHHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -114,6 +114,12 @@ func (m *Module) createHeaderFilter(c *gin.Context, create func(context.Context,
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
errWithCode := gtserror.NewErrorNotAcceptable(err, err.Error())
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
|
@ -157,6 +163,12 @@ func (m *Module) deleteHeaderFilter(c *gin.Context, delete func(context.Context,
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
filterID, errWithCode := apiutil.ParseID(c.Param("ID"))
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
@ -81,6 +82,12 @@ func (m *Module) MediaCleanupPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
form := &apimodel.MediaCleanupRequest{}
|
||||
if err := c.ShouldBind(form); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
@ -83,6 +84,12 @@ func (m *Module) MediaRefetchPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if errWithCode := m.processor.Admin().MediaRefetch(c.Request.Context(), authed.Account, c.Query(DomainQueryKey)); errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -97,6 +97,12 @@ func (m *Module) ReportResolvePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -77,6 +77,12 @@ func (m *Module) RulePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -85,6 +85,12 @@ func (m *Module) RuleDELETEHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -77,6 +77,12 @@ func (m *Module) RulePATCHHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -131,6 +132,12 @@ func (m *Module) FilterPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -137,6 +138,12 @@ func (m *Module) FilterPUTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -75,6 +75,12 @@ func (m *Module) FollowRequestAuthorizePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -144,6 +144,12 @@ func (m *Module) InstanceUpdatePATCHHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
form := &apimodel.InstanceSettingsUpdateRequest{}
|
||||
if err := c.ShouldBind(&form); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1)
|
||||
|
|
|
@ -87,6 +87,12 @@ func (m *Module) ListAccountsPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package lists
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
|
@ -74,6 +75,12 @@ func (m *Module) ListCreatePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -104,6 +104,12 @@ func (m *Module) ListUpdatePUTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -108,6 +108,12 @@ func (m *Module) MediaCreatePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -112,6 +112,12 @@ func (m *Module) MediaPUTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package polls
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -87,6 +88,12 @@ func (m *Module) PollVotePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
errWithCode := gtserror.NewErrorNotAcceptable(err, err.Error())
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
|
|
|
@ -72,6 +72,12 @@ func (m *Module) ReportPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -175,6 +175,18 @@ func (m *Module) SearchGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
// For moving/moved accounts, just return
|
||||
// empty to avoid breaking client apps.
|
||||
results := &apimodel.SearchResult{
|
||||
Accounts: make([]*apimodel.Account, 0),
|
||||
Statuses: make([]*apimodel.Status, 0),
|
||||
Hashtags: make([]any, 0),
|
||||
}
|
||||
apiutil.JSON(c, http.StatusOK, results)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -75,6 +75,12 @@ func (m *Module) StatusBookmarkPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -78,6 +78,12 @@ func (m *Module) StatusBoostPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -218,6 +218,12 @@ func (m *Module) StatusCreatePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -74,6 +74,12 @@ func (m *Module) StatusFavePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package statuses
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -78,6 +79,12 @@ func (m *Module) StatusMutePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -80,6 +80,12 @@ func (m *Module) StatusPinPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
const text = "your account has Moved or is currently Moving; you cannot take create or update type actions"
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(errors.New(text), text), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -19,6 +19,7 @@ package streaming
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
|
@ -185,6 +186,12 @@ func (m *Module) StreamGETHandler(c *gin.Context) {
|
|||
account = authed.Account
|
||||
}
|
||||
|
||||
if account.IsMoving() {
|
||||
err := errors.New("your account has Moved or is currently Moving; you cannot take create or update type actions")
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorForbidden(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
// Get the initial requested stream type, if there is one.
|
||||
streamType := c.Query(StreamQueryKey)
|
||||
|
||||
|
|
|
@ -113,6 +113,13 @@ func (m *Module) HomeTimelineGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
// For moving/moved accounts, just return
|
||||
// empty to avoid breaking client apps.
|
||||
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -112,6 +112,13 @@ func (m *Module) ListTimelineGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
// For moving/moved accounts, just return
|
||||
// empty to avoid breaking client apps.
|
||||
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
@ -117,6 +117,12 @@ func (m *Module) PublicTimelineGETHandler(c *gin.Context) {
|
|||
authed, err = oauth.Authed(c, false, false, false, false)
|
||||
} else {
|
||||
authed, err = oauth.Authed(c, true, true, true, true)
|
||||
if authed.Account.IsMoving() {
|
||||
// For moving/moved accounts, just return
|
||||
// empty to avoid breaking client apps.
|
||||
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -114,6 +114,13 @@ func (m *Module) TagTimelineGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if authed.Account.IsMoving() {
|
||||
// For moving/moved accounts, just return
|
||||
// empty to avoid breaking client apps.
|
||||
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue