mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user