add status model
This commit is contained in:
parent
1361482dd4
commit
bec69011ac
5 changed files with 171 additions and 22 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal"
|
||||||
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RegisterRequest struct {
|
type RegisterRequest struct {
|
||||||
|
@ -17,16 +18,6 @@ type RegisterRequest struct {
|
||||||
Website string `json:"website"`
|
Website string `json:"website"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RegisterResponse struct {
|
|
||||||
ClientID string `json:"client_id"`
|
|
||||||
ClientSecret string `json:"client_secret"`
|
|
||||||
ID string `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
RedirectUri string `json:"redirect_uri"`
|
|
||||||
VapidKey string `json:"vapid_key"`
|
|
||||||
Website string `json:"website"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *Client) Register() error {
|
func (g *Client) Register() error {
|
||||||
params := RegisterRequest{
|
params := RegisterRequest{
|
||||||
ClientName: internal.ApplicationName,
|
ClientName: internal.ApplicationName,
|
||||||
|
@ -53,14 +44,14 @@ func (g *Client) Register() error {
|
||||||
return fmt.Errorf("unable to create the HTTP request; %w", err)
|
return fmt.Errorf("unable to create the HTTP request; %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var registerResponse RegisterResponse
|
var app model.Application
|
||||||
|
|
||||||
if err := g.sendRequest(request, ®isterResponse); err != nil {
|
if err := g.sendRequest(request, &app); err != nil {
|
||||||
return fmt.Errorf("received an error after sending the registration request; %w", err)
|
return fmt.Errorf("received an error after sending the registration request; %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.Authentication.ClientID = registerResponse.ClientID
|
g.Authentication.ClientID = app.ClientID
|
||||||
g.Authentication.ClientSecret = registerResponse.ClientSecret
|
g.Authentication.ClientSecret = app.ClientSecret
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,6 @@ type Account struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Emoji struct {
|
|
||||||
Category string `json:"category"`
|
|
||||||
Shortcode string `json:"shortcode"`
|
|
||||||
StaticURL string `json:"static_url"`
|
|
||||||
URL string `json:"url"`
|
|
||||||
VisibleInPicker bool `json:"visible_in_picker"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AccountRole struct {
|
type AccountRole struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
11
internal/model/application.go
Normal file
11
internal/model/application.go
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
type Application struct {
|
||||||
|
ClientID string `json:"client_id"`
|
||||||
|
ClientSecret string `json:"client_secret"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
RedirectUri string `json:"redirect_uri"`
|
||||||
|
VapidKey string `json:"vapid_key"`
|
||||||
|
Website string `json:"website"`
|
||||||
|
}
|
9
internal/model/emoji.go
Normal file
9
internal/model/emoji.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
type Emoji struct {
|
||||||
|
Category string `json:"category"`
|
||||||
|
Shortcode string `json:"shortcode"`
|
||||||
|
StaticURL string `json:"static_url"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
VisibleInPicker bool `json:"visible_in_picker"`
|
||||||
|
}
|
146
internal/model/status.go
Normal file
146
internal/model/status.go
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
type Status struct {
|
||||||
|
Account Account `json:"account"`
|
||||||
|
Application Application `json:"application"`
|
||||||
|
Bookmarked bool `json:"bookmarked"`
|
||||||
|
Card Card `json:"card"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
CreatedAt string `json:"created_at"`
|
||||||
|
Emojis []Emoji `json:"emojis"`
|
||||||
|
Favourited bool `json:"favourited"`
|
||||||
|
FavouritesCount int `json:"favourites_count"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
InReplyToAccountID string `json:"in_reply_to_account_id"`
|
||||||
|
InReplyToID string `json:"in_reply_to_id"`
|
||||||
|
Language string `json:"language"`
|
||||||
|
MediaAttachments []Attachment `json:"media_attachments"`
|
||||||
|
Mentions []Mention `json:"mentions"`
|
||||||
|
Muted bool `json:"muted"`
|
||||||
|
Pinned bool `json:"pinned"`
|
||||||
|
Poll Poll `json:"poll"`
|
||||||
|
Reblog StatusReblogged `json:"reblog"`
|
||||||
|
Reblogged bool `json:"reblogged"`
|
||||||
|
RebloggsCount int `json:"reblogs_count"`
|
||||||
|
RepliesCount int `json:"replies_count"`
|
||||||
|
Sensitive bool `json:"sensitive"`
|
||||||
|
SpolierText string `json:"spoiler_text"`
|
||||||
|
Tags []Tag `json:"tags"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
URI string `json:"uri"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Visibility string `json:"visibility"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Card struct {
|
||||||
|
AuthorName string `json:"author_name"`
|
||||||
|
AuthorURL string `json:"author_url"`
|
||||||
|
Blurhash string `json:"blurhash"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
EmbedURL string `json:"embed_url"`
|
||||||
|
HTML string `json:"html"`
|
||||||
|
Image string `json:"image"`
|
||||||
|
ProviderName string `json:"provider_name"`
|
||||||
|
ProviderURL string `json:"provider_url"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Height int `json:"height"`
|
||||||
|
Width int `json:"width"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Mention struct {
|
||||||
|
Acct string `json:"acct"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Poll struct {
|
||||||
|
Emojis []Emoji `json:"emojis"`
|
||||||
|
Expired bool `json:"expired"`
|
||||||
|
Voted bool `json:"voted"`
|
||||||
|
Multiple bool `json:"multiple"`
|
||||||
|
ExpiredAt string `json:"expires_at"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
OwnVotes []int `json:"own_votes"`
|
||||||
|
VotersCount int `json:"voters_count"`
|
||||||
|
VotesCount int `json:"votes_count"`
|
||||||
|
Options []PollOption `json:"options"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PollOption struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
VotesCount string `json:"votes_count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusReblogged struct {
|
||||||
|
Account Account `json:"account"`
|
||||||
|
Application Application `json:"application"`
|
||||||
|
Bookmarked bool `json:"bookmarked"`
|
||||||
|
Card Card `json:"card"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
CreatedAt string `json:"created_at"`
|
||||||
|
Emojis []Emoji `json:"emojis"`
|
||||||
|
Favourited bool `json:"favourited"`
|
||||||
|
FavouritesCount int `json:"favourites_count"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
InReplyToAccountID string `json:"in_reply_to_account_id"`
|
||||||
|
InReplyToID string `json:"in_reply_to_id"`
|
||||||
|
Language string `json:"language"`
|
||||||
|
MediaAttachments []Attachment `json:"media_attachments"`
|
||||||
|
Mentions []Mention `json:"mentions"`
|
||||||
|
Muted bool `json:"muted"`
|
||||||
|
Pinned bool `json:"pinned"`
|
||||||
|
Poll Poll `json:"poll"`
|
||||||
|
Reblogged bool `json:"reblogged"`
|
||||||
|
RebloggsCount int `json:"reblogs_count"`
|
||||||
|
RepliesCount int `json:"replies_count"`
|
||||||
|
Sensitive bool `json:"sensitive"`
|
||||||
|
SpolierText string `json:"spoiler_text"`
|
||||||
|
Tags []Tag `json:"tags"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
URI string `json:"uri"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Visibility string `json:"visibility"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Tag struct {
|
||||||
|
History []any `json:"history"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Attachment struct {
|
||||||
|
Meta MediaMeta `json:"meta"`
|
||||||
|
Blurhash string `json:"blurhash"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
PreviewRemoteURL string `json:"preview_remote_url"`
|
||||||
|
PreviewURL string `json:"preview_url"`
|
||||||
|
RemoteURL string `json:"remote_url"`
|
||||||
|
TextURL string `json:"text_url"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MediaMeta struct {
|
||||||
|
Focus MediaFocus `json:"focus"`
|
||||||
|
Original MediaDimensions `json:"original"`
|
||||||
|
Small MediaDimensions `json:"small"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MediaFocus struct {
|
||||||
|
X float64 `json:"x"`
|
||||||
|
Y float64 `json:"y"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MediaDimensions struct {
|
||||||
|
Aspect float64 `json:"aspect"`
|
||||||
|
Bitrate int `json:"bitrate"`
|
||||||
|
Duration float64 `json:"duration"`
|
||||||
|
FrameRate string `json:"frame_rate"`
|
||||||
|
Size string `json:"size"`
|
||||||
|
Height int `json:"height"`
|
||||||
|
Width int `json:"width"`
|
||||||
|
}
|
Loading…
Reference in a new issue