class AppCatalog::WebApp < ApplicationRecord
  store :metadata, coder: JSON

  has_many :remote_storage_authorizations

  has_one_attached :icon
  has_one_attached :apple_touch_icon

  validates :url, presence: true, uniqueness: true
  validates :url, format: { with: URI.regexp },
                  if: Proc.new { |a| a.url.present? }

  def update_metadata
    AppCatalogManager::UpdateMetadata.call(app: self)
  end
end
