- Add BlueskyPostHelper for rendering Bluesky post facets (mentions, links, hashtags) - Implement facet parsing and rendering with proper styling - Add external link partial for non-Bluesky URLs - Update DisplayedFile and PostFiles components to handle Bluesky posts - Add comprehensive test coverage for helper methods - Update scan user job to handle Bluesky-specific data
57 lines
1.3 KiB
Ruby
57 lines
1.3 KiB
Ruby
# typed: strict
|
|
# frozen_string_literal: true
|
|
|
|
module Bluesky::Text
|
|
class FacetFeature
|
|
extend T::Sig
|
|
extend T::Helpers
|
|
abstract!
|
|
|
|
sig(:final) do
|
|
params(hash: T::Hash[String, T.untyped]).returns(FacetFeature)
|
|
end
|
|
def self.from_hash(hash)
|
|
case hash["$type"]
|
|
when "app.bsky.richtext.facet#mention"
|
|
FacetFeatureMention.new(hash)
|
|
when "app.bsky.richtext.facet#link"
|
|
FacetFeatureURI.new(hash)
|
|
when "app.bsky.richtext.facet#tag"
|
|
FacetFeatureTag.new(hash)
|
|
else
|
|
raise "Unknown facet feature type: #{hash["$type"]}"
|
|
end
|
|
end
|
|
end
|
|
|
|
class FacetFeatureURI < FacetFeature
|
|
sig { returns(String) }
|
|
attr_reader :uri
|
|
|
|
sig { params(hash: T::Hash[String, T.untyped]).void }
|
|
def initialize(hash)
|
|
@uri = T.let(hash["uri"], String)
|
|
end
|
|
end
|
|
|
|
class FacetFeatureMention < FacetFeature
|
|
sig { returns(String) }
|
|
attr_reader :did
|
|
|
|
sig { params(hash: T::Hash[String, T.untyped]).void }
|
|
def initialize(hash)
|
|
@did = T.let(hash["did"], String)
|
|
end
|
|
end
|
|
|
|
class FacetFeatureTag < FacetFeature
|
|
sig { returns(String) }
|
|
attr_reader :tag
|
|
|
|
sig { params(hash: T::Hash[String, T.untyped]).void }
|
|
def initialize(hash)
|
|
@tag = T.let(hash["tag"], String)
|
|
end
|
|
end
|
|
end
|