Merge branch 'fix-accepting-follows' into 'master'
Fix accepting follows See merge request framasoft/mobilizon!518
This commit is contained in:
commit
01b4c9678f
@ -257,11 +257,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
|
|||||||
{:member, true} <-
|
{:member, true} <-
|
||||||
{:member, Actors.is_member?(object_data.creator_id, object_data.actor_id)},
|
{:member, Actors.is_member?(object_data.creator_id, object_data.actor_id)},
|
||||||
{:ok, %Activity{} = activity, %Resource{} = resource} <-
|
{:ok, %Activity{} = activity, %Resource{} = resource} <-
|
||||||
ActivityPub.create(:resource, object_data, false),
|
ActivityPub.create(:resource, object_data, false) do
|
||||||
%Actor{type: :Group, id: group_id} = group <-
|
|
||||||
Actors.get_group_by_members_url(group_url),
|
|
||||||
announce_id <- "#{object_url}/announces/#{group_id}",
|
|
||||||
{:ok, _activity, _resource} <- ActivityPub.announce(group, object, announce_id) do
|
|
||||||
{:ok, activity, resource}
|
{:ok, activity, resource}
|
||||||
else
|
else
|
||||||
{:existing_resource, %Resource{} = resource} ->
|
{:existing_resource, %Resource{} = resource} ->
|
||||||
|
@ -93,8 +93,8 @@ defmodule Mobilizon.Federation.HTTPSignatures.Signature do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign(%Actor{keys: keys} = actor, headers) do
|
def sign(%Actor{domain: domain, keys: keys} = actor, headers) when is_nil(domain) do
|
||||||
Logger.debug("Signing on behalf of #{actor.url}")
|
Logger.debug("Signing a payload on behalf of #{actor.url}")
|
||||||
Logger.debug("headers")
|
Logger.debug("headers")
|
||||||
Logger.debug(inspect(headers))
|
Logger.debug(inspect(headers))
|
||||||
|
|
||||||
@ -103,6 +103,11 @@ defmodule Mobilizon.Federation.HTTPSignatures.Signature do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign(%Actor{url: url}, _) do
|
||||||
|
Logger.error("Can't do a signature on remote actor #{url}")
|
||||||
|
raise ArgumentError, message: "Can't do a signature on remote actor #{url}"
|
||||||
|
end
|
||||||
|
|
||||||
def generate_date_header, do: generate_date_header(NaiveDateTime.utc_now())
|
def generate_date_header, do: generate_date_header(NaiveDateTime.utc_now())
|
||||||
|
|
||||||
def generate_date_header(%NaiveDateTime{} = date) do
|
def generate_date_header(%NaiveDateTime{} = date) do
|
||||||
|
@ -18,8 +18,10 @@ defmodule Mobilizon.Federation.WebFinger do
|
|||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@http_options [
|
@http_options [
|
||||||
follow_redirect: true,
|
adapter: [
|
||||||
ssl: [{:versions, [:"tlsv1.2"]}]
|
follow_redirect: true,
|
||||||
|
ssl: [{:versions, [:"tlsv1.2"]}]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
def host_meta do
|
def host_meta do
|
||||||
|
@ -966,7 +966,9 @@ defmodule Mobilizon.Actors do
|
|||||||
# Check if followed has blocked follower
|
# Check if followed has blocked follower
|
||||||
{:already_following, nil} <- {:already_following, is_following(follower, followed)} do
|
{:already_following, nil} <- {:already_following, is_following(follower, followed)} do
|
||||||
Logger.info(
|
Logger.info(
|
||||||
"Making #{follower.preferred_username} follow #{followed.preferred_username} " <>
|
"Making #{Actor.preferred_username_and_domain(follower)} follow #{
|
||||||
|
Actor.preferred_username_and_domain(followed)
|
||||||
|
} " <>
|
||||||
"(approved: #{approved})"
|
"(approved: #{approved})"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -979,11 +981,13 @@ defmodule Mobilizon.Actors do
|
|||||||
else
|
else
|
||||||
{:already_following, %Follower{}} ->
|
{:already_following, %Follower{}} ->
|
||||||
{:error, :already_following,
|
{:error, :already_following,
|
||||||
"Could not follow actor: you are already following #{followed.preferred_username}"}
|
"Could not follow actor: you are already following #{
|
||||||
|
Actor.preferred_username_and_domain(followed)
|
||||||
|
}"}
|
||||||
|
|
||||||
{:suspended, _} ->
|
{:suspended, _} ->
|
||||||
{:error, :suspended,
|
{:error, :suspended,
|
||||||
"Could not follow actor: #{followed.preferred_username} has been suspended"}
|
"Could not follow actor: #{Actor.preferred_username_and_domain(followed)} has been suspended"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user