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

173 lines
3.2 KiB
Elixir

defmodule TribeOne.TribesPlugin.Sender.Streaming.Stream 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]
@visibility [:public, :unlisted, :private]
@latency_modes [:hls, :ll_hls]
postgres do
table("sender_streams")
repo(Tribes.Repo)
custom_indexes do
index([:slug], unique: true)
index([:visibility])
end
end
nostr_sync do
namespace("plugins.sender.stream")
lane(:control)
publish?(true)
consume?(true)
end
actions do
defaults([:read])
read :by_id do
get?(true)
argument :id, :uuid do
allow_nil?(false)
end
filter(expr(id == ^arg(:id)))
end
create :create do
accept([
:slug,
:title,
:description,
:visibility,
:owner_id,
:latency_mode,
:recording_policy,
:default_rendition_policy
])
change(AshNostrSync.PublishChange)
end
create :sync_upsert do
accept([
:id,
:slug,
:title,
:description,
:visibility,
:owner_id,
:latency_mode,
:recording_policy,
:default_rendition_policy
])
upsert?(true)
end
update :update do
require_atomic?(false)
accept([
:slug,
:title,
:description,
:visibility,
:latency_mode,
:recording_policy,
:default_rendition_policy
])
change(AshNostrSync.PublishChange)
end
destroy :destroy do
require_atomic?(false)
soft?(true)
soft_delete()
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 :slug, :string do
allow_nil?(false)
public?(true)
end
attribute :title, :string do
allow_nil?(false)
public?(true)
end
attribute :description, :string do
public?(true)
end
attribute :visibility, :atom do
constraints(one_of: @visibility)
allow_nil?(false)
default(:public)
public?(true)
end
attribute :owner_id, :uuid do
public?(true)
end
attribute :latency_mode, :atom do
constraints(one_of: @latency_modes)
allow_nil?(false)
default(:hls)
public?(true)
end
attribute :recording_policy, Tribes.Types.JsonValue do
allow_nil?(false)
default(%{})
public?(true)
end
attribute :default_rendition_policy, Tribes.Types.JsonValue do
allow_nil?(false)
default(%{})
public?(true)
end
timestamps(type: :utc_datetime)
end
identities do
identity(:unique_slug, [:slug])
end
end