end
end
+ def get_by_confirmation_token(token) do
+ Repo.one(from(u in User, where: fragment("? ->> 'confirmation_token' = ?", u.info, ^token)))
+ end
+
def get_followers_query(%User{id: id, follower_address: follower_address}) do
from(
u in User,
field(:note_count, :integer, default: 0)
field(:follower_count, :integer, default: 0)
field(:locked, :boolean, default: false)
+ field(:confirmation_pending, :boolean, default: false)
+ field(:confirmation_token, :string, default: nil)
field(:default_scope, :string, default: "public")
field(:blocks, {:array, :string}, default: [])
field(:domain_blocks, {:array, :string}, default: [])
])
end
+ def confirmation_update(info, params) do
+ cast(info, params, [:confirmation_pending, :confirmation_token])
+ end
+
def mastodon_profile_update(info, params) do
info
|> cast(params, [
banner: Keyword.get(instance, :banner_upload_limit),
background: Keyword.get(instance, :background_upload_limit)
},
+ accountActivationRequired: Keyword.get(instance, :account_activation_required, false),
invitesEnabled: Keyword.get(instance, :invites_enabled, false),
features: features
}
post("/account/register", TwitterAPI.Controller, :register)
post("/account/password_reset", TwitterAPI.Controller, :password_reset)
+ get("/account/confirm_email/:token", TwitterAPI.Controller, :confirm_email)
get("/search", TwitterAPI.Controller, :search)
get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
end
end
+ def confirm_email(conn, %{"token" => token}) do
+ with %User{} = user <- User.get_by_confirmation_token(token),
+ true <- user.local,
+ new_info_fields <- %{confirmation_pending: false, confirmation_token: nil},
+ info_change <- User.Info.confirmation_update(user.info, new_info_fields),
+ changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change),
+ {:ok, _} <- User.update_and_set_cache(changeset) do
+ conn
+ |> put_flash(:info, "Email confirmed. Please sign in.")
+ |> redirect(to: "/")
+ end
+ end
+
def update_avatar(%{assigns: %{user: user}} = conn, params) do
{:ok, object} = ActivityPub.upload(params, type: :avatar)
change = Changeset.change(user, %{avatar: object.data})