-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathemail_controller.ex
More file actions
31 lines (26 loc) · 1.05 KB
/
Copy pathemail_controller.ex
File metadata and controls
31 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defmodule Survey.EmailController do
use Survey.Web, :controller
@hashid Hashids.new(salt: Application.get_env(:mailer, :hashid_salt))
require Ecto.Query
import Ecto.Query
def unsubscribe(conn, _) do
Survey.User.unsubscribe(conn.assigns.user, "all")
html conn, "You have been unsubscribed from all personalized email from the INQ101x MOOC. To control mass-emails from EdX, please visit your user profile on EdX."
end
def unsubscribe_collab(conn, _) do
Survey.User.unsubscribe(conn.assigns.user, "collab")
html conn, "You have been unsubscribed from all e-mail notifications about
people entering your design group."
end
def redirect(conn, %{"hash" => hash}) do
{:ok, [id]} = Hashids.decode(@hashid, String.strip(hash))
struct = Survey.Cache.get(id)
hash = (from f in Survey.User,
where: f.id == ^struct.userid,
select: f.hash) |> Repo.one
conn
|> put_session(:repo_id, struct.userid)
|> put_session(:lti_userid, hash)
|> ParamSession.redirect(String.replace(struct.url, "}", ""))
end
end