mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Application creation + management via API + settings panel (#3906)
* [feature] Application creation + management via API + settings panel * fix docs links * add errnorows test * use known application as shorter * add comment about side effects
This commit is contained in:
@ -623,8 +623,14 @@ func (c *Converter) AppToAPIAppSensitive(ctx context.Context, a *gtsmodel.Applic
|
||||
return nil, gtserror.Newf("error getting VAPID public key: %w", err)
|
||||
}
|
||||
|
||||
createdAt, err := id.TimeFromULID(a.ID)
|
||||
if err != nil {
|
||||
return nil, gtserror.Newf("error converting id to time: %w", err)
|
||||
}
|
||||
|
||||
return &apimodel.Application{
|
||||
ID: a.ID,
|
||||
CreatedAt: util.FormatISO8601(createdAt),
|
||||
Name: a.Name,
|
||||
Website: a.Website,
|
||||
RedirectURI: strings.Join(a.RedirectURIs, "\n"),
|
||||
@ -1412,14 +1418,28 @@ func (c *Converter) baseStatusToFrontend(
|
||||
apiStatus.InReplyToAccountID = util.PtrIf(s.InReplyToAccountID)
|
||||
apiStatus.Language = util.PtrIf(s.Language)
|
||||
|
||||
if app := s.CreatedWithApplication; app != nil {
|
||||
apiStatus.Application, err = c.AppToAPIAppPublic(ctx, app)
|
||||
switch {
|
||||
case s.CreatedWithApplication != nil:
|
||||
// App exists for this status and is set.
|
||||
apiStatus.Application, err = c.AppToAPIAppPublic(ctx, s.CreatedWithApplication)
|
||||
if err != nil {
|
||||
return nil, gtserror.Newf(
|
||||
"error converting application %s: %w",
|
||||
s.CreatedWithApplicationID, err,
|
||||
)
|
||||
}
|
||||
|
||||
case s.CreatedWithApplicationID != "":
|
||||
// App existed for this status but not
|
||||
// anymore, it's probably been cleaned up.
|
||||
// Set a dummy application.
|
||||
apiStatus.Application = &apimodel.Application{
|
||||
Name: "unknown application",
|
||||
}
|
||||
|
||||
default:
|
||||
// No app stored for this (probably remote)
|
||||
// status, so nothing to do (app is optional).
|
||||
}
|
||||
|
||||
if s.Poll != nil {
|
||||
|
Reference in New Issue
Block a user