commit
3646db025f
62
mastodon.go
62
mastodon.go
|
@ -124,6 +124,24 @@ func RegisterApp(appConfig *AppConfig) (*Application, error) {
|
|||
return app, nil
|
||||
}
|
||||
|
||||
type Account struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Acct string `json:"acct"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Locked bool `json:"locked"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
FollowersCount int64 `json:"followers_count"`
|
||||
FollowingCount int64 `json:"following_count"`
|
||||
StatusesCount int64 `json:"statuses_count"`
|
||||
Note string `json:"note"`
|
||||
URL string `json:"url"`
|
||||
Avatar string `json:"avatar"`
|
||||
AvatarStatic string `json:"avatar_static"`
|
||||
Header string `json:"header"`
|
||||
HeaderStatic string `json:"header_static"`
|
||||
}
|
||||
|
||||
type Visibility int64
|
||||
|
||||
type Toot struct {
|
||||
|
@ -144,23 +162,7 @@ type Status struct {
|
|||
SpoilerText string `json:"spoiler_text"`
|
||||
Visibility string `json:"visibility"`
|
||||
Application interface{} `json:"application"`
|
||||
Account struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Acct string `json:"acct"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Locked bool `json:"locked"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
FollowersCount int64 `json:"followers_count"`
|
||||
FollowingCount int64 `json:"following_count"`
|
||||
StatusesCount int64 `json:"statuses_count"`
|
||||
Note string `json:"note"`
|
||||
URL string `json:"url"`
|
||||
Avatar string `json:"avatar"`
|
||||
AvatarStatic string `json:"avatar_static"`
|
||||
Header string `json:"header"`
|
||||
HeaderStatic string `json:"header_static"`
|
||||
} `json:"account"`
|
||||
Account Account `json:"account"`
|
||||
MediaAttachments []interface{} `json:"media_attachments"`
|
||||
Mentions []interface{} `json:"mentions"`
|
||||
Tags []interface{} `json:"tags"`
|
||||
|
@ -174,6 +176,32 @@ type Status struct {
|
|||
Reblogged interface{} `json:"reblogged"`
|
||||
}
|
||||
|
||||
func (c *client) GetAccount(id int) (*Account, error) {
|
||||
url, err := url.Parse(c.config.Server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url.Path = path.Join(url.Path, fmt.Sprintf("/api/v1/accounts/%d", id))
|
||||
|
||||
req, err := http.NewRequest("GET", url.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+c.config.AccessToken)
|
||||
resp, err := c.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
account := &Account{}
|
||||
err = json.NewDecoder(resp.Body).Decode(account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return account, nil
|
||||
}
|
||||
|
||||
func (c *client) GetTimelineHome() ([]*Status, error) {
|
||||
url, err := url.Parse(c.config.Server)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user