Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional post visibility fields list and local #61

Open
kkostov opened this issue Feb 3, 2023 · 2 comments
Open

Additional post visibility fields list and local #61

kkostov opened this issue Feb 3, 2023 · 2 comments
Labels
enhancement New feature or request pleroma
Milestone

Comments

@kkostov
Copy link
Contributor

kkostov commented Feb 3, 2023

Pleroma supports two additional visibility fields: list and local

@kkostov kkostov added enhancement New feature or request pleroma labels Feb 3, 2023
@kkostov
Copy link
Contributor Author

kkostov commented Dec 17, 2023

The possible values for Pleroma/Akkoma flavours are:

enumeration
public
unlisted
local
private
direct

string value
list:LIST_ID

To support associated values, the Visibility struct needs to become something like this:

public enum Visibility: Codable, CaseIterable, Sendable, Equatable, Hashable {
        /// Visible to everyone, shown in public timelines.
        case `public`
        /// Visible to public, but not included in public timelines.
        case unlisted
        /// Visible to followers only, and to any mentioned users.
        case `private`
        /// Visible only to mentioned users.
        case direct
        /// The post is only visible to a list with the provided ids.
        case list(String)

        public init?(rawValue: String) {
            switch rawValue {
            case "public":
                self = .public
            case "unlisted":
                self = .unlisted
            case "private":
                self = .private
            case "direct":
                self = .direct
            default:
                if rawValue.starts(with: "list:") {
                    self = .list(rawValue)
                } else {
                    return nil
                }
            }
        }

        public var rawValue: String {
            switch self {
            case .public:
                return "public"
            case .unlisted:
                return "unlisted"
            case .private:
                return "private"
            case .direct:
                return "direct"
            case .list(let listId):
                return listId
            }
        }

        // Custom implementation to mimic CaseIterable
        public static var allCases: [Visibility] {
            return [.public, .unlisted, .private, .direct]
        }
    }

@kkostov kkostov added this to the 2.0 milestone Dec 17, 2023
@technicat
Copy link
Contributor

firefish also has local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pleroma
Projects
None yet
Development

No branches or pull requests

2 participants