From 51e9e5014515a5c12023c5b7c7d2e075bec884c2 Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Sun, 28 Mar 2021 18:47:42 +0200 Subject: [PATCH] update mastotypes --- pkg/mastotypes/account.go | 44 +++++++++++++++++++++++++++++++++++++++ pkg/mastotypes/source.go | 16 ++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/pkg/mastotypes/account.go b/pkg/mastotypes/account.go index 1a37d14..6ab5b04 100644 --- a/pkg/mastotypes/account.go +++ b/pkg/mastotypes/account.go @@ -18,6 +18,8 @@ package mastotypes +import "mime/multipart" + // Account represents a mastodon-api Account object, as described here: https://docs.joinmastodon.org/entities/account/ type Account struct { // The account id @@ -85,3 +87,45 @@ type AccountCreateRequest struct { // The language of the confirmation email that will be sent Locale string `form:"locale" binding:"required"` } + +// UpdateCredentialsRequest represents the form submitted during a PATCH request to /api/v1/accounts/update_credentials. +// See https://docs.joinmastodon.org/methods/accounts/ +type UpdateCredentialsRequest struct { + // Whether the account should be shown in the profile directory. + Discoverable string `form:"discoverable"` + // Whether the account has a bot flag. + Bot bool `form:"bot"` + // The display name to use for the profile. + DisplayName string `form:"display_name"` + // The account bio. + Note string `form:"note"` + // Avatar image encoded using multipart/form-data + Avatar *multipart.FileHeader `form:"avatar"` + // Header image encoded using multipart/form-data + Header *multipart.FileHeader `form:"header"` + // Whether manual approval of follow requests is required. + Locked bool `form:"locked"` + // New Source values for this account + Source *UpdateSource `form:"source"` + // Profile metadata name and value + FieldsAttributes []UpdateField `form:"fields_attributes"` +} + +// UpdateSource is to be used specifically in an UpdateCredentialsRequest. +type UpdateSource struct { + // Default post privacy for authored statuses. + Privacy string `form:"privacy"` + // Whether to mark authored statuses as sensitive by default. + Sensitive bool `form:"sensitive"` + // Default language to use for authored statuses. (ISO 6391) + Language string `form:"language"` +} + +// UpdateField is to be used specifically in an UpdateCredentialsRequest. +// By default, max 4 fields and 255 characters per property/value. +type UpdateField struct { + // Name of the field + Name string `form:"name"` + // Value of the field + Value string `form:"value"` +} diff --git a/pkg/mastotypes/source.go b/pkg/mastotypes/source.go index 01a8776..4142540 100644 --- a/pkg/mastotypes/source.go +++ b/pkg/mastotypes/source.go @@ -22,4 +22,20 @@ package mastotypes // Returned as an additional entity when verifying and updated credentials, as an attribute of Account. // See https://docs.joinmastodon.org/entities/source/ type Source struct { + // The default post privacy to be used for new statuses. + // public = Public post + // unlisted = Unlisted post + // private = Followers-only post + // direct = Direct post + Privacy string `json:"privacy,omitempty"` + // Whether new statuses should be marked sensitive by default. + Sensitive bool `json:"sensitive,omitempty"` + // The default posting language for new statuses. + Language string `json:"language,omitempty"` + // Profile bio. + Note string `json:"note"` + // Metadata about the account. + Fields []Field `json:"fields"` + // The number of pending follow requests. + FollowRequestsCount int `json:"follow_requests_count,omitempty"` }