mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2025-05-01 09:34:21 +00:00
Add notification support
This commit is contained in:
parent
51a4b16af5
commit
f68d72ae0e
13 changed files with 271 additions and 29 deletions
|
@ -4,16 +4,22 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
type NotificationPleroma struct {
|
||||
IsSeen bool `json:"is_seen"`
|
||||
}
|
||||
|
||||
// Notification hold information for mastodon notification.
|
||||
type Notification struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Account Account `json:"account"`
|
||||
Status *Status `json:"status"`
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Account Account `json:"account"`
|
||||
Status *Status `json:"status"`
|
||||
Pleroma *NotificationPleroma `json:"pleroma"`
|
||||
}
|
||||
|
||||
// GetNotifications return notifications.
|
||||
|
@ -40,3 +46,11 @@ func (c *Client) GetNotification(ctx context.Context, id string) (*Notification,
|
|||
func (c *Client) ClearNotifications(ctx context.Context) error {
|
||||
return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil)
|
||||
}
|
||||
|
||||
// ReadNotifications marks notifications as read
|
||||
// Currenly only works for Pleroma
|
||||
func (c *Client) ReadNotifications(ctx context.Context, maxID string) error {
|
||||
params := url.Values{}
|
||||
params.Set("max_id", maxID)
|
||||
return c.doAPI(ctx, http.MethodPost, "/api/v1/pleroma/notifications/read", params, nil, nil)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue