mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 13:42:24 -05:00
[feature] Add token review / delete to backend + settings panel (#3845)
This commit is contained in:
parent
ee60732cf7
commit
829143d263
25 changed files with 1637 additions and 1 deletions
|
|
@ -3068,3 +3068,39 @@ func (c *Converter) WebPushSubscriptionToAPIWebPushSubscription(
|
|||
Standard: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Converter) TokenToAPITokenInfo(
|
||||
ctx context.Context,
|
||||
token *gtsmodel.Token,
|
||||
) (*apimodel.TokenInfo, error) {
|
||||
createdAt, err := id.TimeFromULID(token.ID)
|
||||
if err != nil {
|
||||
err := gtserror.Newf("error parsing time from token id: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var lastUsed string
|
||||
if !token.LastUsed.IsZero() {
|
||||
lastUsed = util.FormatISO8601(token.LastUsed)
|
||||
}
|
||||
|
||||
application, err := c.state.DB.GetApplicationByClientID(ctx, token.ClientID)
|
||||
if err != nil {
|
||||
err := gtserror.Newf("db error getting application with client id %s: %w", token.ClientID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiApplication, err := c.AppToAPIAppPublic(ctx, application)
|
||||
if err != nil {
|
||||
err := gtserror.Newf("error converting application to api application: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &apimodel.TokenInfo{
|
||||
ID: token.ID,
|
||||
CreatedAt: util.FormatISO8601(createdAt),
|
||||
LastUsed: lastUsed,
|
||||
Scope: token.Scope,
|
||||
Application: apiApplication,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue