starting work on adding s3 media support

This commit is contained in:
2026-03-30 12:38:32 -04:00
parent 4378a6fb21
commit 11bb3ddd1c
3 changed files with 51 additions and 0 deletions

40
lib/mixer/posts/media.ex Normal file
View File

@@ -0,0 +1,40 @@
defmodule Mixer.Posts.Media do
use Ash.Resource,
otp_app: :mixer,
domain: Mixer.Posts,
data_layer: AshPostgres.DataLayer,
authorizers: [Ash.Policy.Authorizer],
extensions: [
#AshStateMachine,
AshTypescript.Resource
]
postgres do
table "media"
repo Mixer.Repo
end
typescript do
type_name "media"
end
actions do
defaults [:read, :destroy, create: :*, update: :*]
end
attributes do
uuid_primary_key :id
attribute :s3_key, :string do
allow_nil? false
public? true
end
end
relationships do
belongs_to :tweet, Mixer.Posts.Tweet do
allow_nil? false
public? true
end
end
end

View File

@@ -43,6 +43,12 @@ defmodule Mixer.Posts.Tweet do
public? true
end
attribute :likes, :integer do
allow_nil? false
default 0
public? true
end
attribute :user_id, :uuid do
allow_nil? false
public? true
@@ -56,6 +62,10 @@ defmodule Mixer.Posts.Tweet do
allow_nil? false
public? true
end
has_many :s3_key, Mixer.Posts.Media do
public? true
end
end
policies do