52 } |
51 } |
53 |
52 |
54 // GetNotification returns a notification |
53 // GetNotification returns a notification |
55 // The returned notification can be nil if there is an error or if the |
54 // The returned notification can be nil if there is an error or if the |
56 // requested notification does not exist. |
55 // requested notification does not exist. |
57 func (mc *Client) GetNotification(notificationID int64) (*Notification, error) { |
56 func (mc *Client) GetNotification(notificationID ActivityID) (*Notification, error) { |
58 if notificationID < 1 { |
57 if notificationID == "" { |
59 return nil, ErrInvalidID |
58 return nil, ErrInvalidID |
60 } |
59 } |
61 |
60 |
62 var endPoint = "notifications/" + strconv.FormatInt(notificationID, 10) |
61 var endPoint = "notifications/" + notificationID |
63 var notification Notification |
62 var notification Notification |
64 if err := mc.apiCall("v1/"+endPoint, rest.Get, nil, nil, nil, ¬ification); err != nil { |
63 if err := mc.apiCall("v1/"+endPoint, rest.Get, nil, nil, nil, ¬ification); err != nil { |
65 return nil, err |
64 return nil, err |
66 } |
65 } |
67 if notification.ID == 0 { |
66 if notification.ID == "" { |
68 return nil, ErrEntityNotFound |
67 return nil, ErrEntityNotFound |
69 } |
68 } |
70 return ¬ification, nil |
69 return ¬ification, nil |
71 } |
70 } |
72 |
71 |
73 // DismissNotification deletes a notification |
72 // DismissNotification deletes a notification |
74 func (mc *Client) DismissNotification(notificationID int64) error { |
73 func (mc *Client) DismissNotification(notificationID ActivityID) error { |
75 if notificationID < 1 { |
74 if notificationID == "" { |
76 return ErrInvalidID |
75 return ErrInvalidID |
77 } |
76 } |
78 |
77 |
79 endPoint := "notifications/dismiss" |
78 endPoint := "notifications/dismiss" |
80 params := apiCallParams{"id": strconv.FormatInt(notificationID, 10)} |
79 params := apiCallParams{"id": notificationID} |
81 err := mc.apiCall("v1/"+endPoint, rest.Post, params, nil, nil, &Notification{}) |
80 err := mc.apiCall("v1/"+endPoint, rest.Post, params, nil, nil, &Notification{}) |
82 return err |
81 return err |
83 } |
82 } |
84 |
83 |
85 // ClearNotifications deletes all notifications from the Mastodon server for |
84 // ClearNotifications deletes all notifications from the Mastodon server for |