Working s3 compatible file uplaods!

This commit is contained in:
2026-03-30 14:28:44 -04:00
parent 6152dcdeea
commit 830ee36f84
16 changed files with 664 additions and 15 deletions

View File

@@ -5,7 +5,6 @@ defmodule Mixer.Posts.Media do
data_layer: AshPostgres.DataLayer,
authorizers: [Ash.Policy.Authorizer],
extensions: [
#AshStateMachine,
AshTypescript.Resource
]
@@ -19,7 +18,20 @@ defmodule Mixer.Posts.Media do
end
actions do
defaults [:read, :destroy, create: :*, update: :*]
defaults [:read]
create :upload do
accept [:s3_key]
change relate_actor(:user)
end
update :link_to_tweet do
accept [:tweet_id]
end
destroy :destroy do
primary? true
end
end
attributes do
@@ -29,12 +41,41 @@ defmodule Mixer.Posts.Media do
allow_nil? false
public? true
end
end
relationships do
belongs_to :tweet, Mixer.Posts.Tweet do
attribute :user_id, :uuid do
allow_nil? false
public? true
end
end
relationships do
belongs_to :user, Mixer.Accounts.User do
attribute_writable? true
allow_nil? false
public? true
end
belongs_to :tweet, Mixer.Posts.Tweet do
allow_nil? true
public? true
end
end
policies do
policy action_type(:read) do
authorize_if always()
end
policy action(:upload) do
authorize_if actor_present()
end
policy action(:link_to_tweet) do
authorize_if relates_to_actor_via(:user)
end
policy action_type(:destroy) do
authorize_if relates_to_actor_via(:user)
end
end
end