prevent moved accounts from taking create-type actions

This commit is contained in:
tobi 2024-03-09 15:59:17 +01:00
parent 1bcdf1da3b
commit 13e10875e9
42 changed files with 288 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 != "" {

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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