some reformatting and adjusting so logged in users get moved directly to their feed
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
defmodule Mixer.Accounts.Follow do
|
||||
require Ash.Query
|
||||
|
||||
use Ash.Resource,
|
||||
domain: Mixer.Accounts,
|
||||
data_layer: AshPostgres.DataLayer,
|
||||
@@ -20,25 +21,6 @@ defmodule Mixer.Accounts.Follow do
|
||||
type_name "follows"
|
||||
end
|
||||
|
||||
attributes do
|
||||
uuid_primary_key :id
|
||||
create_timestamp :created_at
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :follower, Mixer.Accounts.User do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
end
|
||||
|
||||
belongs_to :following, Mixer.Accounts.User do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
end
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:read, :destroy]
|
||||
|
||||
@@ -48,6 +30,7 @@ defmodule Mixer.Accounts.Follow do
|
||||
upsert_identity :unique_follow
|
||||
accept [:following_id]
|
||||
change relate_actor(:follower)
|
||||
|
||||
validate fn changeset, _context ->
|
||||
follower_id = Ash.Changeset.get_attribute(changeset, :follower_id)
|
||||
following_id = Ash.Changeset.get_attribute(changeset, :following_id)
|
||||
@@ -82,10 +65,6 @@ defmodule Mixer.Accounts.Follow do
|
||||
end
|
||||
end
|
||||
|
||||
identities do
|
||||
identity :unique_follow, [:follower_id, :following_id]
|
||||
end
|
||||
|
||||
policies do
|
||||
policy action_type(:read) do
|
||||
authorize_if always()
|
||||
@@ -99,4 +78,27 @@ defmodule Mixer.Accounts.Follow do
|
||||
authorize_if actor_present()
|
||||
end
|
||||
end
|
||||
|
||||
attributes do
|
||||
uuid_primary_key :id
|
||||
create_timestamp :created_at
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :follower, Mixer.Accounts.User do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
end
|
||||
|
||||
belongs_to :following, Mixer.Accounts.User do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
end
|
||||
end
|
||||
|
||||
identities do
|
||||
identity :unique_follow, [:follower_id, :following_id]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,14 +31,21 @@ defmodule Mixer.Accounts.User.Senders.SendMagicLinkEmail do
|
||||
defp body(params) do
|
||||
# NOTE: You may have to change this to match your magic link acceptance URL.
|
||||
link = url(~p"/magic_link/#{params[:token]}")
|
||||
email_template("Your magic link", "Hello, #{params[:email]}!", """
|
||||
<p style="margin:0 0 20px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
Use the button below to sign in to Mixer. This link is valid for a short time and can only be used once.
|
||||
</p>
|
||||
<p style="margin:0 0 32px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
If you didn't request this, you can safely ignore this email.
|
||||
</p>
|
||||
""", link, "Sign In to Mixer")
|
||||
|
||||
email_template(
|
||||
"Your magic link",
|
||||
"Hello, #{params[:email]}!",
|
||||
"""
|
||||
<p style="margin:0 0 20px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
Use the button below to sign in to Mixer. This link is valid for a short time and can only be used once.
|
||||
</p>
|
||||
<p style="margin:0 0 32px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
If you didn't request this, you can safely ignore this email.
|
||||
</p>
|
||||
""",
|
||||
link,
|
||||
"Sign In to Mixer"
|
||||
)
|
||||
end
|
||||
|
||||
defp email_template(title, greeting, content, button_url, button_label) do
|
||||
|
||||
@@ -22,14 +22,21 @@ defmodule Mixer.Accounts.User.Senders.SendNewUserConfirmationEmail do
|
||||
|
||||
defp body(params) do
|
||||
link = url(~p"/confirm_new_user/#{params[:token]}")
|
||||
email_template("Confirm your email", "Welcome to Mixer!", """
|
||||
<p style="margin:0 0 20px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
Thanks for signing up. Just one more step — confirm your email address to activate your account.
|
||||
</p>
|
||||
<p style="margin:0 0 32px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
If you didn't create an account on Mixer, you can safely ignore this email.
|
||||
</p>
|
||||
""", link, "Confirm Email Address")
|
||||
|
||||
email_template(
|
||||
"Confirm your email",
|
||||
"Welcome to Mixer!",
|
||||
"""
|
||||
<p style="margin:0 0 20px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
Thanks for signing up. Just one more step — confirm your email address to activate your account.
|
||||
</p>
|
||||
<p style="margin:0 0 32px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
If you didn't create an account on Mixer, you can safely ignore this email.
|
||||
</p>
|
||||
""",
|
||||
link,
|
||||
"Confirm Email Address"
|
||||
)
|
||||
end
|
||||
|
||||
defp email_template(title, greeting, content, button_url, button_label) do
|
||||
|
||||
@@ -22,14 +22,21 @@ defmodule Mixer.Accounts.User.Senders.SendPasswordResetEmail do
|
||||
|
||||
defp body(params) do
|
||||
link = url(~p"/password-reset/#{params[:token]}")
|
||||
email_template("Reset your password", "Password reset request", """
|
||||
<p style="margin:0 0 20px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
We received a request to reset the password for your Mixer account. Click the button below to choose a new one.
|
||||
</p>
|
||||
<p style="margin:0 0 32px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
If you didn't request a password reset, you can safely ignore this email — your password will not change.
|
||||
</p>
|
||||
""", link, "Reset My Password")
|
||||
|
||||
email_template(
|
||||
"Reset your password",
|
||||
"Password reset request",
|
||||
"""
|
||||
<p style="margin:0 0 20px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
We received a request to reset the password for your Mixer account. Click the button below to choose a new one.
|
||||
</p>
|
||||
<p style="margin:0 0 32px 0;color:#4B5563;font-size:16px;line-height:1.6;">
|
||||
If you didn't request a password reset, you can safely ignore this email — your password will not change.
|
||||
</p>
|
||||
""",
|
||||
link,
|
||||
"Reset My Password"
|
||||
)
|
||||
end
|
||||
|
||||
defp email_template(title, greeting, content, button_url, button_label) do
|
||||
|
||||
Reference in New Issue
Block a user