start adding mastodon api types
This commit is contained in:
4
pkg/mastotypes/model/account.go
Normal file
4
pkg/mastotypes/model/account.go
Normal file
@ -0,0 +1,4 @@
|
||||
package mastotypes
|
||||
|
||||
type Account struct {
|
||||
}
|
29
pkg/mastotypes/model/application.go
Normal file
29
pkg/mastotypes/model/application.go
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
// Application represents a mastodon-api Application, as defined here: https://docs.joinmastodon.org/entities/application/
|
||||
type Application struct {
|
||||
// The name of your application.
|
||||
Name string `json:"name"`
|
||||
// The website associated with your application (url)
|
||||
Website string `json:"website"`
|
||||
// Used for Push Streaming API. Returned with POST /api/v1/apps. Equivalent to https://docs.joinmastodon.org/entities/pushsubscription/#server_key
|
||||
VapidKey string `json:"vapid_key"`
|
||||
}
|
96
pkg/mastotypes/model/attachment.go
Normal file
96
pkg/mastotypes/model/attachment.go
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
import "mime/multipart"
|
||||
|
||||
// AttachmentRequest represents the form data parameters submitted by a client during a media upload request.
|
||||
// See: https://docs.joinmastodon.org/methods/statuses/media/
|
||||
type AttachmentRequest struct {
|
||||
File *multipart.FileHeader `form:"file"`
|
||||
Thumbnail *multipart.FileHeader `form:"thumbnail"`
|
||||
Description string `form:"description"`
|
||||
Focus string `form:"focus"`
|
||||
}
|
||||
|
||||
// Attachment represents the object returned to a client after a successful media upload request.
|
||||
// See: https://docs.joinmastodon.org/methods/statuses/media/
|
||||
type Attachment struct {
|
||||
// The ID of the attachment in the database.
|
||||
ID string `json:"id"`
|
||||
// The type of the attachment.
|
||||
// unknown = unsupported or unrecognized file type.
|
||||
// image = Static image.
|
||||
// gifv = Looping, soundless animation.
|
||||
// video = Video clip.
|
||||
// audio = Audio track.
|
||||
Type string `json:"type"`
|
||||
// The location of the original full-size attachment.
|
||||
URL string `json:"url"`
|
||||
// The location of a scaled-down preview of the attachment.
|
||||
PreviewURL string `json:"preview_url"`
|
||||
// The location of the full-size original attachment on the remote website.
|
||||
RemoteURL string `json:"remote_url,omitempty"`
|
||||
// A shorter URL for the attachment.
|
||||
TextURL string `json:"text_url,omitempty"`
|
||||
// Metadata returned by Paperclip.
|
||||
// May contain subtrees small and original, as well as various other top-level properties.
|
||||
// More importantly, there may be another top-level focus Hash object as of 2.3.0, with coordinates can be used for smart thumbnail cropping.
|
||||
// See https://docs.joinmastodon.org/methods/statuses/media/#focal-points points for more.
|
||||
Meta MediaMeta `json:"meta,omitempty"`
|
||||
// Alternate text that describes what is in the media attachment, to be used for the visually impaired or when media attachments do not load.
|
||||
Description string `json:"description,omitempty"`
|
||||
// A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet.
|
||||
// See https://github.com/woltapp/blurhash
|
||||
Blurhash string `json:"blurhash,omitempty"`
|
||||
}
|
||||
|
||||
// MediaMeta describes the returned media
|
||||
type MediaMeta struct {
|
||||
Length string `json:"length,omitempty"`
|
||||
Duration float32 `json:"duration,omitempty"`
|
||||
FPS uint16 `json:"fps,omitempty"`
|
||||
Size string `json:"size,omitempty"`
|
||||
Width int `json:"width,omitempty"`
|
||||
Height int `json:"height,omitempty"`
|
||||
Aspect float32 `json:"aspect,omitempty"`
|
||||
AudioEncode string `json:"audio_encode,omitempty"`
|
||||
AudioBitrate string `json:"audio_bitrate,omitempty"`
|
||||
AudioChannels string `json:"audio_channels,omitempty"`
|
||||
Original MediaDimensions `json:"original"`
|
||||
Small MediaDimensions `json:"small,omitempty"`
|
||||
Focus MediaFocus `json:"focus,omitempty"`
|
||||
}
|
||||
|
||||
// MediaFocus describes the focal point of a piece of media. It should be returned to the caller as part of MediaMeta.
|
||||
type MediaFocus struct {
|
||||
X float32 `json:"x"` // should be between -1 and 1
|
||||
Y float32 `json:"y"` // should be between -1 and 1
|
||||
}
|
||||
|
||||
// MediaDimensions describes the physical properties of a piece of media. It should be returned to the caller as part of MediaMeta.
|
||||
type MediaDimensions struct {
|
||||
Width int `json:"width,omitempty"`
|
||||
Height int `json:"height,omitempty"`
|
||||
FrameRate string `json:"frame_rate,omitempty"`
|
||||
Duration float32 `json:"duration,omitempty"`
|
||||
Bitrate int `json:"bitrate,omitempty"`
|
||||
Size string `json:"size,omitempty"`
|
||||
Aspect float32 `json:"aspect,omitempty"`
|
||||
}
|
22
pkg/mastotypes/model/card.go
Normal file
22
pkg/mastotypes/model/card.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
type Card struct {
|
||||
}
|
22
pkg/mastotypes/model/emoji.go
Normal file
22
pkg/mastotypes/model/emoji.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
type Emoji struct {
|
||||
}
|
31
pkg/mastotypes/model/mention.go
Normal file
31
pkg/mastotypes/model/mention.go
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
// Mention represents the mastodon-api mention type, as documented here: https://docs.joinmastodon.org/entities/mention/
|
||||
type Mention struct {
|
||||
// The account id of the mentioned user.
|
||||
ID string `json:"id"`
|
||||
// The username of the mentioned user.
|
||||
Username string `json:"username"`
|
||||
// The location of the mentioned user's profile.
|
||||
URL string `json:"url"`
|
||||
// The webfinger acct: URI of the mentioned user. Equivalent to username for local users, or username@domain for remote users.
|
||||
Acct string `json:"acct"`
|
||||
}
|
35
pkg/mastotypes/model/poll.go
Normal file
35
pkg/mastotypes/model/poll.go
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
type Poll struct {
|
||||
}
|
||||
|
||||
// PollRequest represents a mastodon-api poll attached to a status POST request, as defined here: https://docs.joinmastodon.org/methods/statuses/
|
||||
// It should be used at the path https://mastodon.example/api/v1/statuses
|
||||
type PollRequest struct {
|
||||
// Array of possible answers. If provided, media_ids cannot be used, and poll[expires_in] must be provided.
|
||||
Options []string `form:"options"`
|
||||
// Duration the poll should be open, in seconds. If provided, media_ids cannot be used, and poll[options] must be provided.
|
||||
ExpiresIn int `form:"expires_in"`
|
||||
// Allow multiple choices?
|
||||
Multiple bool `form:"multiple"`
|
||||
// Hide vote counts until the poll ends?
|
||||
HideTotals bool `form:"hide_totals"`
|
||||
}
|
110
pkg/mastotypes/model/status.go
Normal file
110
pkg/mastotypes/model/status.go
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
// StatusRequest represents a mastodon-api status POST request, as defined here: https://docs.joinmastodon.org/methods/statuses/
|
||||
// It should be used at the path https://mastodon.example/api/v1/statuses
|
||||
type StatusRequest struct {
|
||||
// Text content of the status. If media_ids is provided, this becomes optional. Attaching a poll is optional while status is provided.
|
||||
Status string `form:"status"`
|
||||
// Array of Attachment ids to be attached as media. If provided, status becomes optional, and poll cannot be used.
|
||||
MediaIDs []string `form:"media_ids"`
|
||||
// Poll to include with this status.
|
||||
Poll *PollRequest `form:"poll"`
|
||||
// ID of the status being replied to, if status is a reply
|
||||
InReplyToID string `form:"in_reply_to_id"`
|
||||
// Mark status and attached media as sensitive?
|
||||
Sensitive bool `form:"sensitive"`
|
||||
// Text to be shown as a warning or subject before the actual content. Statuses are generally collapsed behind this field.
|
||||
SpoilerText string `form:"spoiler_text"`
|
||||
// Visibility of the posted status. Enumerable oneOf public, unlisted, private, direct.
|
||||
Visibility string `form:"visibility"`
|
||||
// ISO 8601 Datetime at which to schedule a status. Providing this paramter will cause ScheduledStatus to be returned instead of Status. Must be at least 5 minutes in the future.
|
||||
ScheduledAt string `form:"scheduled_at"`
|
||||
// ISO 639 language code for this status.
|
||||
Language string `form:"language"`
|
||||
}
|
||||
|
||||
// Status represents a mastodon-api Status type, as defined here: https://docs.joinmastodon.org/entities/status/
|
||||
type Status struct {
|
||||
// ID of the status in the database.
|
||||
ID string `json:"id"`
|
||||
// The date when this status was created (ISO 8601 Datetime)
|
||||
CreatedAt string `json:"created_at"`
|
||||
// ID of the status being replied.
|
||||
InReplyToID string `json:"in_reply_to_id"`
|
||||
// ID of the account being replied to.
|
||||
InReplyToAccountID string `json:"in_reply_to_account_id"`
|
||||
// Is this status marked as sensitive content?
|
||||
Sensitive bool `json:"sensitive"`
|
||||
// Subject or summary line, below which status content is collapsed until expanded.
|
||||
SpoilerText string `json:"spoiler_text"`
|
||||
// Visibility of this status.
|
||||
// public = Visible to everyone, shown in public timelines.
|
||||
// unlisted = Visible to public, but not included in public timelines.
|
||||
// private = Visible to followers only, and to any mentioned users.
|
||||
// direct = Visible only to mentioned users.
|
||||
Visibility string `json:"visibility"`
|
||||
// Primary language of this status. (ISO 639 Part 1 two-letter language code)
|
||||
Language string `json:"language"`
|
||||
// URI of the status used for federation.
|
||||
URI string `json:"uri"`
|
||||
// A link to the status's HTML representation.
|
||||
URL string `json:"url"`
|
||||
// How many replies this status has received.
|
||||
RepliesCount int `json:"replies_count"`
|
||||
// How many boosts this status has received.
|
||||
ReblogsCount int `json:"reblogs_count"`
|
||||
// How many favourites this status has received.
|
||||
FavouritesCount int `json:"favourites_count"`
|
||||
// Have you favourited this status?
|
||||
Favourited bool `json:"favourited"`
|
||||
// Have you boosted this status?
|
||||
Reblogged bool `json:"reblogged"`
|
||||
// Have you muted notifications for this status's conversation?
|
||||
Muted bool `json:"muted"`
|
||||
// Have you bookmarked this status?
|
||||
Bookmarked bool `json:"bookmarked"`
|
||||
// Have you pinned this status? Only appears if the status is pinnable.
|
||||
Pinned bool `json:"pinned"`
|
||||
// HTML-encoded status content.
|
||||
Content string `json:"content"`
|
||||
// The status being reblogged.
|
||||
Reblog *Status `json:"reblog"`
|
||||
// The application used to post this status.
|
||||
Application *Application `json:"application"`
|
||||
// The account that authored this status.
|
||||
Account *Account `json:"account"`
|
||||
// Media that is attached to this status.
|
||||
MediaAttachments []Attachment `json:"media_attachments"`
|
||||
// Mentions of users within the status content.
|
||||
Mentions []Mention `json:"mentions"`
|
||||
// Hashtags used within the status content.
|
||||
Tags []Tag `json:"tags"`
|
||||
// Custom emoji to be used when rendering status content.
|
||||
Emojis []Emoji `json:"emojis"`
|
||||
// Preview card for links included within status content.
|
||||
Card *Card `json:"card"`
|
||||
// The poll attached to the status.
|
||||
Poll *Poll `json:"poll"`
|
||||
// Plain-text source of a status. Returned instead of content when status is deleted,
|
||||
// so the user may redraft from the source text without the client having to reverse-engineer
|
||||
// the original text from the HTML content.
|
||||
Text string `json:"text"`
|
||||
}
|
22
pkg/mastotypes/model/tag.go
Normal file
22
pkg/mastotypes/model/tag.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package mastotypes
|
||||
|
||||
type Tag struct {
|
||||
}
|
Reference in New Issue
Block a user