2020-05-02 04:50:54 +02:00
|
|
|
defmodule PhilomenaWeb.Channel.NsfwController do
|
|
|
|
use PhilomenaWeb, :controller
|
|
|
|
|
|
|
|
alias Plug.Conn
|
|
|
|
|
|
|
|
def create(conn, _params) do
|
|
|
|
conn
|
|
|
|
|> set_cookie("chan_nsfw", "true")
|
|
|
|
|> put_flash(:info, "Successfully updated channel visibility.")
|
2024-04-29 02:55:27 +02:00
|
|
|
|> redirect(to: ~p"/channels")
|
2020-05-02 04:50:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def delete(conn, _params) do
|
|
|
|
conn
|
|
|
|
|> set_cookie("chan_nsfw", "false")
|
|
|
|
|> put_flash(:info, "Successfully updated channel visibility.")
|
2024-04-29 02:55:27 +02:00
|
|
|
|> redirect(to: ~p"/channels")
|
2020-05-02 04:50:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# Duplicated from setting controller
|
|
|
|
defp set_cookie(conn, cookie_name, value) do
|
|
|
|
# JS wants access; max-age is set to 25 years from now
|
2020-05-27 19:01:35 +02:00
|
|
|
Conn.put_resp_cookie(conn, cookie_name, value,
|
|
|
|
max_age: 788_923_800,
|
|
|
|
http_only: false,
|
|
|
|
extra: "SameSite=Lax"
|
|
|
|
)
|
2020-05-02 04:50:54 +02:00
|
|
|
end
|
|
|
|
end
|