From 8d352d2f05874dd9283360ed3dfc1fa7fc3e530d Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Mon, 10 Feb 2020 17:18:00 +0100 Subject: Fix the stuffs --- lib/waev_web/controllers/exports_controller.ex | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'lib/waev_web/controllers/exports_controller.ex') 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 -- cgit v1.2.3