mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 21:52:25 -05:00
move to ulid
This commit is contained in:
parent
625e6d654c
commit
26ee190338
51 changed files with 398 additions and 514 deletions
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/id"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
)
|
||||
|
|
@ -168,7 +169,12 @@ func (p *processor) searchStatusByURI(authed *oauth.Auth, uri *url.URL, resolve
|
|||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
// put it in the DB so it gets a UUID
|
||||
statusID, err := id.NewULIDFromTime(status.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
status.ID = statusID
|
||||
|
||||
if err := p.db.Put(status); err != nil {
|
||||
return nil, fmt.Errorf("error putting status in the db: %s", err)
|
||||
}
|
||||
|
|
@ -211,6 +217,12 @@ func (p *processor) searchAccountByURI(authed *oauth.Auth, uri *url.URL, resolve
|
|||
return nil, fmt.Errorf("searchAccountByURI: error dereferencing account with uri %s: %s", uri.String(), err)
|
||||
}
|
||||
|
||||
accountID, err := id.NewRandomULID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
account.ID = accountID
|
||||
|
||||
if err := p.db.Put(account); err != nil {
|
||||
return nil, fmt.Errorf("searchAccountByURI: error inserting account with uri %s: %s", uri.String(), err)
|
||||
}
|
||||
|
|
@ -281,6 +293,12 @@ func (p *processor) searchAccountByMention(authed *oauth.Auth, mention string, r
|
|||
return nil, fmt.Errorf("searchAccountByMention: error converting account with uri %s: %s", acctURI.String(), err)
|
||||
}
|
||||
|
||||
foundAccountID, err := id.NewULID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
foundAccount.ID = foundAccountID
|
||||
|
||||
// put this new account in our database
|
||||
if err := p.db.Put(foundAccount); err != nil {
|
||||
return nil, fmt.Errorf("searchAccountByMention: error inserting account with uri %s: %s", acctURI.String(), err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue