From da8954858afb4d5a3a2faf55e77d7da3be0ea3db Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 24 Nov 2022 13:54:49 +0100 Subject: [bugfix] Prevent future statuses entering timelines (#1134) * [bugfix] Prevent future statuses entering timeline Statuses created more than 5 minutes into the future are now rejected in the visibility package. * Come on buddy --- internal/visibility/statushometimelineable.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'internal/visibility/statushometimelineable.go') diff --git a/internal/visibility/statushometimelineable.go b/internal/visibility/statushometimelineable.go index bd3c90b4d..dabb1fa4b 100644 --- a/internal/visibility/statushometimelineable.go +++ b/internal/visibility/statushometimelineable.go @@ -21,17 +21,27 @@ package visibility import ( "context" "fmt" + "time" "codeberg.org/gruf/go-kv" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/log" ) func (f *filter) StatusHometimelineable(ctx context.Context, targetStatus *gtsmodel.Status, timelineOwnerAccount *gtsmodel.Account) (bool, error) { - l := log.WithFields(kv.Fields{ + l := log.WithFields(kv.Fields{{"statusID", targetStatus.ID}}...) - {"statusID", targetStatus.ID}, - }...) + // don't timeline statuses more than 5 min in the future + maxID, err := id.NewULIDFromTime(time.Now().Add(5 * time.Minute)) + if err != nil { + return false, err + } + + if targetStatus.ID > maxID { + l.Debug("status not hometimelineable because it's from more than 5 minutes in the future") + return false, nil + } // status owner should always be able to see their own status in their timeline so we can return early if this is the case if targetStatus.AccountID == timelineOwnerAccount.ID { -- cgit v1.2.3