diff options
author | 2022-11-24 13:54:49 +0100 | |
---|---|---|
committer | 2022-11-24 13:54:49 +0100 | |
commit | da8954858afb4d5a3a2faf55e77d7da3be0ea3db (patch) | |
tree | e81046ed4a4a00a9c5969115e151002deab67613 /internal/visibility/statushometimelineable.go | |
parent | [chore] cleanup storage implementation, no need for multiple interface types ... (diff) | |
download | gotosocial-da8954858afb4d5a3a2faf55e77d7da3be0ea3db.tar.xz |
[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
Diffstat (limited to 'internal/visibility/statushometimelineable.go')
-rw-r--r-- | internal/visibility/statushometimelineable.go | 16 |
1 files changed, 13 insertions, 3 deletions
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 { |