2017-04-14 16:59:43 +02:00
|
|
|
package mastodon
|
|
|
|
|
2017-04-17 04:10:29 +02:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
|
|
|
)
|
2017-04-14 21:23:36 +02:00
|
|
|
|
2017-04-14 16:59:43 +02:00
|
|
|
// Instance hold information for mastodon instance.
|
|
|
|
type Instance struct {
|
|
|
|
URI string `json:"uri"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Description string `json:"description"`
|
|
|
|
EMail string `json:"email"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetInstance return Instance.
|
2017-04-17 04:10:29 +02:00
|
|
|
func (c *Client) GetInstance(ctx context.Context) (*Instance, error) {
|
2017-04-14 16:59:43 +02:00
|
|
|
var instance Instance
|
2017-04-18 10:08:48 +02:00
|
|
|
err := c.doAPI(ctx, http.MethodGet, "/api/v1/instance", nil, &instance, nil)
|
2017-04-14 16:59:43 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &instance, nil
|
|
|
|
}
|
2018-01-29 04:29:39 +01:00
|
|
|
|
|
|
|
// WeeklyActivity hold information for mastodon weekly activity.
|
|
|
|
type WeeklyActivity struct {
|
|
|
|
Week Unixtime `json:"week"`
|
|
|
|
Statuses int64 `json:"statuses,string"`
|
|
|
|
Logins int64 `json:"logins,string"`
|
|
|
|
Registrations int64 `json:"registrations,string"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetInstanceActivity return instance activity.
|
|
|
|
func (c *Client) GetInstanceActivity(ctx context.Context) ([]*WeeklyActivity, error) {
|
|
|
|
var activity []*WeeklyActivity
|
|
|
|
err := c.doAPI(ctx, http.MethodGet, "/api/v1/instance/activity", nil, &activity, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return activity, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetInstancePeers return instance peers.
|
|
|
|
func (c *Client) GetInstancePeers(ctx context.Context) ([]string, error) {
|
|
|
|
var peers []string
|
|
|
|
err := c.doAPI(ctx, http.MethodGet, "/api/v1/instance/peers", nil, &peers, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return peers, nil
|
|
|
|
}
|