Remove service_domain leftovers
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
5a6be1dd6e
commit
512db8f6dc
5 changed files with 6 additions and 19 deletions
|
@ -13,7 +13,6 @@ defmodule Pleroma.Domain do
|
|||
|
||||
schema "domains" do
|
||||
field(:domain, :string, default: "")
|
||||
field(:service_domain, :string, default: "")
|
||||
field(:public, :boolean, default: false)
|
||||
field(:resolves, :boolean, default: false)
|
||||
field(:last_checked_at, :naive_datetime)
|
||||
|
@ -25,10 +24,8 @@ def changeset(%__MODULE__{} = domain, params \\ %{}) do
|
|||
domain
|
||||
|> cast(params, [:domain, :public])
|
||||
|> validate_required([:domain])
|
||||
|> maybe_add_service_domain()
|
||||
|> update_change(:domain, &String.downcase/1)
|
||||
|> unique_constraint(:domain)
|
||||
|> unique_constraint(:service_domain)
|
||||
end
|
||||
|
||||
def update_changeset(%__MODULE__{} = domain, params \\ %{}) do
|
||||
|
@ -47,12 +44,6 @@ def update_state_changeset(%__MODULE__{} = domain, resolves) do
|
|||
)
|
||||
end
|
||||
|
||||
defp maybe_add_service_domain(%{changes: %{service_domain: _}} = changeset), do: changeset
|
||||
|
||||
defp maybe_add_service_domain(%{changes: %{domain: domain}} = changeset) do
|
||||
change(changeset, service_domain: domain)
|
||||
end
|
||||
|
||||
def list do
|
||||
__MODULE__
|
||||
|> order_by(asc: :id)
|
||||
|
@ -61,9 +52,9 @@ def list do
|
|||
|
||||
def get(id), do: Repo.get(__MODULE__, id)
|
||||
|
||||
def get_by_service_domain(domain) do
|
||||
def get_by_name(domain) do
|
||||
__MODULE__
|
||||
|> where(service_domain: ^domain)
|
||||
|> where(domain: ^domain)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ def create(%{body_params: params} = conn, _) do
|
|||
with {:domain_not_used, true} <-
|
||||
{:domain_not_used, params[:domain] !== Pleroma.Web.WebFinger.host()},
|
||||
{:ok, domain} <- Domain.create(params),
|
||||
_ <- @cachex.del(:domain, :domains_list) do
|
||||
_ <- @cachex.del(:domain_cache, :domains_list) do
|
||||
Pleroma.Workers.CheckDomainResolveWorker.enqueue("check_domain_resolve", %{
|
||||
"id" => domain.id
|
||||
})
|
||||
|
@ -62,14 +62,14 @@ def update(%{body_params: params} = conn, %{id: id}) do
|
|||
params
|
||||
|> Domain.update(id)
|
||||
|
||||
@cachex.del(:domain, :domains_list)
|
||||
@cachex.del(:domain_cache, :domains_list)
|
||||
|
||||
render(conn, "show.json", domain: domain)
|
||||
end
|
||||
|
||||
def delete(conn, %{id: id}) do
|
||||
with {:ok, _} <- Domain.delete(id),
|
||||
_ <- @cachex.del(:domain, :domains_list) do
|
||||
_ <- @cachex.del(:domain_cache, :domains_list) do
|
||||
json(conn, %{})
|
||||
else
|
||||
_ -> json_response(conn, :bad_request, "")
|
||||
|
|
|
@ -84,7 +84,6 @@ defp create_request do
|
|||
required: [:domain],
|
||||
properties: %{
|
||||
domain: %Schema{type: :string},
|
||||
service_domain: %Schema{type: :string, nullable: true},
|
||||
public: %Schema{type: :boolean, nullable: true}
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +104,6 @@ defp domain do
|
|||
properties: %{
|
||||
id: %Schema{type: :integer},
|
||||
domain: %Schema{type: :string},
|
||||
service_domain: %Schema{type: :string},
|
||||
public: %Schema{type: :boolean},
|
||||
resolves: %Schema{type: :boolean},
|
||||
last_checked_at: %Schema{type: :string, format: "date-time", nullable: true}
|
||||
|
|
|
@ -17,7 +17,7 @@ def perform(%{host: domain} = conn, _opts) do
|
|||
Pleroma.Config.get([__MODULE__, :domain]),
|
||||
Pleroma.Web.Endpoint.host()
|
||||
],
|
||||
%Domain{} = domain <- Domain.get_by_service_domain(domain) do
|
||||
%Domain{} = domain <- Domain.get_by_name(domain) do
|
||||
Map.put(conn, :domain, domain)
|
||||
else
|
||||
_ -> conn
|
||||
|
|
|
@ -4,7 +4,6 @@ defmodule Pleroma.Repo.Migrations.CreateDomains do
|
|||
def change do
|
||||
create_if_not_exists table(:domains) do
|
||||
add(:domain, :citext)
|
||||
add(:service_domain, :citext)
|
||||
add(:public, :boolean)
|
||||
add(:resolves, :boolean)
|
||||
add(:last_checked_at, :naive_datetime)
|
||||
|
@ -13,7 +12,6 @@ def change do
|
|||
end
|
||||
|
||||
create_if_not_exists(unique_index(:domains, [:domain]))
|
||||
create_if_not_exists(unique_index(:domains, [:service_domain]))
|
||||
|
||||
alter table(:users) do
|
||||
add(:domain_id, references(:domains))
|
||||
|
|
Loading…
Reference in a new issue