Merge pull request #63 from zetamatta/notification-id
Fix: Type of Notification.ID was int64. Change to IDpull/64/head
commit
e0cf1e0650
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
// Notification hold information for mastodon notification.
|
// Notification hold information for mastodon notification.
|
||||||
type Notification struct {
|
type Notification struct {
|
||||||
ID int64 `json:"id"`
|
ID ID `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
Account Account `json:"account"`
|
Account Account `json:"account"`
|
||||||
|
@ -27,9 +27,9 @@ func (c *Client) GetNotifications(ctx context.Context, pg *Pagination) ([]*Notif
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNotification return notification.
|
// GetNotification return notification.
|
||||||
func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification, error) {
|
func (c *Client) GetNotification(ctx context.Context, id ID) (*Notification, error) {
|
||||||
var notification Notification
|
var notification Notification
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification, nil)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%v", id), nil, ¬ification, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,18 +39,18 @@ func TestGetNotifications(t *testing.T) {
|
||||||
if len(ns) != 2 {
|
if len(ns) != 2 {
|
||||||
t.Fatalf("result should be two: %d", len(ns))
|
t.Fatalf("result should be two: %d", len(ns))
|
||||||
}
|
}
|
||||||
if ns[0].ID != 122 {
|
if ns[0].ID != "122" {
|
||||||
t.Fatalf("want %v but %v", 122, ns[0].ID)
|
t.Fatalf("want %v but %v", "122", ns[0].ID)
|
||||||
}
|
}
|
||||||
if ns[1].ID != 123 {
|
if ns[1].ID != "123" {
|
||||||
t.Fatalf("want %v but %v", 123, ns[1].ID)
|
t.Fatalf("want %v but %v", "123", ns[1].ID)
|
||||||
}
|
}
|
||||||
n, err := client.GetNotification(context.Background(), 123)
|
n, err := client.GetNotification(context.Background(), "123")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
if n.ID != 123 {
|
if n.ID != "123" {
|
||||||
t.Fatalf("want %v but %v", 123, n.ID)
|
t.Fatalf("want %v but %v", "123", n.ID)
|
||||||
}
|
}
|
||||||
err = client.ClearNotifications(context.Background())
|
err = client.ClearNotifications(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -117,7 +117,7 @@ func wsTest(t *testing.T, q chan Event, cancel func()) {
|
||||||
if events[0].(*UpdateEvent).Status.Content != "foo" {
|
if events[0].(*UpdateEvent).Status.Content != "foo" {
|
||||||
t.Fatalf("want %q but %q", "foo", events[0].(*UpdateEvent).Status.Content)
|
t.Fatalf("want %q but %q", "foo", events[0].(*UpdateEvent).Status.Content)
|
||||||
}
|
}
|
||||||
if events[1].(*NotificationEvent).Notification.ID != 123 {
|
if events[1].(*NotificationEvent).Notification.ID != "123" {
|
||||||
t.Fatalf("want %d but %d", 123, events[1].(*NotificationEvent).Notification.ID)
|
t.Fatalf("want %d but %d", 123, events[1].(*NotificationEvent).Notification.ID)
|
||||||
}
|
}
|
||||||
if events[2].(*DeleteEvent).ID != 1234567 {
|
if events[2].(*DeleteEvent).ID != 1234567 {
|
||||||
|
|
Loading…
Reference in New Issue