-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement domain change via Sites API
cc @ukutaht
- Loading branch information
Showing
5 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,25 @@ defmodule PlausibleWeb.Api.ExternalSitesController do | |
end | ||
end | ||
|
||
def update_site(conn, %{"site_id" => site_id} = params) do | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
aerosol
Author
Member
|
||
# for now this only allows to change the domain | ||
site = Sites.get_for_user(conn.assigns[:current_user].id, site_id, [:owner, :admin]) | ||
|
||
if site && Plausible.v2?() do | ||
case Plausible.Site.Domain.change(site, params["domain"]) do | ||
{:ok, site} -> | ||
json(conn, site) | ||
|
||
{:error, changeset} -> | ||
conn | ||
|> put_status(400) | ||
|> json(serialize_errors(changeset)) | ||
end | ||
else | ||
H.not_found(conn, "Site could not be found") | ||
end | ||
end | ||
|
||
defp expect_param_key(params, key) do | ||
case Map.fetch(params, key) do | ||
:error -> {:missing, key} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Seems like this endpoint is missing tests