summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-05-24 18:21:27 +0200
committerLibravatar GitHub <noreply@github.com>2022-05-24 17:21:27 +0100
commita54efa09f9fd1b8af9d99e0e94600133a20b751c (patch)
tree71c47d30d8d9990c17d31dd3fcda42ac0f3c2fa6 /internal/typeutils/internaltofrontend.go
parent[bugfix] Don't serialize instance account if not set (#603) (diff)
downloadgotosocial-a54efa09f9fd1b8af9d99e0e94600133a20b751c.tar.xz
[chore] Serialize times as UTC ISO8601 instead of RFC3339 (#602)
* add time util to mimic utc ISO8601 * use ISO8601 when serializing to frontend * update test notification
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r--internal/typeutils/internaltofrontend.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index 9158830ef..9601f3e3a 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -22,7 +22,6 @@ import (
"context"
"fmt"
"strings"
- "time"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
@@ -31,6 +30,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/util"
)
func (c *converter) AccountToAPIAccountSensitive(ctx context.Context, a *gtsmodel.Account) (*model.Account, error) {
@@ -93,7 +93,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
var lastStatusAt string
lastPosted, err := c.db.GetAccountLastPosted(ctx, a.ID)
if err == nil && !lastPosted.IsZero() {
- lastStatusAt = lastPosted.Format(time.RFC3339)
+ lastStatusAt = util.FormatISO8601(lastPosted)
}
// set account avatar fields if available
@@ -140,7 +140,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
Value: f.Value,
}
if !f.VerifiedAt.IsZero() {
- mField.VerifiedAt = f.VerifiedAt.Format(time.RFC3339)
+ mField.VerifiedAt = util.FormatISO8601(f.VerifiedAt)
}
fields = append(fields, mField)
}
@@ -169,7 +169,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
DisplayName: a.DisplayName,
Locked: a.Locked,
Bot: a.Bot,
- CreatedAt: a.CreatedAt.Format(time.RFC3339),
+ CreatedAt: util.FormatISO8601(a.CreatedAt),
Note: a.Note,
URL: a.URL,
Avatar: aviURL,
@@ -209,7 +209,7 @@ func (c *converter) AccountToAPIAccountBlocked(ctx context.Context, a *gtsmodel.
Acct: acct,
DisplayName: a.DisplayName,
Bot: a.Bot,
- CreatedAt: a.CreatedAt.Format(time.RFC3339),
+ CreatedAt: util.FormatISO8601(a.CreatedAt),
URL: a.URL,
Suspended: suspended,
}, nil
@@ -511,7 +511,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
apiStatus := &model.Status{
ID: s.ID,
- CreatedAt: s.CreatedAt.Format(time.RFC3339),
+ CreatedAt: util.FormatISO8601(s.CreatedAt),
InReplyToID: s.InReplyToID,
InReplyToAccountID: s.InReplyToAccountID,
Sensitive: s.Sensitive,
@@ -695,7 +695,7 @@ func (c *converter) NotificationToAPINotification(ctx context.Context, n *gtsmod
return &model.Notification{
ID: n.ID,
Type: string(n.NotificationType),
- CreatedAt: n.CreatedAt.Format(time.RFC3339),
+ CreatedAt: util.FormatISO8601(n.CreatedAt),
Account: apiAccount,
Status: apiStatus,
}, nil
@@ -714,7 +714,7 @@ func (c *converter) DomainBlockToAPIDomainBlock(ctx context.Context, b *gtsmodel
domainBlock.PrivateComment = b.PrivateComment
domainBlock.SubscriptionID = b.SubscriptionID
domainBlock.CreatedBy = b.CreatedByAccountID
- domainBlock.CreatedAt = b.CreatedAt.Format(time.RFC3339)
+ domainBlock.CreatedAt = util.FormatISO8601(b.CreatedAt)
}
return domainBlock, nil