Move configuration to traditional way
⭐️ This is the way. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -707,7 +707,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
||||
# Get recipients for an activity or object
|
||||
@spec get_recipients(map()) :: list()
|
||||
defp get_recipients(data) do
|
||||
(data["to"] || []) ++ (data["cc"] || [])
|
||||
Map.get(data, "to", []) ++ Map.get(data, "cc", [])
|
||||
end
|
||||
|
||||
@spec create_event(map(), map()) :: {:ok, map()}
|
||||
@@ -870,17 +870,18 @@ defmodule Mobilizon.Federation.ActivityPub do
|
||||
audience <-
|
||||
follower.actor |> Audience.calculate_to_and_cc_from_mentions() |> Map.merge(additional),
|
||||
reject_data <- %{
|
||||
"to" => follower.actor.url,
|
||||
"to" => [follower.actor.url],
|
||||
"type" => "Reject",
|
||||
"actor" => follower.actor.url,
|
||||
"actor" => follower.target_actor.url,
|
||||
"object" => follower_as_data
|
||||
},
|
||||
update_data <-
|
||||
reject_data
|
||||
|> Map.merge(audience)
|
||||
audience
|
||||
|> Map.merge(reject_data)
|
||||
|> Map.merge(%{
|
||||
"id" => "#{Endpoint.url()}/reject/follow/#{follower.id}"
|
||||
}) do
|
||||
Logger.error(inspect(update_data))
|
||||
{:ok, follower, update_data}
|
||||
else
|
||||
err ->
|
||||
|
||||
@@ -405,14 +405,14 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
|
||||
Handle incoming `Reject` activities wrapping a `Follow` activity
|
||||
"""
|
||||
def do_handle_incoming_reject_following(follow_object, %Actor{} = actor) do
|
||||
with {:follow, {:ok, %Follower{approved: false, target_actor: followed} = follow}} <-
|
||||
with {:follow, {:ok, %Follower{target_actor: followed} = follow}} <-
|
||||
{:follow, get_follow(follow_object)},
|
||||
{:same_actor, true} <- {:same_actor, actor.id == followed.id},
|
||||
{:ok, activity, _} <-
|
||||
ActivityPub.reject(:follow, follow) do
|
||||
{:ok, activity, follow}
|
||||
else
|
||||
{:follow, _} ->
|
||||
{:follow, _err} ->
|
||||
Logger.debug(
|
||||
"Tried to handle a Reject activity but it's not containing a Follow activity"
|
||||
)
|
||||
|
||||
@@ -54,8 +54,8 @@ defmodule Mobilizon.GraphQL.API.Follows do
|
||||
def reject(%Actor{} = follower, %Actor{} = followed) do
|
||||
Logger.debug("We're trying to reject a follow")
|
||||
|
||||
with %Follower{} = follow <-
|
||||
Actors.is_following(follower, followed),
|
||||
with {:follower, %Follower{} = follow} <-
|
||||
{:follower, Actors.is_following(follower, followed)},
|
||||
{:ok, %Activity{} = activity, %Follower{} = follow} <-
|
||||
ActivityPub.reject(
|
||||
:follow,
|
||||
@@ -64,7 +64,10 @@ defmodule Mobilizon.GraphQL.API.Follows do
|
||||
) do
|
||||
{:ok, activity, follow}
|
||||
else
|
||||
%Follower{approved: true} ->
|
||||
{:follower, nil} ->
|
||||
{:error, "Follow not found"}
|
||||
|
||||
{:follower, %Follower{approved: true}} ->
|
||||
{:error, "Follow already accepted"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
|
||||
paths =
|
||||
[config_path, psql_path] = [
|
||||
Keyword.get(options, :output, ".env"),
|
||||
Keyword.get(options, :output, "config/prod.secret.exs"),
|
||||
Keyword.get(options, :output_psql, "setup_db.psql")
|
||||
]
|
||||
|
||||
@@ -113,11 +113,30 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
"autogenerated"
|
||||
)
|
||||
|
||||
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
listen_port =
|
||||
Common.get_option(
|
||||
options,
|
||||
:listen_port,
|
||||
"What port will the app listen to (leave it if you are using the default setup with nginx)?",
|
||||
4000
|
||||
)
|
||||
|
||||
listen_ip =
|
||||
Common.get_option(
|
||||
options,
|
||||
:listen_ip,
|
||||
"What ip will the app listen to (leave it if you are using the default setup with nginx)?",
|
||||
"127.0.0.1"
|
||||
)
|
||||
|
||||
instance_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
auth_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
|
||||
template_dir = Application.app_dir(:mobilizon, "priv") <> "/templates"
|
||||
|
||||
result_config =
|
||||
EEx.eval_file(
|
||||
".env.sample" |> Path.expand(__DIR__ <> "../../../../../"),
|
||||
"#{template_dir}/config.template.eex",
|
||||
instance_domain: domain,
|
||||
instance_port: port,
|
||||
instance_email: email,
|
||||
@@ -128,12 +147,15 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
database_username: dbuser,
|
||||
database_password: dbpass,
|
||||
version: Mobilizon.Mixfile.project() |> Keyword.get(:version),
|
||||
instance_secret: secret
|
||||
instance_secret: instance_secret,
|
||||
auth_secret: auth_secret,
|
||||
listen_ip: listen_ip,
|
||||
listen_port: listen_port
|
||||
)
|
||||
|
||||
result_psql =
|
||||
EEx.eval_file(
|
||||
"support/postgresql/setup_db.psql" |> Path.expand(__DIR__ <> "../../../../../"),
|
||||
"#{template_dir}/setup_db.eex",
|
||||
database_name: dbname,
|
||||
database_username: dbuser,
|
||||
database_password: dbpass
|
||||
@@ -155,12 +177,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
|
||||
2. Run `sudo -u postgres psql -f #{Common.escape_sh_path(psql_path)} && rm #{
|
||||
Common.escape_sh_path(psql_path)
|
||||
}`.
|
||||
""" <>
|
||||
if config_path in [".env.production", ".env.dev", ".env.test"] do
|
||||
""
|
||||
else
|
||||
"3. Run `mv #{Common.escape_sh_path(config_path)} '.env.production'`."
|
||||
end
|
||||
"""
|
||||
)
|
||||
else
|
||||
Mix.shell().error(
|
||||
|
||||
@@ -37,7 +37,7 @@ defmodule Mobilizon.Addresses do
|
||||
%Address{}
|
||||
|> Address.changeset(attrs)
|
||||
|> Repo.insert(
|
||||
on_conflict: :replace_all_except_primary_key,
|
||||
on_conflict: {:replace_all_except, [:id]},
|
||||
conflict_target: [:origin_id]
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user