mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-04-16 14:24:06 +00:00
remove mention.UpdatedAt, fixes related to NewULIDFromTime() change
This commit is contained in:
parent
a449781152
commit
80cc0b165c
10 changed files with 22 additions and 66 deletions
internal
testrig
1
internal/cache/size.go
vendored
1
internal/cache/size.go
vendored
|
@ -532,7 +532,6 @@ func sizeofMention() uintptr {
|
|||
ID: exampleURI,
|
||||
StatusID: exampleURI,
|
||||
CreatedAt: exampleTime,
|
||||
UpdatedAt: exampleTime,
|
||||
OriginAccountID: exampleURI,
|
||||
OriginAccountURI: exampleURI,
|
||||
TargetAccountID: exampleID,
|
||||
|
|
|
@ -59,11 +59,7 @@ func (suite *InteractionTestSuite) markInteractionsPending(
|
|||
|
||||
// Put an interaction request
|
||||
// in the DB for this reply.
|
||||
req, err := typeutils.StatusToInteractionRequest(ctx, reply)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
req := typeutils.StatusToInteractionRequest(reply)
|
||||
if err := suite.state.DB.PutInteractionRequest(ctx, req); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
@ -90,11 +86,7 @@ func (suite *InteractionTestSuite) markInteractionsPending(
|
|||
|
||||
// Put an interaction request
|
||||
// in the DB for this boost.
|
||||
req, err := typeutils.StatusToInteractionRequest(ctx, boost)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
req := typeutils.StatusToInteractionRequest(boost)
|
||||
if err := suite.state.DB.PutInteractionRequest(ctx, req); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
@ -121,11 +113,7 @@ func (suite *InteractionTestSuite) markInteractionsPending(
|
|||
|
||||
// Put an interaction request
|
||||
// in the DB for this fave.
|
||||
req, err := typeutils.StatusFaveToInteractionRequest(ctx, fave)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
req := typeutils.StatusFaveToInteractionRequest(fave)
|
||||
if err := suite.state.DB.PutInteractionRequest(ctx, req); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
|
|
@ -93,11 +93,7 @@ func init() {
|
|||
// For each currently pending status, check whether it's a reply or
|
||||
// a boost, and insert a corresponding interaction request into the db.
|
||||
for _, pendingStatus := range pendingStatuses {
|
||||
req, err := typeutils.StatusToInteractionRequest(ctx, pendingStatus)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req := typeutils.StatusToInteractionRequest(pendingStatus)
|
||||
if _, err := tx.
|
||||
NewInsert().
|
||||
Model(req).
|
||||
|
@ -125,10 +121,7 @@ func init() {
|
|||
}
|
||||
|
||||
for _, pendingFave := range pendingFaves {
|
||||
req, err := typeutils.StatusFaveToInteractionRequest(ctx, pendingFave)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req := typeutils.StatusFaveToInteractionRequest(pendingFave)
|
||||
|
||||
if _, err := tx.
|
||||
NewInsert().
|
||||
|
|
|
@ -123,13 +123,8 @@ func (t *timelineDB) GetHomeTimeline(ctx context.Context, accountID string, maxI
|
|||
if maxID == "" || maxID >= id.Highest {
|
||||
const future = 24 * time.Hour
|
||||
|
||||
var err error
|
||||
|
||||
// don't return statuses more than 24hr in the future
|
||||
maxID, err = id.NewULIDFromTime(time.Now().Add(future))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
maxID = id.NewULIDFromTime(time.Now().Add(future))
|
||||
}
|
||||
|
||||
// return only statuses LOWER (ie., older) than maxID
|
||||
|
@ -223,13 +218,8 @@ func (t *timelineDB) GetPublicTimeline(ctx context.Context, maxID string, sinceI
|
|||
if maxID == "" || maxID >= id.Highest {
|
||||
const future = 24 * time.Hour
|
||||
|
||||
var err error
|
||||
|
||||
// don't return statuses more than 24hr in the future
|
||||
maxID, err = id.NewULIDFromTime(time.Now().Add(future))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
maxID = id.NewULIDFromTime(time.Now().Add(future))
|
||||
}
|
||||
|
||||
// return only statuses LOWER (ie., older) than maxID
|
||||
|
@ -409,13 +399,8 @@ func (t *timelineDB) GetListTimeline(
|
|||
if maxID == "" || maxID >= id.Highest {
|
||||
const future = 24 * time.Hour
|
||||
|
||||
var err error
|
||||
|
||||
// don't return statuses more than 24hr in the future
|
||||
maxID, err = id.NewULIDFromTime(time.Now().Add(future))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
maxID = id.NewULIDFromTime(time.Now().Add(future))
|
||||
}
|
||||
|
||||
// return only statuses LOWER (ie., older) than maxID
|
||||
|
@ -508,13 +493,8 @@ func (t *timelineDB) GetTagTimeline(
|
|||
if maxID == "" || maxID >= id.Highest {
|
||||
const future = 24 * time.Hour
|
||||
|
||||
var err error
|
||||
|
||||
// don't return statuses more than 24hr in the future
|
||||
maxID, err = id.NewULIDFromTime(time.Now().Add(future))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
maxID = id.NewULIDFromTime(time.Now().Add(future))
|
||||
}
|
||||
|
||||
// return only statuses LOWER (ie., older) than maxID
|
||||
|
|
|
@ -37,10 +37,7 @@ type TimelineTestSuite struct {
|
|||
|
||||
func getFutureStatus() *gtsmodel.Status {
|
||||
theDistantFuture := time.Now().Add(876600 * time.Hour)
|
||||
id, err := id.NewULIDFromTime(theDistantFuture)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
id := id.NewULIDFromTime(theDistantFuture)
|
||||
|
||||
return >smodel.Status{
|
||||
ID: id,
|
||||
|
|
|
@ -627,7 +627,6 @@ func (d *Dereferencer) fetchStatusMentions(
|
|||
|
||||
// Set known further mention details.
|
||||
mention.CreatedAt = status.UpdatedAt
|
||||
mention.UpdatedAt = status.UpdatedAt
|
||||
mention.OriginAccount = status.Account
|
||||
mention.OriginAccountID = status.AccountID
|
||||
mention.OriginAccountURI = status.AccountURI
|
||||
|
|
|
@ -79,7 +79,7 @@ func (suite *AnnounceTestSuite) TestAnnounceTwice() {
|
|||
|
||||
// Insert the boost-of status into the
|
||||
// DB cache to emulate processor handling
|
||||
boost.ID, _ = id.NewULIDFromTime(boost.CreatedAt)
|
||||
boost.ID = id.NewULIDFromTime(boost.CreatedAt)
|
||||
suite.state.Caches.DB.Status.Put(boost)
|
||||
|
||||
// only the URI will be set for the boosted status
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
type Mention struct {
|
||||
ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
|
||||
CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created
|
||||
UpdatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated
|
||||
StatusID string `bun:"type:CHAR(26),nullzero,notnull"` // ID of the status this mention originates from
|
||||
Status *Status `bun:"rel:belongs-to"` // status referred to by statusID
|
||||
OriginAccountID string `bun:"type:CHAR(26),nullzero,notnull"` // ID of the mention creator account
|
||||
|
|
|
@ -22,7 +22,9 @@ import (
|
|||
"math/big"
|
||||
"time"
|
||||
|
||||
"codeberg.org/gruf/go-kv"
|
||||
"github.com/oklog/ulid"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -48,11 +50,16 @@ func NewULID() string {
|
|||
// NewULIDFromTime returns a new ULID string using
|
||||
// given time, or from current time on any error.
|
||||
func NewULIDFromTime(t time.Time) string {
|
||||
newUlid, err := ulid.New(ulid.Timestamp(t), rand.Reader)
|
||||
if err != nil {
|
||||
return NewULID()
|
||||
ts := ulid.Timestamp(t)
|
||||
if ts > ulid.MaxTime() {
|
||||
log.WarnKVs(nil, kv.Fields{
|
||||
{K: "caller", V: log.Caller(2)},
|
||||
{K: "value", V: t},
|
||||
{K: "msg", V: "invalid ulid time"},
|
||||
}...)
|
||||
ts = ulid.Now()
|
||||
}
|
||||
return newUlid.String()
|
||||
return ulid.MustNew(ts, rand.Reader).String()
|
||||
}
|
||||
|
||||
// NewRandomULID returns a new ULID string using a random time in an ~80 year range around the current datetime, or an error if something goes wrong.
|
||||
|
|
|
@ -2341,7 +2341,6 @@ func NewTestMentions() map[string]*gtsmodel.Mention {
|
|||
ID: "01FCTA2Y6FGHXQA4ZE6N5NMNEX",
|
||||
StatusID: "01FCTA44PW9H1TB328S9AQXKDS",
|
||||
CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
UpdatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
OriginAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||
OriginAccountURI: "http://localhost:8080/users/the_mighty_zork",
|
||||
TargetAccountID: "01F8MH5ZK5VRH73AKHQM6Y9VNX",
|
||||
|
@ -2353,7 +2352,6 @@ func NewTestMentions() map[string]*gtsmodel.Mention {
|
|||
ID: "01FDF2HM2NF6FSRZCDEDV451CN",
|
||||
StatusID: "01FCQSQ667XHJ9AV9T27SJJSX5",
|
||||
CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
UpdatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
OriginAccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
|
||||
OriginAccountURI: "http://localhost:8080/users/1happyturtle",
|
||||
TargetAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||
|
@ -2365,7 +2363,6 @@ func NewTestMentions() map[string]*gtsmodel.Mention {
|
|||
ID: "01FN3VKDEF4CN2W9TKX339BEHB",
|
||||
StatusID: "01FN3VJGFH10KR7S2PB0GFJZYG",
|
||||
CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
UpdatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
OriginAccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
|
||||
OriginAccountURI: "http://localhost:8080/users/1happyturtle",
|
||||
TargetAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||
|
@ -2377,7 +2374,6 @@ func NewTestMentions() map[string]*gtsmodel.Mention {
|
|||
ID: "01FF26A6BGEKCZFWNEHXB2ZZ6M",
|
||||
StatusID: "01FF25D5Q0DH7CHD57CTRS6WK0",
|
||||
CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
UpdatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"),
|
||||
OriginAccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
|
||||
OriginAccountURI: "http://localhost:8080/users/admin",
|
||||
TargetAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||
|
@ -2389,7 +2385,6 @@ func NewTestMentions() map[string]*gtsmodel.Mention {
|
|||
ID: "01J5QVP69ANF1K4WHES6GA4WXP",
|
||||
StatusID: "01J5QVB9VC76NPPRQ207GG4DRZ",
|
||||
CreatedAt: TimeMustParse("2024-02-20T12:41:37+02:00"),
|
||||
UpdatedAt: TimeMustParse("2024-02-20T12:41:37+02:00"),
|
||||
OriginAccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
|
||||
OriginAccountURI: "http://localhost:8080/users/admin",
|
||||
TargetAccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
|
||||
|
@ -2401,7 +2396,6 @@ func NewTestMentions() map[string]*gtsmodel.Mention {
|
|||
ID: "01HE7XQNMKTVC8MNPCE1JGK4J3",
|
||||
StatusID: "01HE7XJ1CG84TBKH5V9XKBVGF5",
|
||||
CreatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"),
|
||||
UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"),
|
||||
OriginAccountID: "01FHMQX3GAABWSM0S2VZEC2SWC",
|
||||
OriginAccountURI: "http://example.org/users/Some_User",
|
||||
TargetAccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
|
||||
|
|
Loading…
Reference in a new issue