11 type NotificationPleroma struct {
12 IsSeen bool `json:"is_seen"`
15 // Notification hold information for mastodon notification.
16 type Notification struct {
18 Type string `json:"type"`
19 CreatedAt time.Time `json:"created_at"`
20 Account Account `json:"account"`
21 Status *Status `json:"status"`
22 Pleroma *NotificationPleroma `json:"pleroma"`
25 // GetNotifications return notifications.
26 func (c *Client) GetNotifications(ctx context.Context, pg *Pagination) ([]*Notification, error) {
27 var notifications []*Notification
28 err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", nil, ¬ifications, pg)
32 return notifications, nil
35 // GetNotification return notification.
36 func (c *Client) GetNotification(ctx context.Context, id string) (*Notification, error) {
37 var notification Notification
38 err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%v", id), nil, ¬ification, nil)
42 return ¬ification, nil
45 // ClearNotifications clear notifications.
46 func (c *Client) ClearNotifications(ctx context.Context) error {
47 return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil)
50 // ReadNotifications marks notifications as read
51 // Currenly only works for Pleroma
52 func (c *Client) ReadNotifications(ctx context.Context, maxID string) error {
53 params := url.Values{}
54 params.Set("max_id", maxID)
55 return c.doAPI(ctx, http.MethodPost, "/api/v1/pleroma/notifications/read", params, nil, nil)