aboutsummaryrefslogtreecommitdiff
path: root/lib/waev_web/controllers
diff options
context:
space:
mode:
authorGuillermo Ramos2020-02-10 17:18:00 +0100
committerGuillermo Ramos2020-02-10 17:39:24 +0100
commit8d352d2f05874dd9283360ed3dfc1fa7fc3e530d (patch)
tree747c285b61e0964bfcf2abb3eab4e88ec2ad889a /lib/waev_web/controllers
parentaa0213ad46ca0dcb3e64e14cee2676d8fdc60110 (diff)
downloadwaev-8d352d2f05874dd9283360ed3dfc1fa7fc3e530d.tar.gz
Fix the stuffs
Diffstat (limited to 'lib/waev_web/controllers')
-rw-r--r--lib/waev_web/controllers/exports_controller.ex19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/waev_web/controllers/exports_controller.ex b/lib/waev_web/controllers/exports_controller.ex
index 764accf..f2b6fb4 100644
--- a/lib/waev_web/controllers/exports_controller.ex
+++ b/lib/waev_web/controllers/exports_controller.ex
@@ -15,15 +15,28 @@ defmodule WaevWeb.ExportsController do
end
def get_media(conn, %{"id" => id, "at_id" => at_id}) do
- case Waev.Export.Message.File.path(id, at_id) do
- {:ok, path} ->
+ case Waev.Export.Message.File.media_path(id, at_id) do
+ nil ->
+ conn
+ |> put_status(:not_found)
+ |> put_view(WaevWeb.ErrorView)
+ |> render("404.html")
+
+ path ->
send_download(conn, {:file, path}, filename: at_id)
+ end
+ end
- :error ->
+ def get_avatar(conn, %{"id" => id, "av_id" => av_id}) do
+ case Waev.Export.Party.avatar_path(id, av_id) do
+ nil ->
conn
|> put_status(:not_found)
|> put_view(WaevWeb.ErrorView)
|> render("404.html")
+
+ path ->
+ send_download(conn, {:file, path}, filename: av_id)
end
end
end