vendor/github.com/McKael/madon/v3/types.go
changeset 270 df7e9dff1b66
parent 268 4dd196a4ee7c
equal deleted inserted replaced
269:c50e88700432 270:df7e9dff1b66
     8 package madon
     8 package madon
     9 
     9 
    10 import (
    10 import (
    11 	"time"
    11 	"time"
    12 )
    12 )
       
    13 
       
    14 // Generic type alias for ActivityPub IDs
       
    15 type ActivityID = string
    13 
    16 
    14 // MastodonDate is a custom type for the timestamps returned by some API calls
    17 // MastodonDate is a custom type for the timestamps returned by some API calls
    15 type MastodonDate struct {
    18 type MastodonDate struct {
    16 	time.Time
    19 	time.Time
    17 }
    20 }
    37 // InstancePeer is a peer name, as returned by the instance/peers API
    40 // InstancePeer is a peer name, as returned by the instance/peers API
    38 type InstancePeer string
    41 type InstancePeer string
    39 
    42 
    40 // Account represents a Mastodon account entity
    43 // Account represents a Mastodon account entity
    41 type Account struct {
    44 type Account struct {
    42 	ID             int64         `json:"id,string"`
    45 	ID             ActivityID    `json:"id"`
    43 	Username       string        `json:"username"`
    46 	Username       string        `json:"username"`
    44 	Acct           string        `json:"acct"`
    47 	Acct           string        `json:"acct"`
    45 	DisplayName    string        `json:"display_name"`
    48 	DisplayName    string        `json:"display_name"`
    46 	Note           string        `json:"note"`
    49 	Note           string        `json:"note"`
    47 	URL            string        `json:"url"`
    50 	URL            string        `json:"url"`
    67 	Website string `json:"website"`
    70 	Website string `json:"website"`
    68 }
    71 }
    69 
    72 
    70 // Attachment represents a Mastodon media attachment entity
    73 // Attachment represents a Mastodon media attachment entity
    71 type Attachment struct {
    74 type Attachment struct {
    72 	ID         int64   `json:"id,string"`
    75 	ID         ActivityID `json:"id"`
    73 	Type       string  `json:"type"`
    76 	Type       string     `json:"type"`
    74 	URL        string  `json:"url"`
    77 	URL        string     `json:"url"`
    75 	RemoteURL  *string `json:"remote_url"`
    78 	RemoteURL  *string    `json:"remote_url"`
    76 	PreviewURL string  `json:"preview_url"`
    79 	PreviewURL string     `json:"preview_url"`
    77 	TextURL    *string `json:"text_url"`
    80 	TextURL    *string    `json:"text_url"`
    78 	Meta       *struct {
    81 	Meta       *struct {
    79 		Original struct {
    82 		Original struct {
    80 			Size   string  `json:"size"`
    83 			Size   string  `json:"size"`
    81 			Aspect float64 `json:"aspect"`
    84 			Aspect float64 `json:"aspect"`
    82 			Width  int     `json:"width"`
    85 			Width  int     `json:"width"`
   149 	ContactAccount *Account `json:"contact_account"`
   152 	ContactAccount *Account `json:"contact_account"`
   150 }
   153 }
   151 
   154 
   152 // List represents a Mastodon list entity
   155 // List represents a Mastodon list entity
   153 type List struct {
   156 type List struct {
   154 	ID    int64  `json:"id,string"`
   157 	ID    ActivityID `json:"id"`
   155 	Title string `json:"title"`
   158 	Title string     `json:"title"`
   156 }
   159 }
   157 
   160 
   158 // Mention represents a Mastodon mention entity
   161 // Mention represents a Mastodon mention entity
   159 type Mention struct {
   162 type Mention struct {
   160 	ID       int64  `json:"id,string"`
   163 	ID       ActivityID `json:"id"`
   161 	URL      string `json:"url"`
   164 	URL      string     `json:"url"`
   162 	Username string `json:"username"`
   165 	Username string     `json:"username"`
   163 	Acct     string `json:"acct"`
   166 	Acct     string     `json:"acct"`
   164 }
   167 }
   165 
   168 
   166 // Notification represents a Mastodon notification entity
   169 // Notification represents a Mastodon notification entity
   167 type Notification struct {
   170 type Notification struct {
   168 	ID        int64     `json:"id,string"`
   171 	ID        ActivityID `json:"id"`
   169 	Type      string    `json:"type"`
   172 	Type      string     `json:"type"`
   170 	CreatedAt time.Time `json:"created_at"`
   173 	CreatedAt time.Time  `json:"created_at"`
   171 	Account   *Account  `json:"account"`
   174 	Account   *Account   `json:"account"`
   172 	Status    *Status   `json:"status"`
   175 	Status    *Status    `json:"status"`
   173 }
   176 }
   174 
   177 
   175 // Relationship represents a Mastodon relationship entity
   178 // Relationship represents a Mastodon relationship entity
   176 type Relationship struct {
   179 type Relationship struct {
   177 	ID        int64 `json:"id,string"`
   180 	ID        ActivityID `json:"id"`
   178 	Following bool  `json:"following"`
   181 	Following bool       `json:"following"`
   179 	//ShowingReblogs      bool  `json:"showing_reblogs"` // Incoherent type
   182 	//ShowingReblogs      bool  `json:"showing_reblogs"` // Incoherent type
   180 	FollowedBy          bool `json:"followed_by"`
   183 	FollowedBy          bool `json:"followed_by"`
   181 	Blocking            bool `json:"blocking"`
   184 	Blocking            bool `json:"blocking"`
   182 	Muting              bool `json:"muting"`
   185 	Muting              bool `json:"muting"`
   183 	Requested           bool `json:"requested"`
   186 	Requested           bool `json:"requested"`
   187 	Endorsed            bool `json:"endorsed"`
   190 	Endorsed            bool `json:"endorsed"`
   188 }
   191 }
   189 
   192 
   190 // Report represents a Mastodon report entity
   193 // Report represents a Mastodon report entity
   191 type Report struct {
   194 type Report struct {
   192 	ID          int64  `json:"id,string"`
   195 	ID          ActivityID `json:"id"`
   193 	ActionTaken string `json:"action_taken"`
   196 	ActionTaken string     `json:"action_taken"`
   194 }
   197 }
   195 
   198 
   196 // Results represents a Mastodon search results entity
   199 // Results represents a Mastodon search results entity
   197 type Results struct {
   200 type Results struct {
   198 	Accounts []Account `json:"accounts"`
   201 	Accounts []Account `json:"accounts"`
   200 	Hashtags []Tag     `json:"hashtags"`
   203 	Hashtags []Tag     `json:"hashtags"`
   201 }
   204 }
   202 
   205 
   203 // Status represents a Mastodon status entity
   206 // Status represents a Mastodon status entity
   204 type Status struct {
   207 type Status struct {
   205 	ID                 int64        `json:"id,string"`
   208 	ID                 ActivityID   `json:"id"`
   206 	URI                string       `json:"uri"`
   209 	URI                string       `json:"uri"`
   207 	URL                string       `json:"url"`
   210 	URL                string       `json:"url"`
   208 	Account            *Account     `json:"account"`
   211 	Account            *Account     `json:"account"`
   209 	InReplyToID        *int64       `json:"in_reply_to_id,string"`
   212 	InReplyToID        *ActivityID  `json:"in_reply_to_id"`
   210 	InReplyToAccountID *int64       `json:"in_reply_to_account_id,string"`
   213 	InReplyToAccountID *ActivityID  `json:"in_reply_to_account_id"`
   211 	Reblog             *Status      `json:"reblog"`
   214 	Reblog             *Status      `json:"reblog"`
   212 	Content            string       `json:"content"`
   215 	Content            string       `json:"content"`
   213 	CreatedAt          time.Time    `json:"created_at"`
   216 	CreatedAt          time.Time    `json:"created_at"`
   214 	ReblogsCount       int64        `json:"reblogs_count"`
   217 	ReblogsCount       int64        `json:"reblogs_count"`
   215 	FavouritesCount    int64        `json:"favourites_count"`
   218 	FavouritesCount    int64        `json:"favourites_count"`