diff options
author | 2021-04-19 19:42:19 +0200 | |
---|---|---|
committer | 2021-04-19 19:42:19 +0200 | |
commit | 32c5fd987a06e11b14a4247d13187657c14adedd (patch) | |
tree | f5b787ca0f020bea5fd020925e52d3592a77a6ad /internal/oauth/tokenstore.go | |
parent | Api/v1/accounts (#8) (diff) | |
download | gotosocial-32c5fd987a06e11b14a4247d13187657c14adedd.tar.xz |
Api/v1/statuses (#11)
This PR adds:
Statuses
New status creation.
View existing status
Delete a status
Fave a status
Unfave a status
See who's faved a status
Media
Upload media attachment and store/retrieve it
Upload custom emoji and store/retrieve it
Fileserver
Serve files from storage
Testing
Test models, testrig -- run a GTS test instance and play around with it.
Diffstat (limited to 'internal/oauth/tokenstore.go')
-rw-r--r-- | internal/oauth/tokenstore.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/oauth/tokenstore.go b/internal/oauth/tokenstore.go index c4c9ff1d5..14caa6581 100644 --- a/internal/oauth/tokenstore.go +++ b/internal/oauth/tokenstore.go @@ -98,7 +98,7 @@ func (pts *tokenStore) Create(ctx context.Context, info oauth2.TokenInfo) error if !ok { return errors.New("info param was not a models.Token") } - if err := pts.db.Put(oauthTokenToPGToken(t)); err != nil { + if err := pts.db.Put(OAuthTokenToPGToken(t)); err != nil { return fmt.Errorf("error in tokenstore create: %s", err) } return nil @@ -130,7 +130,7 @@ func (pts *tokenStore) GetByCode(ctx context.Context, code string) (oauth2.Token if err := pts.db.GetWhere("code", code, pgt); err != nil { return nil, err } - return pgTokenToOauthToken(pgt), nil + return PGTokenToOauthToken(pgt), nil } // GetByAccess selects a token from the DB based on the Access field @@ -144,7 +144,7 @@ func (pts *tokenStore) GetByAccess(ctx context.Context, access string) (oauth2.T if err := pts.db.GetWhere("access", access, pgt); err != nil { return nil, err } - return pgTokenToOauthToken(pgt), nil + return PGTokenToOauthToken(pgt), nil } // GetByRefresh selects a token from the DB based on the Refresh field @@ -158,7 +158,7 @@ func (pts *tokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2 if err := pts.db.GetWhere("refresh", refresh, pgt); err != nil { return nil, err } - return pgTokenToOauthToken(pgt), nil + return PGTokenToOauthToken(pgt), nil } /* @@ -194,8 +194,8 @@ type Token struct { RefreshExpiresAt time.Time `pg:"type:timestamp"` } -// oauthTokenToPGToken is a lil util function that takes a gotosocial token and gives back a token for inserting into postgres -func oauthTokenToPGToken(tkn *models.Token) *Token { +// OAuthTokenToPGToken is a lil util function that takes a gotosocial token and gives back a token for inserting into postgres +func OAuthTokenToPGToken(tkn *models.Token) *Token { now := time.Now() // For the following, we want to make sure we're not adding a time.Now() to an *empty* ExpiresIn, otherwise that's @@ -236,8 +236,8 @@ func oauthTokenToPGToken(tkn *models.Token) *Token { } } -// pgTokenToOauthToken is a lil util function that takes a postgres token and gives back a gotosocial token -func pgTokenToOauthToken(pgt *Token) *models.Token { +// PGTokenToOauthToken is a lil util function that takes a postgres token and gives back a gotosocial token +func PGTokenToOauthToken(pgt *Token) *models.Token { now := time.Now() return &models.Token{ |