Merge branch 'fixes' into 'main'
Various fixes Closes #1303 See merge request framasoft/mobilizon!1414
This commit is contained in:
commit
e46a38ca2a
|
@ -42,3 +42,4 @@ E7967805C1EA5301F2722C7BDB2F25F3
|
||||||
BDFB0FB1AAF69C18212CBCFD42F8B717
|
BDFB0FB1AAF69C18212CBCFD42F8B717
|
||||||
40220A533CCACB3A1CE9DBF1A8A430A1
|
40220A533CCACB3A1CE9DBF1A8A430A1
|
||||||
EEB29D1DDA3A3015BC645A989B5BD38E
|
EEB29D1DDA3A3015BC645A989B5BD38E
|
||||||
|
5AEE3C678C80E0389C3B0D9D11886EB6
|
|
@ -186,6 +186,9 @@ export const GROUP_BASIC_FIELDS_FRAGMENTS = gql`
|
||||||
...PostBasicFields
|
...PostBasicFields
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
members {
|
||||||
|
total
|
||||||
|
}
|
||||||
}
|
}
|
||||||
${ACTOR_FRAGMENT}
|
${ACTOR_FRAGMENT}
|
||||||
${ADDRESS_FRAGMENT}
|
${ADDRESS_FRAGMENT}
|
||||||
|
|
|
@ -26,7 +26,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
|
||||||
relay = get_actor()
|
relay = get_actor()
|
||||||
|
|
||||||
unless Regex.match?(~r/BEGIN RSA PRIVATE KEY/, relay.keys) do
|
unless Regex.match?(~r/BEGIN RSA PRIVATE KEY/, relay.keys) do
|
||||||
{:ok, relay} = Actors.actor_key_rotation(relay)
|
{:ok, _relay} = Actors.actor_key_rotation(relay)
|
||||||
end
|
end
|
||||||
|
|
||||||
relay
|
relay
|
||||||
|
|
|
@ -26,7 +26,11 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
|
||||||
Logger.debug("fetching tags")
|
Logger.debug("fetching tags")
|
||||||
Logger.debug(inspect(tags))
|
Logger.debug(inspect(tags))
|
||||||
|
|
||||||
tags |> Enum.flat_map(&fetch_tag/1) |> Enum.uniq() |> Enum.map(&existing_tag_or_data/1)
|
tags
|
||||||
|
|> Enum.flat_map(&fetch_tag/1)
|
||||||
|
|> Enum.uniq()
|
||||||
|
|> Enum.filter(& &1)
|
||||||
|
|> Enum.map(&existing_tag_or_data/1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_tags(_), do: []
|
def fetch_tags(_), do: []
|
||||||
|
@ -122,6 +126,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
|
||||||
create_mention(mention, acc)
|
create_mention(mention, acc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp create_mention(_, acc), do: acc
|
||||||
|
|
||||||
@spec maybe_fetch_actor_and_attributed_to_id(map()) ::
|
@spec maybe_fetch_actor_and_attributed_to_id(map()) ::
|
||||||
{:ok, Actor.t(), Actor.t() | nil} | {:error, atom()}
|
{:ok, Actor.t(), Actor.t() | nil} | {:error, atom()}
|
||||||
def maybe_fetch_actor_and_attributed_to_id(%{
|
def maybe_fetch_actor_and_attributed_to_id(%{
|
||||||
|
@ -179,8 +185,10 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
|
||||||
|
|
||||||
def maybe_fetch_actor_and_attributed_to_id(_), do: {:error, :no_actor_found}
|
def maybe_fetch_actor_and_attributed_to_id(_), do: {:error, :no_actor_found}
|
||||||
|
|
||||||
@spec fetch_actor(String.t()) :: {:ok, Actor.t()} | {:error, atom()}
|
@spec fetch_actor(String.t() | map()) :: {:ok, Actor.t()} | {:error, atom()}
|
||||||
def fetch_actor(actor_url) do
|
def fetch_actor(%{"id" => actor_url}) when is_binary(actor_url), do: fetch_actor(actor_url)
|
||||||
|
|
||||||
|
def fetch_actor(actor_url) when is_binary(actor_url) do
|
||||||
case ActivityPubActor.get_or_fetch_actor_by_url(actor_url) do
|
case ActivityPubActor.get_or_fetch_actor_by_url(actor_url) do
|
||||||
{:ok, %Actor{suspended: false} = actor} ->
|
{:ok, %Actor{suspended: false} = actor} ->
|
||||||
{:ok, actor}
|
{:ok, actor}
|
||||||
|
@ -193,6 +201,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch_actor(_), do: {:error, :no_actor_found}
|
||||||
|
|
||||||
@spec process_pictures(map(), integer()) :: Keyword.t()
|
@spec process_pictures(map(), integer()) :: Keyword.t()
|
||||||
def process_pictures(object, actor_id) do
|
def process_pictures(object, actor_id) do
|
||||||
attachements = Map.get(object, "attachment", [])
|
attachements = Map.get(object, "attachment", [])
|
||||||
|
|
|
@ -195,6 +195,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Discussion do
|
||||||
else
|
else
|
||||||
{:member, false} ->
|
{:member, false} ->
|
||||||
{:error, :unauthorized}
|
{:error, :unauthorized}
|
||||||
|
|
||||||
|
{:error, %Ecto.Changeset{} = err} ->
|
||||||
|
{:error, err}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -282,6 +282,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do
|
||||||
{:error,
|
{:error,
|
||||||
dgettext("errors", "Participation is confirmed but not approved yet by an organizer")}
|
dgettext("errors", "Participation is confirmed but not approved yet by an organizer")}
|
||||||
|
|
||||||
|
{:has_participant, %Participant{role: :participant}} ->
|
||||||
|
{:error, dgettext("errors", "Participation is already confirmed")}
|
||||||
|
|
||||||
{:has_participant, nil} ->
|
{:has_participant, nil} ->
|
||||||
{:error, dgettext("errors", "This token is invalid")}
|
{:error, dgettext("errors", "This token is invalid")}
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,7 @@ defmodule Mobilizon.Actors.Actor do
|
||||||
|> put_address(attrs)
|
|> put_address(attrs)
|
||||||
|> unique_constraint(:url, name: :actors_url_index)
|
|> unique_constraint(:url, name: :actors_url_index)
|
||||||
|> unique_constraint(:preferred_username, name: :actors_preferred_username_domain_type_index)
|
|> unique_constraint(:preferred_username, name: :actors_preferred_username_domain_type_index)
|
||||||
|> validate_format(:preferred_username, ~r/[a-z0-9_]+/)
|
|> validate_format(:preferred_username, ~r/[A-z0-9_]+/)
|
||||||
|> put_change(:last_refreshed_at, DateTime.utc_now() |> DateTime.truncate(:second))
|
|> put_change(:last_refreshed_at, DateTime.utc_now() |> DateTime.truncate(:second))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ defmodule Mobilizon.Service.Formatter do
|
||||||
|
|
||||||
{link, %{acc | mentions: MapSet.put(acc.mentions, {"@" <> nickname, actor})}}
|
{link, %{acc | mentions: MapSet.put(acc.mentions, {"@" <> nickname, actor})}}
|
||||||
|
|
||||||
# Ignore groups mentions for now
|
# Ignore every other actor type mentions for now
|
||||||
{:ok, %Actor{type: :Group}} ->
|
{:ok, %Actor{}} ->
|
||||||
{buffer, acc}
|
{buffer, acc}
|
||||||
|
|
||||||
{:error, _} ->
|
{:error, _} ->
|
||||||
|
|
|
@ -26,10 +26,13 @@ defmodule Mobilizon.Web.ExportController do
|
||||||
{:error, :not_found}
|
{:error, :not_found}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{:error,
|
send_resp(
|
||||||
dgettext("errors", "Export to format %{format} is not enabled on this instance",
|
conn,
|
||||||
format: format
|
404,
|
||||||
)}
|
dgettext("errors", "Export to format %{format} is not enabled on this instance",
|
||||||
|
format: format
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1136,6 +1136,15 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
|
||||||
assert %Participant{role: :participant} =
|
assert %Participant{role: :participant} =
|
||||||
event.id |> Events.list_participants_for_event() |> Map.get(:elements) |> hd()
|
event.id |> Events.list_participants_for_event() |> Map.get(:elements) |> hd()
|
||||||
|
|
||||||
|
res =
|
||||||
|
conn
|
||||||
|
|> AbsintheHelpers.graphql_query(
|
||||||
|
query: @confirmation_mutation,
|
||||||
|
variables: %{confirmationToken: confirmation_token}
|
||||||
|
)
|
||||||
|
|
||||||
|
assert hd(res["errors"])["message"] == "Participation is already confirmed"
|
||||||
|
|
||||||
assert_email_sent(to: @email)
|
assert_email_sent(to: @email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -262,11 +262,16 @@ defmodule Mobilizon.Web.ActivityPubControllerTest do
|
||||||
conn
|
conn
|
||||||
|> get(Actor.build_url(actor.preferred_username, :outbox, page: 0))
|
|> get(Actor.build_url(actor.preferred_username, :outbox, page: 0))
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|> Map.get("orderedItems")
|
||||||
|
# Published time can be different while we reach the second page
|
||||||
|
|> Enum.map(&Map.drop(&1, ["published"]))
|
||||||
|
|
||||||
page_1_result =
|
page_1_result =
|
||||||
conn
|
conn
|
||||||
|> get(Actor.build_url(actor.preferred_username, :outbox, page: 1))
|
|> get(Actor.build_url(actor.preferred_username, :outbox, page: 1))
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|> Map.get("orderedItems")
|
||||||
|
|> Enum.map(&Map.drop(&1, ["published"]))
|
||||||
|
|
||||||
assert page_0_result == page_1_result
|
assert page_0_result == page_1_result
|
||||||
end
|
end
|
||||||
|
|
13
test/web/controllers/export_controller_test.exs
Normal file
13
test/web/controllers/export_controller_test.exs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Portions of this file are derived from Pleroma:
|
||||||
|
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/web_finger/web_finger_test.exs
|
||||||
|
|
||||||
|
defmodule Mobilizon.Web.ExportControllerTest do
|
||||||
|
use Mobilizon.Web.ConnCase
|
||||||
|
|
||||||
|
test "GET /.well-known/webfinger with no query", %{conn: conn} do
|
||||||
|
conn = get(conn, "/exports/not_existing/whatever")
|
||||||
|
assert response(conn, 404) == "Export to format not_existing is not enabled on this instance"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue