From 5543fd53400037dc8ae22d4919b7085c46177ce1 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:07:25 +0200 Subject: [feature/frontend] Add options to include Unlisted posts or hide all posts (#3272) * [feature/frontend] Add options to include Unlisted posts or hide all posts * finish up * swagger * move invalidate call into bundb package, avoid invalidating if not necessary * rename show_web_statuses => web_visibility * don't use ptr for webvisibility * last bits --- internal/api/client/accounts/accountupdate.go | 12 +++++++++++- internal/api/model/account.go | 3 +++ internal/api/model/source.go | 5 +++++ internal/api/model/status.go | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) (limited to 'internal/api') diff --git a/internal/api/client/accounts/accountupdate.go b/internal/api/client/accounts/accountupdate.go index f81f54db0..5d3a3da5f 100644 --- a/internal/api/client/accounts/accountupdate.go +++ b/internal/api/client/accounts/accountupdate.go @@ -145,6 +145,15 @@ import ( // description: Hide the account's following/followers collections. // type: boolean // - +// name: web_visibility +// in: formData +// description: |- +// Posts to show on the web view of the account. +// "public": default, show only Public visibility posts on the web. +// "unlisted": show Public *and* Unlisted visibility posts on the web. +// "none": show no posts on the web, not even Public ones. +// type: string +// - // name: fields_attributes[0][name] // in: formData // description: Name of 1st profile field to be added to this account's profile. @@ -339,7 +348,8 @@ func parseUpdateAccountForm(c *gin.Context) (*apimodel.UpdateCredentialsRequest, form.Theme == nil && form.CustomCSS == nil && form.EnableRSS == nil && - form.HideCollections == nil) { + form.HideCollections == nil && + form.WebVisibility == nil) { return nil, errors.New("empty form submitted") } diff --git a/internal/api/model/account.go b/internal/api/model/account.go index 0eaf52734..d34d7d519 100644 --- a/internal/api/model/account.go +++ b/internal/api/model/account.go @@ -227,6 +227,9 @@ type UpdateCredentialsRequest struct { EnableRSS *bool `form:"enable_rss" json:"enable_rss"` // Hide this account's following/followers collections. HideCollections *bool `form:"hide_collections" json:"hide_collections"` + // Visibility of statuses to show via the web view. + // "none", "public" (default), or "unlisted" (which includes public as well). + WebVisibility *string `form:"web_visibility" json:"web_visibility"` } // UpdateSource is to be used specifically in an UpdateCredentialsRequest. diff --git a/internal/api/model/source.go b/internal/api/model/source.go index 3b57f8565..cc3eb78ee 100644 --- a/internal/api/model/source.go +++ b/internal/api/model/source.go @@ -26,6 +26,11 @@ type Source struct { // private = Followers-only post // direct = Direct post Privacy Visibility `json:"privacy"` + // Visibility level(s) of posts to show for this account via the web api. + // "public" = default, show only Public visibility posts on the web. + // "unlisted" = show Public *and* Unlisted visibility posts on the web. + // "none" = show no posts on the web, not even Public ones. + WebVisibility Visibility `json:"web_visibility"` // Whether new statuses should be marked sensitive by default. Sensitive bool `json:"sensitive"` // The default posting language for new statuses. diff --git a/internal/api/model/status.go b/internal/api/model/status.go index d0acafae8..9b83fa582 100644 --- a/internal/api/model/status.go +++ b/internal/api/model/status.go @@ -232,6 +232,8 @@ type StatusCreateRequest struct { type Visibility string const ( + // VisibilityNone is visible to nobody. This is only used for the visibility of web statuses. + VisibilityNone Visibility = "none" // VisibilityPublic is visible to everyone, and will be available via the web even for nonauthenticated users. VisibilityPublic Visibility = "public" // VisibilityUnlisted is visible to everyone, but only on home timelines, lists, etc. -- cgit v1.2.3