From 7590eb9cc2e1557d4f7acea858a896afc7b03ca5 Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Mon, 15 Mar 2021 14:47:23 +0100 Subject: move mastotypes --- internal/oauth/oauth.go | 38 +++++++++ pkg/mastotypes/account.go | 69 +++++++++++++++++ pkg/mastotypes/activity.go | 31 ++++++++ pkg/mastotypes/admin.go | 81 ++++++++++++++++++++ pkg/mastotypes/announcement.go | 37 +++++++++ pkg/mastotypes/announcementreaction.go | 33 ++++++++ pkg/mastotypes/application.go | 29 +++++++ pkg/mastotypes/attachment.go | 96 +++++++++++++++++++++++ pkg/mastotypes/card.go | 61 +++++++++++++++ pkg/mastotypes/context.go | 27 +++++++ pkg/mastotypes/conversation.go | 36 +++++++++ pkg/mastotypes/emoji.go | 38 +++++++++ pkg/mastotypes/error.go | 32 ++++++++ pkg/mastotypes/featuredtag.go | 33 ++++++++ pkg/mastotypes/field.go | 34 +++++++++ pkg/mastotypes/filter.go | 46 +++++++++++ pkg/mastotypes/history.go | 29 +++++++ pkg/mastotypes/identityproof.go | 33 ++++++++ pkg/mastotypes/instance.go | 72 ++++++++++++++++++ pkg/mastotypes/list.go | 31 ++++++++ pkg/mastotypes/marker.go | 37 +++++++++ pkg/mastotypes/mention.go | 31 ++++++++ pkg/mastotypes/model/account.go | 69 ----------------- pkg/mastotypes/model/activity.go | 31 -------- pkg/mastotypes/model/admin.go | 81 -------------------- pkg/mastotypes/model/announcement.go | 37 --------- pkg/mastotypes/model/announcementreaction.go | 33 -------- pkg/mastotypes/model/application.go | 29 ------- pkg/mastotypes/model/attachment.go | 96 ----------------------- pkg/mastotypes/model/card.go | 61 --------------- pkg/mastotypes/model/context.go | 27 ------- pkg/mastotypes/model/conversation.go | 36 --------- pkg/mastotypes/model/emoji.go | 38 --------- pkg/mastotypes/model/error.go | 32 -------- pkg/mastotypes/model/featuredtag.go | 33 -------- pkg/mastotypes/model/field.go | 34 --------- pkg/mastotypes/model/filter.go | 46 ----------- pkg/mastotypes/model/history.go | 29 ------- pkg/mastotypes/model/identityproof.go | 33 -------- pkg/mastotypes/model/instance.go | 72 ------------------ pkg/mastotypes/model/list.go | 31 -------- pkg/mastotypes/model/marker.go | 37 --------- pkg/mastotypes/model/mention.go | 31 -------- pkg/mastotypes/model/notification.go | 45 ----------- pkg/mastotypes/model/poll.go | 64 ---------------- pkg/mastotypes/model/preferences.go | 40 ---------- pkg/mastotypes/model/pushsubscription.go | 45 ----------- pkg/mastotypes/model/relationship.go | 49 ------------ pkg/mastotypes/model/results.go | 29 ------- pkg/mastotypes/model/scheduledstatus.go | 39 ---------- pkg/mastotypes/model/source.go | 22 ------ pkg/mastotypes/model/status.go | 110 --------------------------- pkg/mastotypes/model/tag.go | 22 ------ pkg/mastotypes/notification.go | 45 +++++++++++ pkg/mastotypes/poll.go | 64 ++++++++++++++++ pkg/mastotypes/preferences.go | 40 ++++++++++ pkg/mastotypes/pushsubscription.go | 45 +++++++++++ pkg/mastotypes/relationship.go | 49 ++++++++++++ pkg/mastotypes/results.go | 29 +++++++ pkg/mastotypes/scheduledstatus.go | 39 ++++++++++ pkg/mastotypes/source.go | 22 ++++++ pkg/mastotypes/status.go | 110 +++++++++++++++++++++++++++ pkg/mastotypes/tag.go | 22 ++++++ 63 files changed, 1419 insertions(+), 1381 deletions(-) create mode 100644 pkg/mastotypes/account.go create mode 100644 pkg/mastotypes/activity.go create mode 100644 pkg/mastotypes/admin.go create mode 100644 pkg/mastotypes/announcement.go create mode 100644 pkg/mastotypes/announcementreaction.go create mode 100644 pkg/mastotypes/application.go create mode 100644 pkg/mastotypes/attachment.go create mode 100644 pkg/mastotypes/card.go create mode 100644 pkg/mastotypes/context.go create mode 100644 pkg/mastotypes/conversation.go create mode 100644 pkg/mastotypes/emoji.go create mode 100644 pkg/mastotypes/error.go create mode 100644 pkg/mastotypes/featuredtag.go create mode 100644 pkg/mastotypes/field.go create mode 100644 pkg/mastotypes/filter.go create mode 100644 pkg/mastotypes/history.go create mode 100644 pkg/mastotypes/identityproof.go create mode 100644 pkg/mastotypes/instance.go create mode 100644 pkg/mastotypes/list.go create mode 100644 pkg/mastotypes/marker.go create mode 100644 pkg/mastotypes/mention.go delete mode 100644 pkg/mastotypes/model/account.go delete mode 100644 pkg/mastotypes/model/activity.go delete mode 100644 pkg/mastotypes/model/admin.go delete mode 100644 pkg/mastotypes/model/announcement.go delete mode 100644 pkg/mastotypes/model/announcementreaction.go delete mode 100644 pkg/mastotypes/model/application.go delete mode 100644 pkg/mastotypes/model/attachment.go delete mode 100644 pkg/mastotypes/model/card.go delete mode 100644 pkg/mastotypes/model/context.go delete mode 100644 pkg/mastotypes/model/conversation.go delete mode 100644 pkg/mastotypes/model/emoji.go delete mode 100644 pkg/mastotypes/model/error.go delete mode 100644 pkg/mastotypes/model/featuredtag.go delete mode 100644 pkg/mastotypes/model/field.go delete mode 100644 pkg/mastotypes/model/filter.go delete mode 100644 pkg/mastotypes/model/history.go delete mode 100644 pkg/mastotypes/model/identityproof.go delete mode 100644 pkg/mastotypes/model/instance.go delete mode 100644 pkg/mastotypes/model/list.go delete mode 100644 pkg/mastotypes/model/marker.go delete mode 100644 pkg/mastotypes/model/mention.go delete mode 100644 pkg/mastotypes/model/notification.go delete mode 100644 pkg/mastotypes/model/poll.go delete mode 100644 pkg/mastotypes/model/preferences.go delete mode 100644 pkg/mastotypes/model/pushsubscription.go delete mode 100644 pkg/mastotypes/model/relationship.go delete mode 100644 pkg/mastotypes/model/results.go delete mode 100644 pkg/mastotypes/model/scheduledstatus.go delete mode 100644 pkg/mastotypes/model/source.go delete mode 100644 pkg/mastotypes/model/status.go delete mode 100644 pkg/mastotypes/model/tag.go create mode 100644 pkg/mastotypes/notification.go create mode 100644 pkg/mastotypes/poll.go create mode 100644 pkg/mastotypes/preferences.go create mode 100644 pkg/mastotypes/pushsubscription.go create mode 100644 pkg/mastotypes/relationship.go create mode 100644 pkg/mastotypes/results.go create mode 100644 pkg/mastotypes/scheduledstatus.go create mode 100644 pkg/mastotypes/source.go create mode 100644 pkg/mastotypes/status.go create mode 100644 pkg/mastotypes/tag.go diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 95cf97191..11b1b57fd 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -19,4 +19,42 @@ package oauth type Server struct { + manager := manage.NewDefaultManager() + // token memory store + manager.MustTokenStorage(store.NewMemoryTokenStore()) + + // client memory store + clientStore := store.NewClientStore() + clientStore.Set("000000", &models.Client{ + ID: "000000", + Secret: "999999", + Domain: "http://localhost", + }) + manager.MapClientStorage(clientStore) + + srv := server.NewDefaultServer(manager) + srv.SetAllowGetAccessRequest(true) + srv.SetClientInfoHandler(server.ClientFormHandler) + + srv.SetInternalErrorHandler(func(err error) (re *errors.Response) { + log.Println("Internal Error:", err.Error()) + return + }) + + srv.SetResponseErrorHandler(func(re *errors.Response) { + log.Println("Response Error:", re.Error.Error()) + }) + + http.HandleFunc("/authorize", func(w http.ResponseWriter, r *http.Request) { + err := srv.HandleAuthorizeRequest(w, r) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + } + }) + + http.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) { + srv.HandleTokenRequest(w, r) + }) + + log.Fatal(http.ListenAndServe(":9096", nil)) } diff --git a/pkg/mastotypes/account.go b/pkg/mastotypes/account.go new file mode 100644 index 000000000..031fa7c02 --- /dev/null +++ b/pkg/mastotypes/account.go @@ -0,0 +1,69 @@ +/* + 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 . +*/ + +package mastotypes + +// Account represents a mastodon-api Account object, as described here: https://docs.joinmastodon.org/entities/account/ +type Account struct { + // The account id + ID string `json:"id"` + // The username of the account, not including domain. + Username string `json:"username"` + // The Webfinger account URI. Equal to username for local users, or username@domain for remote users. + Acct string `json:"acct"` + // The profile's display name. + DisplayName string `json:"display_name"` + // Whether the account manually approves follow requests. + Locked bool `json:"locked"` + // Whether the account has opted into discovery features such as the profile directory. + Discoverable bool `json:"discoverable"` + // A presentational flag. Indicates that the account may perform automated actions, may not be monitored, or identifies as a robot. + Bot bool `json:"bot"` + // When the account was created. (ISO 8601 Datetime) + CreatedAt string `json:"created_at"` + // The profile's bio / description. + Note string `json:"note"` + // The location of the user's profile page. + URL string `json:"url"` + // An image icon that is shown next to statuses and in the profile. + Avatar string `json:"avatar"` + // A static version of the avatar. Equal to avatar if its value is a static image; different if avatar is an animated GIF. + AvatarStatic string `json:"avatar_static"` + // An image banner that is shown above the profile and in profile cards. + Header string `json:"header"` + // A static version of the header. Equal to header if its value is a static image; different if header is an animated GIF. + HeaderStatic string `json:"header_static"` + // The reported followers of this profile. + FollowersCount int `json:"followers_count"` + // The reported follows of this profile. + FollowingCount int `json:"following_count"` + // How many statuses are attached to this account. + StatusesCount int `json:"statuses_count"` + // When the most recent status was posted. (ISO 8601 Datetime) + LastStatusAt string `json:"last_status_at"` + // Custom emoji entities to be used when rendering the profile. If none, an empty array will be returned. + Emojis []Emoji `json:"emojis"` + // Additional metadata attached to a profile as name-value pairs. + Fields []Field `json:"fields"` + // An extra entity returned when an account is suspended. + Suspended bool `json:"suspended"` + // When a timed mute will expire, if applicable. (ISO 8601 Datetime) + MuteExpiresAt string `json:"mute_expires_at"` + // An extra entity to be used with API methods to verify credentials and update credentials. + Source *Source `json:"source"` +} diff --git a/pkg/mastotypes/activity.go b/pkg/mastotypes/activity.go new file mode 100644 index 000000000..b8dbf2c1b --- /dev/null +++ b/pkg/mastotypes/activity.go @@ -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 . +*/ + +package mastotypes + +// Activity represents the mastodon-api Activity type. See here: https://docs.joinmastodon.org/entities/activity/ +type Activity struct { + // Midnight at the first day of the week. (UNIX Timestamp as string) + Week string `json:"week"` + // Statuses created since the week began. Integer cast to string. + Statuses string `json:"statuses"` + // User logins since the week began. Integer cast as string. + Logins string `json:"logins"` + // User registrations since the week began. Integer cast as string. + Registrations string `json:"registrations"` +} diff --git a/pkg/mastotypes/admin.go b/pkg/mastotypes/admin.go new file mode 100644 index 000000000..71c2bb309 --- /dev/null +++ b/pkg/mastotypes/admin.go @@ -0,0 +1,81 @@ +/* + 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 . +*/ + +package mastotypes + +// AdminAccountInfo represents the *admin* view of an account's details. See here: https://docs.joinmastodon.org/entities/admin-account/ +type AdminAccountInfo struct { + // The ID of the account in the database. + ID string `json:"id"` + // The username of the account. + Username string `json:"username"` + // The domain of the account. + Domain string `json:"domain"` + // When the account was first discovered. (ISO 8601 Datetime) + CreatedAt string `json:"created_at"` + // The email address associated with the account. + Email string `json:"email"` + // The IP address last used to login to this account. + IP string `json:"ip"` + // The locale of the account. (ISO 639 Part 1 two-letter language code) + Locale string `json:"locale"` + // Invite request text + InviteRequest string `json:"invite_request"` + // The current role of the account. + Role string `json:"role"` + // Whether the account has confirmed their email address. + Confirmed bool `json:"confirmed"` + // Whether the account is currently approved. + Approved bool `json:"approved"` + // Whether the account is currently disabled. + Disabled bool `json:"disabled"` + // Whether the account is currently silenced + Silenced bool `json:"silenced"` + // Whether the account is currently suspended. + Suspended bool `json:"suspended"` + // User-level information about the account. + Account *Account `json:"account"` + // The ID of the application that created this account. + CreatedByApplicationID string `json:"created_by_application_id,omitempty"` + // The ID of the account that invited this user + InvitedByAccountID string `json:"invited_by_account_id"` +} + +// AdminReportInfo represents the *admin* view of a report. See here: https://docs.joinmastodon.org/entities/admin-report/ +type AdminReportInfo struct { + // The ID of the report in the database. + ID string `json:"id"` + // The action taken to resolve this report. + ActionTaken string `json:"action_taken"` + // An optional reason for reporting. + Comment string `json:"comment"` + // The time the report was filed. (ISO 8601 Datetime) + CreatedAt string `json:"created_at"` + // The time of last action on this report. (ISO 8601 Datetime) + UpdatedAt string `json:"updated_at"` + // The account which filed the report. + Account *Account `json:"account"` + // The account being reported. + TargetAccount *Account `json:"target_account"` + // The account of the moderator assigned to this report. + AssignedAccount *Account `json:"assigned_account"` + // The action taken by the moderator who handled the report. + ActionTakenByAccount string `json:"action_taken_by_account"` + // Statuses attached to the report, for context. + Statuses []Status `json:"statuses"` +} diff --git a/pkg/mastotypes/announcement.go b/pkg/mastotypes/announcement.go new file mode 100644 index 000000000..882d6bb9b --- /dev/null +++ b/pkg/mastotypes/announcement.go @@ -0,0 +1,37 @@ +/* + 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 . +*/ + +package mastotypes + +// Announcement represents an admin/moderator announcement for local users. See here: https://docs.joinmastodon.org/entities/announcement/ +type Announcement struct { + ID string `json:"id"` + Content string `json:"content"` + StartsAt string `json:"starts_at"` + EndsAt string `json:"ends_at"` + AllDay bool `json:"all_day"` + PublishedAt string `json:"published_at"` + UpdatedAt string `json:"updated_at"` + Published bool `json:"published"` + Read bool `json:"read"` + Mentions []Mention `json:"mentions"` + Statuses []Status `json:"statuses"` + Tags []Tag `json:"tags"` + Emojis []Emoji `json:"emoji"` + Reactions []AnnouncementReaction `json:"reactions"` +} diff --git a/pkg/mastotypes/announcementreaction.go b/pkg/mastotypes/announcementreaction.go new file mode 100644 index 000000000..444c57e2c --- /dev/null +++ b/pkg/mastotypes/announcementreaction.go @@ -0,0 +1,33 @@ +/* + 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 . +*/ + +package mastotypes + +// AnnouncementReaction represents a user reaction to admin/moderator announcement. See here: https://docs.joinmastodon.org/entities/announcementreaction/ +type AnnouncementReaction struct { + // The emoji used for the reaction. Either a unicode emoji, or a custom emoji's shortcode. + Name string `json:"name"` + // The total number of users who have added this reaction. + Count int `json:"count"` + // Whether the authorized user has added this reaction to the announcement. + Me bool `json:"me"` + // A link to the custom emoji. + URL string `json:"url,omitempty"` + // A link to a non-animated version of the custom emoji. + StaticURL string `json:"static_url,omitempty"` +} diff --git a/pkg/mastotypes/application.go b/pkg/mastotypes/application.go new file mode 100644 index 000000000..d2f894306 --- /dev/null +++ b/pkg/mastotypes/application.go @@ -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 . +*/ + +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"` +} diff --git a/pkg/mastotypes/attachment.go b/pkg/mastotypes/attachment.go new file mode 100644 index 000000000..4d4d0955a --- /dev/null +++ b/pkg/mastotypes/attachment.go @@ -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 . +*/ + +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"` +} diff --git a/pkg/mastotypes/card.go b/pkg/mastotypes/card.go new file mode 100644 index 000000000..d1147e04b --- /dev/null +++ b/pkg/mastotypes/card.go @@ -0,0 +1,61 @@ +/* + 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 . +*/ + +package mastotypes + +// Card represents a rich preview card that is generated using OpenGraph tags from a URL. See here: https://docs.joinmastodon.org/entities/card/ +type Card struct { + // REQUIRED + + // Location of linked resource. + URL string `json:"url"` + // Title of linked resource. + Title string `json:"title"` + // Description of preview. + Description string `json:"description"` + // The type of the preview card. + // String (Enumerable, oneOf) + // link = Link OEmbed + // photo = Photo OEmbed + // video = Video OEmbed + // rich = iframe OEmbed. Not currently accepted, so won't show up in practice. + Type string `json:"type"` + + // OPTIONAL + + // The author of the original resource. + AuthorName string `json:"author_name"` + // A link to the author of the original resource. + AuthorURL string `json:"author_url"` + // The provider of the original resource. + ProviderName string `json:"provider_name"` + // A link to the provider of the original resource. + ProviderURL string `json:"provider_url"` + // HTML to be used for generating the preview card. + HTML string `json:"html"` + // Width of preview, in pixels. + Width int `json:"width"` + // Height of preview, in pixels. + Height int `json:"height"` + // Preview thumbnail. + Image string `json:"image"` + // Used for photo embeds, instead of custom html. + EmbedURL string `json:"embed_url"` + // A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet. + Blurhash string `json:"blurhash"` +} diff --git a/pkg/mastotypes/context.go b/pkg/mastotypes/context.go new file mode 100644 index 000000000..397522dc7 --- /dev/null +++ b/pkg/mastotypes/context.go @@ -0,0 +1,27 @@ +/* + 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 . +*/ + +package mastotypes + +// Context represents the tree around a given status. Used for reconstructing threads of statuses. See: https://docs.joinmastodon.org/entities/context/ +type Context struct { + // Parents in the thread. + Ancestors []Status `json:"ancestors"` + // Children in the thread. + Descendants []Status `json:"descendants"` +} diff --git a/pkg/mastotypes/conversation.go b/pkg/mastotypes/conversation.go new file mode 100644 index 000000000..ed95c124c --- /dev/null +++ b/pkg/mastotypes/conversation.go @@ -0,0 +1,36 @@ +/* + 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 . +*/ + +package mastotypes + +// Conversation represents a conversation with "direct message" visibility. See https://docs.joinmastodon.org/entities/conversation/ +type Conversation struct { + // REQUIRED + + // Local database ID of the conversation. + ID string `json:"id"` + // Participants in the conversation. + Accounts []Account `json:"accounts"` + // Is the conversation currently marked as unread? + Unread bool `json:"unread"` + + // OPTIONAL + + // The last status in the conversation, to be used for optional display. + LastStatus *Status `json:"last_status"` +} diff --git a/pkg/mastotypes/emoji.go b/pkg/mastotypes/emoji.go new file mode 100644 index 000000000..e9ef95460 --- /dev/null +++ b/pkg/mastotypes/emoji.go @@ -0,0 +1,38 @@ +/* + 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 . +*/ + +package mastotypes + +// Emoji represents a custom emoji. See https://docs.joinmastodon.org/entities/emoji/ +type Emoji struct { + // REQUIRED + + // The name of the custom emoji. + Shortcode string `json:"shortcode"` + // A link to the custom emoji. + URL string `json:"url"` + // A link to a static copy of the custom emoji. + StaticURL string `json:"static_url"` + // Whether this Emoji should be visible in the picker or unlisted. + VisibleInPicker bool `json:"visible_in_picker"` + + // OPTIONAL + + // Used for sorting custom emoji in the picker. + Category string `json:"category,omitempty"` +} diff --git a/pkg/mastotypes/error.go b/pkg/mastotypes/error.go new file mode 100644 index 000000000..394085724 --- /dev/null +++ b/pkg/mastotypes/error.go @@ -0,0 +1,32 @@ +/* + 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 . +*/ + +package mastotypes + +// Error represents an error message returned from the API. See https://docs.joinmastodon.org/entities/error/ +type Error struct { + // REQUIRED + + // The error message. + Error string `json:"error"` + + // OPTIONAL + + // A longer description of the error, mainly provided with the OAuth API. + ErrorDescription string `json:"error_description"` +} diff --git a/pkg/mastotypes/featuredtag.go b/pkg/mastotypes/featuredtag.go new file mode 100644 index 000000000..0e0bbe802 --- /dev/null +++ b/pkg/mastotypes/featuredtag.go @@ -0,0 +1,33 @@ +/* + 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 . +*/ + +package mastotypes + +// FeaturedTag represents a hashtag that is featured on a profile. See https://docs.joinmastodon.org/entities/featuredtag/ +type FeaturedTag struct { + // The internal ID of the featured tag in the database. + ID string `json:"id"` + // The name of the hashtag being featured. + Name string `json:"name"` + // A link to all statuses by a user that contain this hashtag. + URL string `json:"url"` + // The number of authored statuses containing this hashtag. + StatusesCount int `json:"statuses_count"` + // The timestamp of the last authored status containing this hashtag. (ISO 8601 Datetime) + LastStatusAt string `json:"last_status_at"` +} diff --git a/pkg/mastotypes/field.go b/pkg/mastotypes/field.go new file mode 100644 index 000000000..dbfe08c54 --- /dev/null +++ b/pkg/mastotypes/field.go @@ -0,0 +1,34 @@ +/* + 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 . +*/ + +package mastotypes + +// Field represents a profile field as a name-value pair with optional verification. See https://docs.joinmastodon.org/entities/field/ +type Field struct { + // REQUIRED + + // The key of a given field's key-value pair. + Name string `json:"name"` + // The value associated with the name key. + Value string `json:"value"` + + // OPTIONAL + + // Timestamp of when the server verified a URL value for a rel="me” link. String (ISO 8601 Datetime) if value is a verified URL + VerifiedAt string `json:"verified_at,omitempty"` +} diff --git a/pkg/mastotypes/filter.go b/pkg/mastotypes/filter.go new file mode 100644 index 000000000..86d9795a3 --- /dev/null +++ b/pkg/mastotypes/filter.go @@ -0,0 +1,46 @@ +/* + 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 . +*/ + +package mastotypes + +// Filter represents a user-defined filter for determining which statuses should not be shown to the user. See https://docs.joinmastodon.org/entities/filter/ +// If whole_word is true , client app should do: +// Define ‘word constituent character’ for your app. In the official implementation, it’s [A-Za-z0-9_] in JavaScript, and [[:word:]] in Ruby. +// Ruby uses the POSIX character class (Letter | Mark | Decimal_Number | Connector_Punctuation). +// If the phrase starts with a word character, and if the previous character before matched range is a word character, its matched range should be treated to not match. +// If the phrase ends with a word character, and if the next character after matched range is a word character, its matched range should be treated to not match. +// Please check app/javascript/mastodon/selectors/index.js and app/lib/feed_manager.rb in the Mastodon source code for more details. +type Filter struct { + // The ID of the filter in the database. + ID string `json:"id"` + // The text to be filtered. + Phrase string `json:"text"` + // The contexts in which the filter should be applied. + // Array of String (Enumerable anyOf) + // home = home timeline and lists + // notifications = notifications timeline + // public = public timelines + // thread = expanded thread of a detailed status + Context []string `json:"context"` + // Should the filter consider word boundaries? + WholeWord bool `json:"whole_word"` + // When the filter should no longer be applied (ISO 8601 Datetime), or null if the filter does not expire + ExpiresAt string `json:"expires_at,omitempty"` + // Should matching entities in home and notifications be dropped by the server? + Irreversible bool `json:"irreversible"` +} diff --git a/pkg/mastotypes/history.go b/pkg/mastotypes/history.go new file mode 100644 index 000000000..235761378 --- /dev/null +++ b/pkg/mastotypes/history.go @@ -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 . +*/ + +package mastotypes + +// History represents daily usage history of a hashtag. See https://docs.joinmastodon.org/entities/history/ +type History struct { + // UNIX timestamp on midnight of the given day (string cast from integer). + Day string `json:"day"` + // The counted usage of the tag within that day (string cast from integer). + Uses string `json:"uses"` + // The total of accounts using the tag within that day (string cast from integer). + Accounts string `json:"accounts"` +} diff --git a/pkg/mastotypes/identityproof.go b/pkg/mastotypes/identityproof.go new file mode 100644 index 000000000..7265d46e3 --- /dev/null +++ b/pkg/mastotypes/identityproof.go @@ -0,0 +1,33 @@ +/* + 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 . +*/ + +package mastotypes + +// IdentityProof represents a proof from an external identity provider. See https://docs.joinmastodon.org/entities/identityproof/ +type IdentityProof struct { + // The name of the identity provider. + Provider string `json:"provider"` + // The account owner's username on the identity provider's service. + ProviderUsername string `json:"provider_username"` + // The account owner's profile URL on the identity provider. + ProfileURL string `json:"profile_url"` + // A link to a statement of identity proof, hosted by the identity provider. + ProofURL string `json:"proof_url"` + // When the identity proof was last updated. + UpdatedAt string `json:"updated_at"` +} diff --git a/pkg/mastotypes/instance.go b/pkg/mastotypes/instance.go new file mode 100644 index 000000000..10e626a8e --- /dev/null +++ b/pkg/mastotypes/instance.go @@ -0,0 +1,72 @@ +/* + 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 . +*/ + +package mastotypes + +// Instance represents the software instance of Mastodon running on this domain. See https://docs.joinmastodon.org/entities/instance/ +type Instance struct { + // REQUIRED + + // The domain name of the instance. + URI string `json:"uri"` + // The title of the website. + Title string `json:"title"` + // Admin-defined description of the Mastodon site. + Description string `json:"description"` + // A shorter description defined by the admin. + ShortDescription string `json:"short_description"` + // An email that may be contacted for any inquiries. + Email string `json:"email"` + // The version of Mastodon installed on the instance. + Version string `json:"version"` + // Primary langauges of the website and its staff. + Languages []string `json:"languages"` + // Whether registrations are enabled. + Registrations bool `json:"registrations"` + // Whether registrations require moderator approval. + ApprovalRequired bool `json:"approval_required"` + // Whether invites are enabled. + InvitesEnabled bool `json:"invites_enabled"` + // URLs of interest for clients apps. + URLS *InstanceURLs `json:"urls"` + // Statistics about how much information the instance contains. + Stats *InstanceStats `json:"stats"` + + // OPTIONAL + + // Banner image for the website. + Thumbnail string `json:"thumbnail,omitempty"` + // A user that can be contacted, as an alternative to email. + ContactAccount *Account `json:"contact_account,omitempty"` +} + +// InstanceURLs represents URLs necessary for successfully connecting to the instance as a user. See https://docs.joinmastodon.org/entities/instance/ +type InstanceURLs struct { + // Websockets address for push streaming. + StreamingAPI string `json:"streaming_api"` +} + +// InstanceStats represents some public-facing stats about the instance. See https://docs.joinmastodon.org/entities/instance/ +type InstanceStats struct { + // Users registered on this instance. + UserCount int `json:"user_count"` + // Statuses authored by users on instance. + StatusCount int `json:"status_count"` + // Domains federated with this instance. + DomainCount int `json:"domain_count"` +} diff --git a/pkg/mastotypes/list.go b/pkg/mastotypes/list.go new file mode 100644 index 000000000..5b704367b --- /dev/null +++ b/pkg/mastotypes/list.go @@ -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 . +*/ + +package mastotypes + +// List represents a list of some users that the authenticated user follows. See https://docs.joinmastodon.org/entities/list/ +type List struct { + // The internal database ID of the list. + ID string `json:"id"` + // The user-defined title of the list. + Title string `json:"title"` + // followed = Show replies to any followed user + // list = Show replies to members of the list + // none = Show replies to no one + RepliesPolicy string `json:"replies_policy"` +} diff --git a/pkg/mastotypes/marker.go b/pkg/mastotypes/marker.go new file mode 100644 index 000000000..790322313 --- /dev/null +++ b/pkg/mastotypes/marker.go @@ -0,0 +1,37 @@ +/* + 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 . +*/ + +package mastotypes + +// Marker represents the last read position within a user's timelines. See https://docs.joinmastodon.org/entities/marker/ +type Marker struct { + // Information about the user's position in the home timeline. + Home *TimelineMarker `json:"home"` + // Information about the user's position in their notifications. + Notifications *TimelineMarker `json:"notifications"` +} + +// TimelineMarker contains information about a user's progress through a specific timeline. See https://docs.joinmastodon.org/entities/marker/ +type TimelineMarker struct { + // The ID of the most recently viewed entity. + LastReadID string `json:"last_read_id"` + // The timestamp of when the marker was set (ISO 8601 Datetime) + UpdatedAt string `json:"updated_at"` + // Used for locking to prevent write conflicts. + Version string `json:"version"` +} diff --git a/pkg/mastotypes/mention.go b/pkg/mastotypes/mention.go new file mode 100644 index 000000000..81a593d99 --- /dev/null +++ b/pkg/mastotypes/mention.go @@ -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 . +*/ + +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"` +} diff --git a/pkg/mastotypes/model/account.go b/pkg/mastotypes/model/account.go deleted file mode 100644 index 031fa7c02..000000000 --- a/pkg/mastotypes/model/account.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Account represents a mastodon-api Account object, as described here: https://docs.joinmastodon.org/entities/account/ -type Account struct { - // The account id - ID string `json:"id"` - // The username of the account, not including domain. - Username string `json:"username"` - // The Webfinger account URI. Equal to username for local users, or username@domain for remote users. - Acct string `json:"acct"` - // The profile's display name. - DisplayName string `json:"display_name"` - // Whether the account manually approves follow requests. - Locked bool `json:"locked"` - // Whether the account has opted into discovery features such as the profile directory. - Discoverable bool `json:"discoverable"` - // A presentational flag. Indicates that the account may perform automated actions, may not be monitored, or identifies as a robot. - Bot bool `json:"bot"` - // When the account was created. (ISO 8601 Datetime) - CreatedAt string `json:"created_at"` - // The profile's bio / description. - Note string `json:"note"` - // The location of the user's profile page. - URL string `json:"url"` - // An image icon that is shown next to statuses and in the profile. - Avatar string `json:"avatar"` - // A static version of the avatar. Equal to avatar if its value is a static image; different if avatar is an animated GIF. - AvatarStatic string `json:"avatar_static"` - // An image banner that is shown above the profile and in profile cards. - Header string `json:"header"` - // A static version of the header. Equal to header if its value is a static image; different if header is an animated GIF. - HeaderStatic string `json:"header_static"` - // The reported followers of this profile. - FollowersCount int `json:"followers_count"` - // The reported follows of this profile. - FollowingCount int `json:"following_count"` - // How many statuses are attached to this account. - StatusesCount int `json:"statuses_count"` - // When the most recent status was posted. (ISO 8601 Datetime) - LastStatusAt string `json:"last_status_at"` - // Custom emoji entities to be used when rendering the profile. If none, an empty array will be returned. - Emojis []Emoji `json:"emojis"` - // Additional metadata attached to a profile as name-value pairs. - Fields []Field `json:"fields"` - // An extra entity returned when an account is suspended. - Suspended bool `json:"suspended"` - // When a timed mute will expire, if applicable. (ISO 8601 Datetime) - MuteExpiresAt string `json:"mute_expires_at"` - // An extra entity to be used with API methods to verify credentials and update credentials. - Source *Source `json:"source"` -} diff --git a/pkg/mastotypes/model/activity.go b/pkg/mastotypes/model/activity.go deleted file mode 100644 index b8dbf2c1b..000000000 --- a/pkg/mastotypes/model/activity.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Activity represents the mastodon-api Activity type. See here: https://docs.joinmastodon.org/entities/activity/ -type Activity struct { - // Midnight at the first day of the week. (UNIX Timestamp as string) - Week string `json:"week"` - // Statuses created since the week began. Integer cast to string. - Statuses string `json:"statuses"` - // User logins since the week began. Integer cast as string. - Logins string `json:"logins"` - // User registrations since the week began. Integer cast as string. - Registrations string `json:"registrations"` -} diff --git a/pkg/mastotypes/model/admin.go b/pkg/mastotypes/model/admin.go deleted file mode 100644 index 71c2bb309..000000000 --- a/pkg/mastotypes/model/admin.go +++ /dev/null @@ -1,81 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// AdminAccountInfo represents the *admin* view of an account's details. See here: https://docs.joinmastodon.org/entities/admin-account/ -type AdminAccountInfo struct { - // The ID of the account in the database. - ID string `json:"id"` - // The username of the account. - Username string `json:"username"` - // The domain of the account. - Domain string `json:"domain"` - // When the account was first discovered. (ISO 8601 Datetime) - CreatedAt string `json:"created_at"` - // The email address associated with the account. - Email string `json:"email"` - // The IP address last used to login to this account. - IP string `json:"ip"` - // The locale of the account. (ISO 639 Part 1 two-letter language code) - Locale string `json:"locale"` - // Invite request text - InviteRequest string `json:"invite_request"` - // The current role of the account. - Role string `json:"role"` - // Whether the account has confirmed their email address. - Confirmed bool `json:"confirmed"` - // Whether the account is currently approved. - Approved bool `json:"approved"` - // Whether the account is currently disabled. - Disabled bool `json:"disabled"` - // Whether the account is currently silenced - Silenced bool `json:"silenced"` - // Whether the account is currently suspended. - Suspended bool `json:"suspended"` - // User-level information about the account. - Account *Account `json:"account"` - // The ID of the application that created this account. - CreatedByApplicationID string `json:"created_by_application_id,omitempty"` - // The ID of the account that invited this user - InvitedByAccountID string `json:"invited_by_account_id"` -} - -// AdminReportInfo represents the *admin* view of a report. See here: https://docs.joinmastodon.org/entities/admin-report/ -type AdminReportInfo struct { - // The ID of the report in the database. - ID string `json:"id"` - // The action taken to resolve this report. - ActionTaken string `json:"action_taken"` - // An optional reason for reporting. - Comment string `json:"comment"` - // The time the report was filed. (ISO 8601 Datetime) - CreatedAt string `json:"created_at"` - // The time of last action on this report. (ISO 8601 Datetime) - UpdatedAt string `json:"updated_at"` - // The account which filed the report. - Account *Account `json:"account"` - // The account being reported. - TargetAccount *Account `json:"target_account"` - // The account of the moderator assigned to this report. - AssignedAccount *Account `json:"assigned_account"` - // The action taken by the moderator who handled the report. - ActionTakenByAccount string `json:"action_taken_by_account"` - // Statuses attached to the report, for context. - Statuses []Status `json:"statuses"` -} diff --git a/pkg/mastotypes/model/announcement.go b/pkg/mastotypes/model/announcement.go deleted file mode 100644 index 882d6bb9b..000000000 --- a/pkg/mastotypes/model/announcement.go +++ /dev/null @@ -1,37 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Announcement represents an admin/moderator announcement for local users. See here: https://docs.joinmastodon.org/entities/announcement/ -type Announcement struct { - ID string `json:"id"` - Content string `json:"content"` - StartsAt string `json:"starts_at"` - EndsAt string `json:"ends_at"` - AllDay bool `json:"all_day"` - PublishedAt string `json:"published_at"` - UpdatedAt string `json:"updated_at"` - Published bool `json:"published"` - Read bool `json:"read"` - Mentions []Mention `json:"mentions"` - Statuses []Status `json:"statuses"` - Tags []Tag `json:"tags"` - Emojis []Emoji `json:"emoji"` - Reactions []AnnouncementReaction `json:"reactions"` -} diff --git a/pkg/mastotypes/model/announcementreaction.go b/pkg/mastotypes/model/announcementreaction.go deleted file mode 100644 index 444c57e2c..000000000 --- a/pkg/mastotypes/model/announcementreaction.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// AnnouncementReaction represents a user reaction to admin/moderator announcement. See here: https://docs.joinmastodon.org/entities/announcementreaction/ -type AnnouncementReaction struct { - // The emoji used for the reaction. Either a unicode emoji, or a custom emoji's shortcode. - Name string `json:"name"` - // The total number of users who have added this reaction. - Count int `json:"count"` - // Whether the authorized user has added this reaction to the announcement. - Me bool `json:"me"` - // A link to the custom emoji. - URL string `json:"url,omitempty"` - // A link to a non-animated version of the custom emoji. - StaticURL string `json:"static_url,omitempty"` -} diff --git a/pkg/mastotypes/model/application.go b/pkg/mastotypes/model/application.go deleted file mode 100644 index d2f894306..000000000 --- a/pkg/mastotypes/model/application.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - 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 . -*/ - -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"` -} diff --git a/pkg/mastotypes/model/attachment.go b/pkg/mastotypes/model/attachment.go deleted file mode 100644 index 4d4d0955a..000000000 --- a/pkg/mastotypes/model/attachment.go +++ /dev/null @@ -1,96 +0,0 @@ -/* - 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 . -*/ - -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"` -} diff --git a/pkg/mastotypes/model/card.go b/pkg/mastotypes/model/card.go deleted file mode 100644 index d1147e04b..000000000 --- a/pkg/mastotypes/model/card.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Card represents a rich preview card that is generated using OpenGraph tags from a URL. See here: https://docs.joinmastodon.org/entities/card/ -type Card struct { - // REQUIRED - - // Location of linked resource. - URL string `json:"url"` - // Title of linked resource. - Title string `json:"title"` - // Description of preview. - Description string `json:"description"` - // The type of the preview card. - // String (Enumerable, oneOf) - // link = Link OEmbed - // photo = Photo OEmbed - // video = Video OEmbed - // rich = iframe OEmbed. Not currently accepted, so won't show up in practice. - Type string `json:"type"` - - // OPTIONAL - - // The author of the original resource. - AuthorName string `json:"author_name"` - // A link to the author of the original resource. - AuthorURL string `json:"author_url"` - // The provider of the original resource. - ProviderName string `json:"provider_name"` - // A link to the provider of the original resource. - ProviderURL string `json:"provider_url"` - // HTML to be used for generating the preview card. - HTML string `json:"html"` - // Width of preview, in pixels. - Width int `json:"width"` - // Height of preview, in pixels. - Height int `json:"height"` - // Preview thumbnail. - Image string `json:"image"` - // Used for photo embeds, instead of custom html. - EmbedURL string `json:"embed_url"` - // A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet. - Blurhash string `json:"blurhash"` -} diff --git a/pkg/mastotypes/model/context.go b/pkg/mastotypes/model/context.go deleted file mode 100644 index 397522dc7..000000000 --- a/pkg/mastotypes/model/context.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Context represents the tree around a given status. Used for reconstructing threads of statuses. See: https://docs.joinmastodon.org/entities/context/ -type Context struct { - // Parents in the thread. - Ancestors []Status `json:"ancestors"` - // Children in the thread. - Descendants []Status `json:"descendants"` -} diff --git a/pkg/mastotypes/model/conversation.go b/pkg/mastotypes/model/conversation.go deleted file mode 100644 index ed95c124c..000000000 --- a/pkg/mastotypes/model/conversation.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Conversation represents a conversation with "direct message" visibility. See https://docs.joinmastodon.org/entities/conversation/ -type Conversation struct { - // REQUIRED - - // Local database ID of the conversation. - ID string `json:"id"` - // Participants in the conversation. - Accounts []Account `json:"accounts"` - // Is the conversation currently marked as unread? - Unread bool `json:"unread"` - - // OPTIONAL - - // The last status in the conversation, to be used for optional display. - LastStatus *Status `json:"last_status"` -} diff --git a/pkg/mastotypes/model/emoji.go b/pkg/mastotypes/model/emoji.go deleted file mode 100644 index e9ef95460..000000000 --- a/pkg/mastotypes/model/emoji.go +++ /dev/null @@ -1,38 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Emoji represents a custom emoji. See https://docs.joinmastodon.org/entities/emoji/ -type Emoji struct { - // REQUIRED - - // The name of the custom emoji. - Shortcode string `json:"shortcode"` - // A link to the custom emoji. - URL string `json:"url"` - // A link to a static copy of the custom emoji. - StaticURL string `json:"static_url"` - // Whether this Emoji should be visible in the picker or unlisted. - VisibleInPicker bool `json:"visible_in_picker"` - - // OPTIONAL - - // Used for sorting custom emoji in the picker. - Category string `json:"category,omitempty"` -} diff --git a/pkg/mastotypes/model/error.go b/pkg/mastotypes/model/error.go deleted file mode 100644 index 394085724..000000000 --- a/pkg/mastotypes/model/error.go +++ /dev/null @@ -1,32 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Error represents an error message returned from the API. See https://docs.joinmastodon.org/entities/error/ -type Error struct { - // REQUIRED - - // The error message. - Error string `json:"error"` - - // OPTIONAL - - // A longer description of the error, mainly provided with the OAuth API. - ErrorDescription string `json:"error_description"` -} diff --git a/pkg/mastotypes/model/featuredtag.go b/pkg/mastotypes/model/featuredtag.go deleted file mode 100644 index 0e0bbe802..000000000 --- a/pkg/mastotypes/model/featuredtag.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// FeaturedTag represents a hashtag that is featured on a profile. See https://docs.joinmastodon.org/entities/featuredtag/ -type FeaturedTag struct { - // The internal ID of the featured tag in the database. - ID string `json:"id"` - // The name of the hashtag being featured. - Name string `json:"name"` - // A link to all statuses by a user that contain this hashtag. - URL string `json:"url"` - // The number of authored statuses containing this hashtag. - StatusesCount int `json:"statuses_count"` - // The timestamp of the last authored status containing this hashtag. (ISO 8601 Datetime) - LastStatusAt string `json:"last_status_at"` -} diff --git a/pkg/mastotypes/model/field.go b/pkg/mastotypes/model/field.go deleted file mode 100644 index dbfe08c54..000000000 --- a/pkg/mastotypes/model/field.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Field represents a profile field as a name-value pair with optional verification. See https://docs.joinmastodon.org/entities/field/ -type Field struct { - // REQUIRED - - // The key of a given field's key-value pair. - Name string `json:"name"` - // The value associated with the name key. - Value string `json:"value"` - - // OPTIONAL - - // Timestamp of when the server verified a URL value for a rel="me” link. String (ISO 8601 Datetime) if value is a verified URL - VerifiedAt string `json:"verified_at,omitempty"` -} diff --git a/pkg/mastotypes/model/filter.go b/pkg/mastotypes/model/filter.go deleted file mode 100644 index 86d9795a3..000000000 --- a/pkg/mastotypes/model/filter.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Filter represents a user-defined filter for determining which statuses should not be shown to the user. See https://docs.joinmastodon.org/entities/filter/ -// If whole_word is true , client app should do: -// Define ‘word constituent character’ for your app. In the official implementation, it’s [A-Za-z0-9_] in JavaScript, and [[:word:]] in Ruby. -// Ruby uses the POSIX character class (Letter | Mark | Decimal_Number | Connector_Punctuation). -// If the phrase starts with a word character, and if the previous character before matched range is a word character, its matched range should be treated to not match. -// If the phrase ends with a word character, and if the next character after matched range is a word character, its matched range should be treated to not match. -// Please check app/javascript/mastodon/selectors/index.js and app/lib/feed_manager.rb in the Mastodon source code for more details. -type Filter struct { - // The ID of the filter in the database. - ID string `json:"id"` - // The text to be filtered. - Phrase string `json:"text"` - // The contexts in which the filter should be applied. - // Array of String (Enumerable anyOf) - // home = home timeline and lists - // notifications = notifications timeline - // public = public timelines - // thread = expanded thread of a detailed status - Context []string `json:"context"` - // Should the filter consider word boundaries? - WholeWord bool `json:"whole_word"` - // When the filter should no longer be applied (ISO 8601 Datetime), or null if the filter does not expire - ExpiresAt string `json:"expires_at,omitempty"` - // Should matching entities in home and notifications be dropped by the server? - Irreversible bool `json:"irreversible"` -} diff --git a/pkg/mastotypes/model/history.go b/pkg/mastotypes/model/history.go deleted file mode 100644 index 235761378..000000000 --- a/pkg/mastotypes/model/history.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// History represents daily usage history of a hashtag. See https://docs.joinmastodon.org/entities/history/ -type History struct { - // UNIX timestamp on midnight of the given day (string cast from integer). - Day string `json:"day"` - // The counted usage of the tag within that day (string cast from integer). - Uses string `json:"uses"` - // The total of accounts using the tag within that day (string cast from integer). - Accounts string `json:"accounts"` -} diff --git a/pkg/mastotypes/model/identityproof.go b/pkg/mastotypes/model/identityproof.go deleted file mode 100644 index 7265d46e3..000000000 --- a/pkg/mastotypes/model/identityproof.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// IdentityProof represents a proof from an external identity provider. See https://docs.joinmastodon.org/entities/identityproof/ -type IdentityProof struct { - // The name of the identity provider. - Provider string `json:"provider"` - // The account owner's username on the identity provider's service. - ProviderUsername string `json:"provider_username"` - // The account owner's profile URL on the identity provider. - ProfileURL string `json:"profile_url"` - // A link to a statement of identity proof, hosted by the identity provider. - ProofURL string `json:"proof_url"` - // When the identity proof was last updated. - UpdatedAt string `json:"updated_at"` -} diff --git a/pkg/mastotypes/model/instance.go b/pkg/mastotypes/model/instance.go deleted file mode 100644 index 10e626a8e..000000000 --- a/pkg/mastotypes/model/instance.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Instance represents the software instance of Mastodon running on this domain. See https://docs.joinmastodon.org/entities/instance/ -type Instance struct { - // REQUIRED - - // The domain name of the instance. - URI string `json:"uri"` - // The title of the website. - Title string `json:"title"` - // Admin-defined description of the Mastodon site. - Description string `json:"description"` - // A shorter description defined by the admin. - ShortDescription string `json:"short_description"` - // An email that may be contacted for any inquiries. - Email string `json:"email"` - // The version of Mastodon installed on the instance. - Version string `json:"version"` - // Primary langauges of the website and its staff. - Languages []string `json:"languages"` - // Whether registrations are enabled. - Registrations bool `json:"registrations"` - // Whether registrations require moderator approval. - ApprovalRequired bool `json:"approval_required"` - // Whether invites are enabled. - InvitesEnabled bool `json:"invites_enabled"` - // URLs of interest for clients apps. - URLS *InstanceURLs `json:"urls"` - // Statistics about how much information the instance contains. - Stats *InstanceStats `json:"stats"` - - // OPTIONAL - - // Banner image for the website. - Thumbnail string `json:"thumbnail,omitempty"` - // A user that can be contacted, as an alternative to email. - ContactAccount *Account `json:"contact_account,omitempty"` -} - -// InstanceURLs represents URLs necessary for successfully connecting to the instance as a user. See https://docs.joinmastodon.org/entities/instance/ -type InstanceURLs struct { - // Websockets address for push streaming. - StreamingAPI string `json:"streaming_api"` -} - -// InstanceStats represents some public-facing stats about the instance. See https://docs.joinmastodon.org/entities/instance/ -type InstanceStats struct { - // Users registered on this instance. - UserCount int `json:"user_count"` - // Statuses authored by users on instance. - StatusCount int `json:"status_count"` - // Domains federated with this instance. - DomainCount int `json:"domain_count"` -} diff --git a/pkg/mastotypes/model/list.go b/pkg/mastotypes/model/list.go deleted file mode 100644 index 5b704367b..000000000 --- a/pkg/mastotypes/model/list.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// List represents a list of some users that the authenticated user follows. See https://docs.joinmastodon.org/entities/list/ -type List struct { - // The internal database ID of the list. - ID string `json:"id"` - // The user-defined title of the list. - Title string `json:"title"` - // followed = Show replies to any followed user - // list = Show replies to members of the list - // none = Show replies to no one - RepliesPolicy string `json:"replies_policy"` -} diff --git a/pkg/mastotypes/model/marker.go b/pkg/mastotypes/model/marker.go deleted file mode 100644 index 790322313..000000000 --- a/pkg/mastotypes/model/marker.go +++ /dev/null @@ -1,37 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Marker represents the last read position within a user's timelines. See https://docs.joinmastodon.org/entities/marker/ -type Marker struct { - // Information about the user's position in the home timeline. - Home *TimelineMarker `json:"home"` - // Information about the user's position in their notifications. - Notifications *TimelineMarker `json:"notifications"` -} - -// TimelineMarker contains information about a user's progress through a specific timeline. See https://docs.joinmastodon.org/entities/marker/ -type TimelineMarker struct { - // The ID of the most recently viewed entity. - LastReadID string `json:"last_read_id"` - // The timestamp of when the marker was set (ISO 8601 Datetime) - UpdatedAt string `json:"updated_at"` - // Used for locking to prevent write conflicts. - Version string `json:"version"` -} diff --git a/pkg/mastotypes/model/mention.go b/pkg/mastotypes/model/mention.go deleted file mode 100644 index 81a593d99..000000000 --- a/pkg/mastotypes/model/mention.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - 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 . -*/ - -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"` -} diff --git a/pkg/mastotypes/model/notification.go b/pkg/mastotypes/model/notification.go deleted file mode 100644 index 26d361b43..000000000 --- a/pkg/mastotypes/model/notification.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Notification represents a notification of an event relevant to the user. See https://docs.joinmastodon.org/entities/notification/ -type Notification struct { - // REQUIRED - - // The id of the notification in the database. - ID string `json:"id"` - // The type of event that resulted in the notification. - // follow = Someone followed you - // follow_request = Someone requested to follow you - // mention = Someone mentioned you in their status - // reblog = Someone boosted one of your statuses - // favourite = Someone favourited one of your statuses - // poll = A poll you have voted in or created has ended - // status = Someone you enabled notifications for has posted a status - Type string `json:"type"` - // The timestamp of the notification (ISO 8601 Datetime) - CreatedAt string `json:"created_at"` - // The account that performed the action that generated the notification. - Account *Account `json:"account"` - - // OPTIONAL - - // Status that was the object of the notification, e.g. in mentions, reblogs, favourites, or polls. - Status *Status `json:"status"` -} diff --git a/pkg/mastotypes/model/poll.go b/pkg/mastotypes/model/poll.go deleted file mode 100644 index bedaebec2..000000000 --- a/pkg/mastotypes/model/poll.go +++ /dev/null @@ -1,64 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Poll represents the mastodon-api poll type, as described here: https://docs.joinmastodon.org/entities/poll/ -type Poll struct { - // The ID of the poll in the database. - ID string `json:"id"` - // When the poll ends. (ISO 8601 Datetime), or null if the poll does not end - ExpiresAt string `json:"expires_at"` - // Is the poll currently expired? - Expired bool `json:"expired"` - // Does the poll allow multiple-choice answers? - Multiple bool `json:"multiple"` - // How many votes have been received. - VotesCount int `json:"votes_count"` - // How many unique accounts have voted on a multiple-choice poll. Null if multiple is false. - VotersCount int `json:"voters_count,omitempty"` - // When called with a user token, has the authorized user voted? - Voted bool `json:"voted,omitempty"` - // When called with a user token, which options has the authorized user chosen? Contains an array of index values for options. - OwnVotes []int `json:"own_votes,omitempty"` - // Possible answers for the poll. - Options []PollOptions `json:"options"` - // Custom emoji to be used for rendering poll options. - Emojis []Emoji `json:"emojis"` -} - -// PollOptions represents the current vote counts for different poll options -type PollOptions struct { - // The text value of the poll option. String. - Title string `json:"title"` - // The number of received votes for this option. Number, or null if results are not published yet. - VotesCount int `json:"votes_count,omitempty"` -} - -// 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://example.org/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"` -} diff --git a/pkg/mastotypes/model/preferences.go b/pkg/mastotypes/model/preferences.go deleted file mode 100644 index c28f5d5ab..000000000 --- a/pkg/mastotypes/model/preferences.go +++ /dev/null @@ -1,40 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Preferences represents a user's preferences. See https://docs.joinmastodon.org/entities/preferences/ -type Preferences struct { - // Default visibility for new posts. - // public = Public post - // unlisted = Unlisted post - // private = Followers-only post - // direct = Direct post - PostingDefaultVisibility string `json:"posting:default:visibility"` - // Default sensitivity flag for new posts. - PostingDefaultSensitive bool `json:"posting:default:sensitive"` - // Default language for new posts. (ISO 639-1 language two-letter code), or null - PostingDefaultLanguage string `json:"posting:default:language,omitempty"` - // Whether media attachments should be automatically displayed or blurred/hidden. - // default = Hide media marked as sensitive - // show_all = Always show all media by default, regardless of sensitivity - // hide_all = Always hide all media by default, regardless of sensitivity - ReadingExpandMedia string `json:"reading:expand:media"` - // Whether CWs should be expanded by default. - ReadingExpandSpoilers bool `json:"reading:expand:spoilers"` -} diff --git a/pkg/mastotypes/model/pushsubscription.go b/pkg/mastotypes/model/pushsubscription.go deleted file mode 100644 index 4d7535100..000000000 --- a/pkg/mastotypes/model/pushsubscription.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// PushSubscription represents a subscription to the push streaming server. See https://docs.joinmastodon.org/entities/pushsubscription/ -type PushSubscription struct { - // The id of the push subscription in the database. - ID string `json:"id"` - // Where push alerts will be sent to. - Endpoint string `json:"endpoint"` - // The streaming server's VAPID key. - ServerKey string `json:"server_key"` - // Which alerts should be delivered to the endpoint. - Alerts *PushSubscriptionAlerts `json:"alerts"` -} - -// PushSubscriptionAlerts represents the specific alerts that this push subscription will give. -type PushSubscriptionAlerts struct { - // Receive a push notification when someone has followed you? - Follow bool `json:"follow"` - // Receive a push notification when a status you created has been favourited by someone else? - Favourite bool `json:"favourite"` - // Receive a push notification when someone else has mentioned you in a status? - Mention bool `json:"mention"` - // Receive a push notification when a status you created has been boosted by someone else? - Reblog bool `json:"reblog"` - // Receive a push notification when a poll you voted in or created has ended? - Poll bool `json:"poll"` -} diff --git a/pkg/mastotypes/model/relationship.go b/pkg/mastotypes/model/relationship.go deleted file mode 100644 index 1e0bbab46..000000000 --- a/pkg/mastotypes/model/relationship.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Relationship represents a relationship between accounts. See https://docs.joinmastodon.org/entities/relationship/ -type Relationship struct { - // The account id. - ID string `json:"id"` - // Are you following this user? - Following bool `json:"following"` - // Are you receiving this user's boosts in your home timeline? - ShowingReblogs bool `json:"showing_reblogs"` - // Have you enabled notifications for this user? - Notifying bool `json:"notifying"` - // Are you followed by this user? - FollowedBy bool `json:"followed_by"` - // Are you blocking this user? - Blocking bool `json:"blocking"` - // Is this user blocking you? - BlockedBy bool `json:"blocked_by"` - // Are you muting this user? - Muting bool `json:"muting"` - // Are you muting notifications from this user? - MutingNotifications bool `json:"muting_notifications"` - // Do you have a pending follow request for this user? - Requested bool `json:"requested"` - // Are you blocking this user's domain? - DomainBlocking bool `json:"domain_blocking"` - // Are you featuring this user on your profile? - Endorsed bool `json:"endorsed"` - // Your note on this account. - Note string `json:"note"` -} diff --git a/pkg/mastotypes/model/results.go b/pkg/mastotypes/model/results.go deleted file mode 100644 index 3fa7c7abb..000000000 --- a/pkg/mastotypes/model/results.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// Results represents the results of a search. See https://docs.joinmastodon.org/entities/results/ -type Results struct { - // Accounts which match the given query - Accounts []Account `json:"accounts"` - // Statuses which match the given query - Statuses []Status `json:"statuses"` - // Hashtags which match the given query - Hashtags []Tag `json:"hashtags"` -} diff --git a/pkg/mastotypes/model/scheduledstatus.go b/pkg/mastotypes/model/scheduledstatus.go deleted file mode 100644 index ff45eaade..000000000 --- a/pkg/mastotypes/model/scheduledstatus.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -// ScheduledStatus represents a status that will be published at a future scheduled date. See https://docs.joinmastodon.org/entities/scheduledstatus/ -type ScheduledStatus struct { - ID string `json:"id"` - ScheduledAt string `json:"scheduled_at"` - Params *StatusParams `json:"params"` - MediaAttachments []Attachment `json:"media_attachments"` -} - -// StatusParams represents parameters for a scheduled status. See https://docs.joinmastodon.org/entities/scheduledstatus/ -type StatusParams struct { - Text string `json:"text"` - InReplyToID string `json:"in_reply_to_id,omitempty"` - MediaIDs []string `json:"media_ids,omitempty"` - Sensitive bool `json:"sensitive,omitempty"` - SpoilerText string `json:"spoiler_text,omitempty"` - Visibility string `json:"visibility"` - ScheduledAt string `json:"scheduled_at,omitempty"` - ApplicationID string `json:"application_id"` -} diff --git a/pkg/mastotypes/model/source.go b/pkg/mastotypes/model/source.go deleted file mode 100644 index e4a2ca06a..000000000 --- a/pkg/mastotypes/model/source.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -type Source struct { -} diff --git a/pkg/mastotypes/model/status.go b/pkg/mastotypes/model/status.go deleted file mode 100644 index e98504e27..000000000 --- a/pkg/mastotypes/model/status.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - 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 . -*/ - -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"` -} diff --git a/pkg/mastotypes/model/tag.go b/pkg/mastotypes/model/tag.go deleted file mode 100644 index d34314b0b..000000000 --- a/pkg/mastotypes/model/tag.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - 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 . -*/ - -package mastotypes - -type Tag struct { -} diff --git a/pkg/mastotypes/notification.go b/pkg/mastotypes/notification.go new file mode 100644 index 000000000..26d361b43 --- /dev/null +++ b/pkg/mastotypes/notification.go @@ -0,0 +1,45 @@ +/* + 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 . +*/ + +package mastotypes + +// Notification represents a notification of an event relevant to the user. See https://docs.joinmastodon.org/entities/notification/ +type Notification struct { + // REQUIRED + + // The id of the notification in the database. + ID string `json:"id"` + // The type of event that resulted in the notification. + // follow = Someone followed you + // follow_request = Someone requested to follow you + // mention = Someone mentioned you in their status + // reblog = Someone boosted one of your statuses + // favourite = Someone favourited one of your statuses + // poll = A poll you have voted in or created has ended + // status = Someone you enabled notifications for has posted a status + Type string `json:"type"` + // The timestamp of the notification (ISO 8601 Datetime) + CreatedAt string `json:"created_at"` + // The account that performed the action that generated the notification. + Account *Account `json:"account"` + + // OPTIONAL + + // Status that was the object of the notification, e.g. in mentions, reblogs, favourites, or polls. + Status *Status `json:"status"` +} diff --git a/pkg/mastotypes/poll.go b/pkg/mastotypes/poll.go new file mode 100644 index 000000000..bedaebec2 --- /dev/null +++ b/pkg/mastotypes/poll.go @@ -0,0 +1,64 @@ +/* + 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 . +*/ + +package mastotypes + +// Poll represents the mastodon-api poll type, as described here: https://docs.joinmastodon.org/entities/poll/ +type Poll struct { + // The ID of the poll in the database. + ID string `json:"id"` + // When the poll ends. (ISO 8601 Datetime), or null if the poll does not end + ExpiresAt string `json:"expires_at"` + // Is the poll currently expired? + Expired bool `json:"expired"` + // Does the poll allow multiple-choice answers? + Multiple bool `json:"multiple"` + // How many votes have been received. + VotesCount int `json:"votes_count"` + // How many unique accounts have voted on a multiple-choice poll. Null if multiple is false. + VotersCount int `json:"voters_count,omitempty"` + // When called with a user token, has the authorized user voted? + Voted bool `json:"voted,omitempty"` + // When called with a user token, which options has the authorized user chosen? Contains an array of index values for options. + OwnVotes []int `json:"own_votes,omitempty"` + // Possible answers for the poll. + Options []PollOptions `json:"options"` + // Custom emoji to be used for rendering poll options. + Emojis []Emoji `json:"emojis"` +} + +// PollOptions represents the current vote counts for different poll options +type PollOptions struct { + // The text value of the poll option. String. + Title string `json:"title"` + // The number of received votes for this option. Number, or null if results are not published yet. + VotesCount int `json:"votes_count,omitempty"` +} + +// 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://example.org/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"` +} diff --git a/pkg/mastotypes/preferences.go b/pkg/mastotypes/preferences.go new file mode 100644 index 000000000..c28f5d5ab --- /dev/null +++ b/pkg/mastotypes/preferences.go @@ -0,0 +1,40 @@ +/* + 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 . +*/ + +package mastotypes + +// Preferences represents a user's preferences. See https://docs.joinmastodon.org/entities/preferences/ +type Preferences struct { + // Default visibility for new posts. + // public = Public post + // unlisted = Unlisted post + // private = Followers-only post + // direct = Direct post + PostingDefaultVisibility string `json:"posting:default:visibility"` + // Default sensitivity flag for new posts. + PostingDefaultSensitive bool `json:"posting:default:sensitive"` + // Default language for new posts. (ISO 639-1 language two-letter code), or null + PostingDefaultLanguage string `json:"posting:default:language,omitempty"` + // Whether media attachments should be automatically displayed or blurred/hidden. + // default = Hide media marked as sensitive + // show_all = Always show all media by default, regardless of sensitivity + // hide_all = Always hide all media by default, regardless of sensitivity + ReadingExpandMedia string `json:"reading:expand:media"` + // Whether CWs should be expanded by default. + ReadingExpandSpoilers bool `json:"reading:expand:spoilers"` +} diff --git a/pkg/mastotypes/pushsubscription.go b/pkg/mastotypes/pushsubscription.go new file mode 100644 index 000000000..4d7535100 --- /dev/null +++ b/pkg/mastotypes/pushsubscription.go @@ -0,0 +1,45 @@ +/* + 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 . +*/ + +package mastotypes + +// PushSubscription represents a subscription to the push streaming server. See https://docs.joinmastodon.org/entities/pushsubscription/ +type PushSubscription struct { + // The id of the push subscription in the database. + ID string `json:"id"` + // Where push alerts will be sent to. + Endpoint string `json:"endpoint"` + // The streaming server's VAPID key. + ServerKey string `json:"server_key"` + // Which alerts should be delivered to the endpoint. + Alerts *PushSubscriptionAlerts `json:"alerts"` +} + +// PushSubscriptionAlerts represents the specific alerts that this push subscription will give. +type PushSubscriptionAlerts struct { + // Receive a push notification when someone has followed you? + Follow bool `json:"follow"` + // Receive a push notification when a status you created has been favourited by someone else? + Favourite bool `json:"favourite"` + // Receive a push notification when someone else has mentioned you in a status? + Mention bool `json:"mention"` + // Receive a push notification when a status you created has been boosted by someone else? + Reblog bool `json:"reblog"` + // Receive a push notification when a poll you voted in or created has ended? + Poll bool `json:"poll"` +} diff --git a/pkg/mastotypes/relationship.go b/pkg/mastotypes/relationship.go new file mode 100644 index 000000000..1e0bbab46 --- /dev/null +++ b/pkg/mastotypes/relationship.go @@ -0,0 +1,49 @@ +/* + 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 . +*/ + +package mastotypes + +// Relationship represents a relationship between accounts. See https://docs.joinmastodon.org/entities/relationship/ +type Relationship struct { + // The account id. + ID string `json:"id"` + // Are you following this user? + Following bool `json:"following"` + // Are you receiving this user's boosts in your home timeline? + ShowingReblogs bool `json:"showing_reblogs"` + // Have you enabled notifications for this user? + Notifying bool `json:"notifying"` + // Are you followed by this user? + FollowedBy bool `json:"followed_by"` + // Are you blocking this user? + Blocking bool `json:"blocking"` + // Is this user blocking you? + BlockedBy bool `json:"blocked_by"` + // Are you muting this user? + Muting bool `json:"muting"` + // Are you muting notifications from this user? + MutingNotifications bool `json:"muting_notifications"` + // Do you have a pending follow request for this user? + Requested bool `json:"requested"` + // Are you blocking this user's domain? + DomainBlocking bool `json:"domain_blocking"` + // Are you featuring this user on your profile? + Endorsed bool `json:"endorsed"` + // Your note on this account. + Note string `json:"note"` +} diff --git a/pkg/mastotypes/results.go b/pkg/mastotypes/results.go new file mode 100644 index 000000000..3fa7c7abb --- /dev/null +++ b/pkg/mastotypes/results.go @@ -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 . +*/ + +package mastotypes + +// Results represents the results of a search. See https://docs.joinmastodon.org/entities/results/ +type Results struct { + // Accounts which match the given query + Accounts []Account `json:"accounts"` + // Statuses which match the given query + Statuses []Status `json:"statuses"` + // Hashtags which match the given query + Hashtags []Tag `json:"hashtags"` +} diff --git a/pkg/mastotypes/scheduledstatus.go b/pkg/mastotypes/scheduledstatus.go new file mode 100644 index 000000000..ff45eaade --- /dev/null +++ b/pkg/mastotypes/scheduledstatus.go @@ -0,0 +1,39 @@ +/* + 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 . +*/ + +package mastotypes + +// ScheduledStatus represents a status that will be published at a future scheduled date. See https://docs.joinmastodon.org/entities/scheduledstatus/ +type ScheduledStatus struct { + ID string `json:"id"` + ScheduledAt string `json:"scheduled_at"` + Params *StatusParams `json:"params"` + MediaAttachments []Attachment `json:"media_attachments"` +} + +// StatusParams represents parameters for a scheduled status. See https://docs.joinmastodon.org/entities/scheduledstatus/ +type StatusParams struct { + Text string `json:"text"` + InReplyToID string `json:"in_reply_to_id,omitempty"` + MediaIDs []string `json:"media_ids,omitempty"` + Sensitive bool `json:"sensitive,omitempty"` + SpoilerText string `json:"spoiler_text,omitempty"` + Visibility string `json:"visibility"` + ScheduledAt string `json:"scheduled_at,omitempty"` + ApplicationID string `json:"application_id"` +} diff --git a/pkg/mastotypes/source.go b/pkg/mastotypes/source.go new file mode 100644 index 000000000..e4a2ca06a --- /dev/null +++ b/pkg/mastotypes/source.go @@ -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 . +*/ + +package mastotypes + +type Source struct { +} diff --git a/pkg/mastotypes/status.go b/pkg/mastotypes/status.go new file mode 100644 index 000000000..e98504e27 --- /dev/null +++ b/pkg/mastotypes/status.go @@ -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 . +*/ + +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"` +} diff --git a/pkg/mastotypes/tag.go b/pkg/mastotypes/tag.go new file mode 100644 index 000000000..d34314b0b --- /dev/null +++ b/pkg/mastotypes/tag.go @@ -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 . +*/ + +package mastotypes + +type Tag struct { +} -- cgit v1.2.3