31 qID := fmt.Sprintf("exclude_types[%d]", i) |
31 qID := fmt.Sprintf("exclude_types[%d]", i) |
32 params[qID] = eType |
32 params[qID] = eType |
33 } |
33 } |
34 } |
34 } |
35 |
35 |
36 if err := mc.apiCall("notifications", rest.Get, params, lopt, &links, ¬ifications); err != nil { |
36 if err := mc.apiCall("v1/notifications", rest.Get, params, lopt, &links, ¬ifications); err != nil { |
37 return nil, err |
37 return nil, err |
38 } |
38 } |
39 if lopt != nil { // Fetch more pages to reach our limit |
39 if lopt != nil { // Fetch more pages to reach our limit |
40 var notifSlice []Notification |
40 var notifSlice []Notification |
41 for (lopt.All || lopt.Limit > len(notifications)) && links.next != nil { |
41 for (lopt.All || lopt.Limit > len(notifications)) && links.next != nil { |
42 newlopt := links.next |
42 newlopt := links.next |
43 links = apiLinks{} |
43 links = apiLinks{} |
44 if err := mc.apiCall("notifications", rest.Get, nil, newlopt, &links, ¬ifSlice); err != nil { |
44 if err := mc.apiCall("v1/notifications", rest.Get, nil, newlopt, &links, ¬ifSlice); err != nil { |
45 return nil, err |
45 return nil, err |
46 } |
46 } |
47 notifications = append(notifications, notifSlice...) |
47 notifications = append(notifications, notifSlice...) |
48 notifSlice = notifSlice[:0] // Clear struct |
48 notifSlice = notifSlice[:0] // Clear struct |
49 } |
49 } |
59 return nil, ErrInvalidID |
59 return nil, ErrInvalidID |
60 } |
60 } |
61 |
61 |
62 var endPoint = "notifications/" + strconv.FormatInt(notificationID, 10) |
62 var endPoint = "notifications/" + strconv.FormatInt(notificationID, 10) |
63 var notification Notification |
63 var notification Notification |
64 if err := mc.apiCall(endPoint, rest.Get, nil, nil, nil, ¬ification); err != nil { |
64 if err := mc.apiCall("v1/"+endPoint, rest.Get, nil, nil, nil, ¬ification); err != nil { |
65 return nil, err |
65 return nil, err |
66 } |
66 } |
67 if notification.ID == 0 { |
67 if notification.ID == 0 { |
68 return nil, ErrEntityNotFound |
68 return nil, ErrEntityNotFound |
69 } |
69 } |
76 return ErrInvalidID |
76 return ErrInvalidID |
77 } |
77 } |
78 |
78 |
79 endPoint := "notifications/dismiss" |
79 endPoint := "notifications/dismiss" |
80 params := apiCallParams{"id": strconv.FormatInt(notificationID, 10)} |
80 params := apiCallParams{"id": strconv.FormatInt(notificationID, 10)} |
81 err := mc.apiCall(endPoint, rest.Post, params, nil, nil, &Notification{}) |
81 err := mc.apiCall("v1/"+endPoint, rest.Post, params, nil, nil, &Notification{}) |
82 return err |
82 return err |
83 } |
83 } |
84 |
84 |
85 // ClearNotifications deletes all notifications from the Mastodon server for |
85 // ClearNotifications deletes all notifications from the Mastodon server for |
86 // the authenticated user |
86 // the authenticated user |
87 func (mc *Client) ClearNotifications() error { |
87 func (mc *Client) ClearNotifications() error { |
88 err := mc.apiCall("notifications/clear", rest.Post, nil, nil, nil, &Notification{}) |
88 err := mc.apiCall("v1/notifications/clear", rest.Post, nil, nil, nil, &Notification{}) |
89 return err |
89 return err |
90 } |
90 } |