import Foundation struct ModerationInput { let author: Post.Author var text = "" var labels: [ModerationPolicy.Label] = [] var tags: [String] = [] var languages: [String] = [] var imageDescriptions: [URL: String] = [:] var additionalText: [String] = [] func policyPost(isFollowing: Bool) -> ModerationPolicy.Post { ModerationPolicy.Post( author: .init(did: author.id, isFollowing: isFollowing, labels: author.moderationLabels), text: text, tags: tags, languages: languages, imageAltTexts: imageDescriptions.keys.sorted { $0.absoluteString < $1.absoluteString }.compactMap { imageDescriptions[$0] }, embeddedTexts: additionalText, labels: labels) } static func post(_ post: Post) -> Self { Self( author: post.author, text: post.text, labels: post.moderationLabels, tags: post.tags, languages: post.languages, imageDescriptions: post.imageDescriptions, additionalText: [post.externalTitle, post.externalDescription].compactMap { $0 } + post.pendingImages.map(\.altText)) } static func quote(_ quote: Post.Quote, author: Post.Author) -> Self { Self( author: author, text: quote.text ?? "", labels: quote.moderationLabels, tags: quote.tags, languages: quote.languages, imageDescriptions: quote.imageDescriptions, additionalText: [quote.externalTitle, quote.externalDescription].compactMap { $0 }) } static func quotedPost(_ post: Post) -> Self { Self( author: post.author, text: post.text, labels: post.moderationLabels, tags: post.tags, languages: post.languages, imageDescriptions: post.imageDescriptions, additionalText: [post.externalTitle, post.externalDescription].compactMap { $0 }) } } struct PreparedQuoteDecision { let quote: Post.Quote let fallback: Post? let decision: ModerationPolicy.Decision? }