Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
[#1571] Update GETNotifications endpoint to use repo.APITime
Browse files Browse the repository at this point in the history
  • Loading branch information
placer14 committed May 22, 2019
1 parent 3a2b854 commit 536b37a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions api/jsonapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ func TestNotificationsAreReturnedInExpectedOrder(t *testing.T) {
createdAt = time.Unix(837645345, 0)
notif1 = &repo.Notification{
ID: "notif1",
CreatedAt: createdAt,
CreatedAt: repo.NewAPITime(createdAt),
NotifierType: repo.NotifierTypeFollowNotification,
NotifierData: &repo.FollowNotification{
ID: "notif1",
Expand All @@ -806,7 +806,7 @@ func TestNotificationsAreReturnedInExpectedOrder(t *testing.T) {
}
notif2 = &repo.Notification{
ID: "notif2",
CreatedAt: createdAt,
CreatedAt: repo.NewAPITime(createdAt),
NotifierType: repo.NotifierTypeFollowNotification,
NotifierData: &repo.FollowNotification{
ID: "notif2",
Expand All @@ -816,7 +816,7 @@ func TestNotificationsAreReturnedInExpectedOrder(t *testing.T) {
}
notif3 = &repo.Notification{
ID: "notif3",
CreatedAt: createdAt,
CreatedAt: repo.NewAPITime(createdAt),
NotifierType: repo.NotifierTypeFollowNotification,
NotifierData: &repo.FollowNotification{
ID: "notif3",
Expand Down
2 changes: 1 addition & 1 deletion repo/db/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (n *NotficationsDB) GetAll(offsetId string, limit int, typeFilter []string)
read = true
}
notification.IsRead = read
notification.CreatedAt = time.Unix(int64(timestampInt), 0).UTC()
notification.CreatedAt = repo.NewAPITime(time.Unix(int64(timestampInt), 0).UTC())
// END

ret = append(ret, notification)
Expand Down
6 changes: 3 additions & 3 deletions repo/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Notifier interface {
func NewNotification(n Notifier, createdAt time.Time, isRead bool) *Notification {
return &Notification{
ID: n.GetID(),
CreatedAt: createdAt.UTC(),
CreatedAt: NewAPITime(createdAt.UTC()),
IsRead: isRead,
NotifierData: n,
NotifierType: n.GetType(),
Expand All @@ -55,7 +55,7 @@ func NewNotification(n Notifier, createdAt time.Time, isRead bool) *Notification
// serializations to match in the Notifications Datastore
type Notification struct {
ID string `json:"-"`
CreatedAt time.Time `json:"timestamp"`
CreatedAt *APITime `json:"timestamp"`
IsRead bool `json:"read"`
NotifierData Notifier `json:"notification"`
NotifierType NotificationType `json:"-"`
Expand All @@ -77,7 +77,7 @@ func (n *Notification) Data() ([]byte, error) { return json.MarshalInde
func (n *Notification) WebsocketData() ([]byte, error) { return n.Data() }

type notificationTransporter struct {
CreatedAt time.Time `json:"timestamp"`
CreatedAt *APITime `json:"timestamp"`
IsRead bool `json:"read"`
NotifierData json.RawMessage `json:"notification"`
NotifierType NotificationType `json:"type"`
Expand Down

0 comments on commit 536b37a

Please sign in to comment.