slightly changed how files are stored in the bucket and allows post deletion

This commit is contained in:
2026-03-31 17:12:40 -04:00
parent 1c1830b086
commit 53467cd611
7 changed files with 295 additions and 3 deletions

View File

@@ -11,6 +11,10 @@ defmodule Mixer.Posts.Media do
postgres do
table "media"
repo Mixer.Repo
references do
reference :tweet, on_delete: :delete
end
end
typescript do

View File

@@ -10,7 +10,7 @@ defmodule Mixer.Posts.MediaUploader do
if ext in @extensions, do: :ok, else: {:error, "unsupported file type #{ext}"}
end
def storage_dir(_version, {_file, scope}), do: "uploads/media/#{scope.id}"
def storage_dir(_version, {_file, scope}), do: "uploads/media/#{scope.user_id}/#{scope.media_id}"
def filename(_version, {file, _scope}) do
Path.basename(file.file_name, Path.extname(file.file_name))

View File

@@ -8,6 +8,10 @@ defmodule Mixer.Posts.TweetLike do
postgres do
table "tweet_likes"
repo Mixer.Repo
references do
reference :tweet, on_delete: :delete
end
end
actions do