Files
self 1fb848b8cb feat: namespace plugin identity
Adopt canonical plugin id/slug manifest fields, vendor-prefixed OTP app naming, and fully-qualified capability ids for Sender.
2026-05-27 19:05:39 +02:00

167 lines
2.9 KiB
Elixir

defmodule TribeOne.TribesPlugin.Sender.Streaming.Rendition do
@moduledoc false
use Ash.Resource,
otp_app: :tribe_one_sender,
domain: TribeOne.TribesPlugin.Sender.Streaming,
data_layer: AshPostgres.DataLayer,
authorizers: [Ash.Policy.Authorizer],
extensions: [AshNostrSync]
@containers [:mpegts, :fmp4]
@statuses [:pending, :ready, :degraded, :failed]
postgres do
table("sender_renditions")
repo(Tribes.Repo)
custom_indexes do
index([:generation_id])
index([:status])
end
end
nostr_sync do
namespace("plugins.sender.rendition")
lane(:control)
publish?(true)
consume?(true)
end
actions do
defaults([:read])
create :upsert do
accept([
:id,
:generation_id,
:name,
:width,
:height,
:video_bitrate,
:audio_bitrate,
:codec,
:container,
:playlist_path,
:status
])
upsert?(true)
change(AshNostrSync.PublishChange)
end
create :sync_upsert do
accept([
:id,
:generation_id,
:name,
:width,
:height,
:video_bitrate,
:audio_bitrate,
:codec,
:container,
:playlist_path,
:status
])
upsert?(true)
end
read :by_id do
get?(true)
argument :id, :uuid do
allow_nil?(false)
end
filter(expr(id == ^arg(:id)))
end
update :update do
require_atomic?(false)
accept([
:status
])
change(AshNostrSync.PublishChange)
end
end
policies do
bypass Tribes.Checks.SyncInteraction do
authorize_if(always())
end
bypass Tribes.Checks.SystemInteraction do
authorize_if(always())
end
policy action_type(:read) do
authorize_if(always())
end
end
attributes do
attribute :id, :uuid do
allow_nil?(false)
primary_key?(true)
public?(true)
writable?(true)
default(&Ash.UUID.generate/0)
end
attribute :generation_id, :uuid do
allow_nil?(false)
public?(true)
end
attribute :name, :string do
allow_nil?(false)
public?(true)
end
attribute :width, :integer do
public?(true)
end
attribute :height, :integer do
public?(true)
end
attribute :video_bitrate, :integer do
public?(true)
end
attribute :audio_bitrate, :integer do
public?(true)
end
attribute :codec, :string do
public?(true)
end
attribute :container, :atom do
constraints(one_of: @containers)
allow_nil?(false)
default(:mpegts)
public?(true)
end
attribute :playlist_path, :string do
allow_nil?(false)
public?(true)
end
attribute :status, :atom do
constraints(one_of: @statuses)
allow_nil?(false)
default(:pending)
public?(true)
end
timestamps(type: :utc_datetime)
end
end