Merge branch 'bugs' into 'main'

Various bugs

Closes #962, #964, #960 et #963

See merge request framasoft/mobilizon!1130
This commit is contained in:
Thomas Citharel 2021-11-29 10:34:46 +00:00
commit 1e1a145847
12 changed files with 67 additions and 46 deletions

View file

@ -190,30 +190,6 @@ pages:
services: services:
- docker:stable-dind - docker:stable-dind
cache: {} cache: {}
tags:
- "privileged"
build-docker-main:
<<: *docker
rules:
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
before_script:
# Login to DockerHub
- mkdir -p ~/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > ~/.docker/config.json
script:
- docker build -t framasoft/mobilizon:main -f docker/production/Dockerfile .
- docker push framasoft/mobilizon:main
build-docker-tag:
<<: *docker
rules: &tag-rules
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
when: never
- if: $CI_COMMIT_TAG
timeout: 3 hours
before_script: before_script:
# Install buildx # Install buildx
- wget https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64 - wget https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64
@ -229,6 +205,25 @@ build-docker-tag:
# Login to DockerHub # Login to DockerHub
- mkdir -p ~/.docker - mkdir -p ~/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > ~/.docker/config.json - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > ~/.docker/config.json
tags:
- "privileged"
build-docker-main:
<<: *docker
rules:
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
script:
- docker buildx build --push --platform linux/amd64 -t framasoft/mobilizon:main -f docker/production/Dockerfile .
build-docker-tag:
<<: *docker
rules: &tag-rules
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
when: never
- if: $CI_COMMIT_TAG
timeout: 3 hours
script: script:
- > - >
docker buildx build docker buildx build

View file

@ -15,13 +15,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Make sure my group upcoming events are ordered by their start date - Make sure my group upcoming events are ordered by their start date
- Fix event participants pagination - Fix event participants pagination
- Always focus the search field after results have been fetched - Always focus the search field after results have been fetched
- Don't sign fetches to instance actor when refreshing their keys
- Fix reject of already following instances
- Added missing timezone data to the Docker image - Added missing timezone data to the Docker image
- Replace @tiptap/starter-kit with indidual extensions, removing unneeded extensions that caused issues on old Firefox versions - Replace @tiptap/starter-kit with indidual extensions, removing unneeded extensions that caused issues on old Firefox versions
- Better handling of Friendica Update activities without actor information - Better handling of Friendica Update activities without actor information
- Always show pending/cancelled status on event cards - Always show pending/cancelled status on event cards
- Fixed nightly docker build
- Refresh loggeduser information before the final step of onboarding, avoiding loop when finishing onboarding
- Handle tz_world data being absent
### Translations ### Translations
- Croatian (New !)
- Czech - Czech
- Gaelic - Gaelic
- Hungarian - Hungarian

View file

@ -30,8 +30,7 @@ COPY rel ./rel
COPY support ./support COPY support ./support
COPY --from=assets ./priv/static ./priv/static COPY --from=assets ./priv/static ./priv/static
RUN mix tz_world.update \ RUN mix phx.digest.clean --all \
&& mix phx.digest.clean --all \
&& mix release && mix release
# Finally setup the app # Finally setup the app
@ -50,11 +49,13 @@ LABEL org.opencontainers.image.title="mobilizon" \
org.opencontainers.image.revision=$VCS_REF \ org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.created=$BUILD_DATE org.opencontainers.image.created=$BUILD_DATE
RUN apk add --no-cache openssl ca-certificates ncurses-libs file postgresql-client libgcc libstdc++ imagemagick python3 py3-pip py3-pillow py3-cffi py3-brotli gcc musl-dev python3-dev pango libxslt-dev RUN apk add --no-cache curl openssl ca-certificates ncurses-libs file postgresql-client libgcc libstdc++ imagemagick python3 py3-pip py3-pillow py3-cffi py3-brotli gcc musl-dev python3-dev pango libxslt-dev
RUN pip install weasyprint pyexcel-ods3 RUN pip install weasyprint pyexcel-ods3
RUN mkdir -p /var/lib/mobilizon/uploads && chown nobody:nobody /var/lib/mobilizon/uploads RUN mkdir -p /var/lib/mobilizon/uploads && chown nobody:nobody /var/lib/mobilizon/uploads
RUN mkdir -p /var/lib/mobilizon/timezones && chown nobody:nobody /var/lib/mobilizon/timezones RUN mkdir -p /var/lib/mobilizon/timezones
RUN curl -L 'https://packages.joinmobilizon.org/tz_world/timezones-geodata.dets' -o /var/lib/mobilizon/timezones/timezones-geodata.dets
RUN chown nobody:nobody /var/lib/mobilizon/timezones
RUN mkdir -p /etc/mobilizon && chown nobody:nobody /etc/mobilizon RUN mkdir -p /etc/mobilizon && chown nobody:nobody /etc/mobilizon
USER nobody USER nobody

View file

@ -272,6 +272,11 @@ export default class NavBar extends Vue {
// If we don't have any identities, the user has validated their account, // If we don't have any identities, the user has validated their account,
// is logging for the first time but didn't create an identity somehow // is logging for the first time but didn't create an identity somehow
if (this.identities.length === 0) { if (this.identities.length === 0) {
console.debug(
"We have no identities listed for current user",
this.identities
);
console.debug("Pushing route to REGISTER_PROFILE");
try { try {
await this.$router.push({ await this.$router.push({
name: RouteName.REGISTER_PROFILE, name: RouteName.REGISTER_PROFILE,

View file

@ -406,7 +406,6 @@ import Subtitle from "../components/Utils/Subtitle.vue";
DateComponent, DateComponent,
EventParticipationCard, EventParticipationCard,
MultiCard, MultiCard,
"settings-onboard": () => import("./User/SettingsOnboard.vue"),
}, },
metaInfo() { metaInfo() {
return { return {
@ -569,7 +568,9 @@ export default class Home extends Vue {
@Watch("loggedUser") @Watch("loggedUser")
detectEmptyUserSettings(loggedUser: IUser): void { detectEmptyUserSettings(loggedUser: IUser): void {
console.debug("Try to detect empty user settings", loggedUser);
if (loggedUser?.id && loggedUser?.settings === null) { if (loggedUser?.id && loggedUser?.settings === null) {
console.debug("No user settings, pushing to onboarding assistant");
this.$router.push({ this.$router.push({
name: RouteName.WELCOME_SCREEN, name: RouteName.WELCOME_SCREEN,
params: { step: "1" }, params: { step: "1" },

View file

@ -49,7 +49,8 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator"; import { USER_SETTINGS } from "@/graphql/user";
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import { TIMEZONES } from "../../graphql/config"; import { TIMEZONES } from "../../graphql/config";
import RouteName from "../../router/name"; import RouteName from "../../router/name";
import { IConfig } from "../../types/config.model"; import { IConfig } from "../../types/config.model";
@ -65,6 +66,7 @@ import { IConfig } from "../../types/config.model";
}, },
apollo: { apollo: {
config: TIMEZONES, config: TIMEZONES,
loggedUser: USER_SETTINGS,
}, },
metaInfo() { metaInfo() {
return { return {
@ -82,6 +84,11 @@ export default class SettingsOnboard extends Vue {
get stepIndex(): number { get stepIndex(): number {
return this.step - 1; return this.step - 1;
} }
@Watch("stepIndex")
refetchUserSettings() {
this.$apollo.queries.loggedUser.refetch();
}
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View file

@ -14,37 +14,38 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do
@doc """ @doc """
Getting an actor from url, eventually creating it if we don't have it locally or if it needs an update Getting an actor from url, eventually creating it if we don't have it locally or if it needs an update
""" """
@spec get_or_fetch_actor_by_url(url :: String.t(), preload :: boolean()) :: @spec get_or_fetch_actor_by_url(url :: String.t(), options :: Keyword.t()) ::
{:ok, Actor.t()} {:ok, Actor.t()}
| {:error, make_actor_errors} | {:error, make_actor_errors}
| {:error, :no_internal_relay_actor} | {:error, :no_internal_relay_actor}
| {:error, :url_nil} | {:error, :url_nil}
def get_or_fetch_actor_by_url(url, preload \\ false) def get_or_fetch_actor_by_url(url, options \\ [])
def get_or_fetch_actor_by_url(nil, _preload), do: {:error, :url_nil}
def get_or_fetch_actor_by_url("https://www.w3.org/ns/activitystreams#Public", _preload) do def get_or_fetch_actor_by_url("https://www.w3.org/ns/activitystreams#Public", _preload) do
%Actor{url: url} = Relay.get_actor() %Actor{url: url} = Relay.get_actor()
get_or_fetch_actor_by_url(url) get_or_fetch_actor_by_url(url)
end end
def get_or_fetch_actor_by_url(url, preload) do def get_or_fetch_actor_by_url(url, options) when is_binary(url) and is_list(options) do
Logger.debug("Getting or fetching actor by URL #{url}") Logger.debug("Getting or fetching actor by URL #{url}")
preload = Keyword.get(options, :preload, false)
case Actors.get_actor_by_url(url, preload) do case Actors.get_actor_by_url(url, preload) do
{:ok, %Actor{} = cached_actor} -> {:ok, %Actor{} = cached_actor} ->
if Actors.needs_update?(cached_actor) do if Actors.needs_update?(cached_actor) do
__MODULE__.make_actor_from_url(url, preload: preload) __MODULE__.make_actor_from_url(url, options)
else else
{:ok, cached_actor} {:ok, cached_actor}
end end
{:error, :actor_not_found} -> {:error, :actor_not_found} ->
# For tests, see https://github.com/jjh42/mock#not-supported---mocking-internal-function-calls and Mobilizon.Federation.ActivityPubTest # For tests, see https://github.com/jjh42/mock#not-supported---mocking-internal-function-calls and Mobilizon.Federation.ActivityPubTest
__MODULE__.make_actor_from_url(url, preload: preload) __MODULE__.make_actor_from_url(url, options)
end end
end end
def get_or_fetch_actor_by_url(nil, _preload), do: {:error, :url_nil}
@type make_actor_errors :: Fetcher.fetch_actor_errors() | :actor_is_local @type make_actor_errors :: Fetcher.fetch_actor_errors() | :actor_is_local
@doc """ @doc """

View file

@ -210,7 +210,8 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
def handle_incoming( def handle_incoming(
%{"type" => "Follow", "object" => followed, "actor" => follower, "id" => id} = _data %{"type" => "Follow", "object" => followed, "actor" => follower, "id" => id} = _data
) do ) do
with {:ok, %Actor{} = followed} <- ActivityPubActor.get_or_fetch_actor_by_url(followed, true), with {:ok, %Actor{} = followed} <-
ActivityPubActor.get_or_fetch_actor_by_url(followed, preload: true),
{:ok, %Actor{} = follower} <- ActivityPubActor.get_or_fetch_actor_by_url(follower), {:ok, %Actor{} = follower} <- ActivityPubActor.get_or_fetch_actor_by_url(follower),
{:ok, activity, object} <- {:ok, activity, object} <-
Actions.Follow.follow(follower, followed, id, false) do Actions.Follow.follow(follower, followed, id, false) do

View file

@ -52,7 +52,8 @@ defmodule Mobilizon.Federation.HTTPSignatures.Signature do
{:ok, String.t()} {:ok, String.t()}
| {:error, :actor_not_found | :pem_decode_error} | {:error, :actor_not_found | :pem_decode_error}
defp get_public_key_for_url(url) do defp get_public_key_for_url(url) do
with {:ok, %Actor{} = actor} <- ActivityPubActor.get_or_fetch_actor_by_url(url) do with {:ok, %Actor{} = actor} <-
ActivityPubActor.get_or_fetch_actor_by_url(url, ignore_sign_object_fetches: true) do
get_actor_public_key(actor) get_actor_public_key(actor)
end end
end end

View file

@ -69,8 +69,8 @@ defmodule Mobilizon.GraphQL.API.Follows do
) )
case Actors.is_following(follower, followed) do case Actors.is_following(follower, followed) do
%Follower{approved: true} -> %Follower{approved: false} ->
{:error, "Follow already accepted"} {:error, "Follow already rejected"}
%Follower{} = follow -> %Follower{} = follow ->
Actions.Reject.reject( Actions.Reject.reject(

View file

@ -18,6 +18,9 @@ defmodule Mobilizon.Service.TimezoneDetector do
{:error, :time_zone_not_found} -> {:error, :time_zone_not_found} ->
fallback fallback
{:error, :enoent} ->
fallback
end end
end end

View file

@ -126,7 +126,7 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
needs_update?: fn _ -> false end needs_update?: fn _ -> false end
]}, ]},
{ActivityPubActor, [:passthrough], {ActivityPubActor, [:passthrough],
make_actor_from_url: fn @actor_url, preload: false -> make_actor_from_url: fn @actor_url, [] ->
{:ok, {:ok,
%Actor{ %Actor{
preferred_username: "tcit", preferred_username: "tcit",
@ -138,7 +138,7 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
ActivityPubActor.get_or_fetch_actor_by_url(@actor_url) ActivityPubActor.get_or_fetch_actor_by_url(@actor_url)
assert_called(Actors.needs_update?(:_)) assert_called(Actors.needs_update?(:_))
refute called(ActivityPubActor.make_actor_from_url(@actor_url, preload: false)) refute called(ActivityPubActor.make_actor_from_url(@actor_url, []))
end end
# Fetch doesn't use cache if Actors.needs_update? returns true # Fetch doesn't use cache if Actors.needs_update? returns true
@ -155,7 +155,7 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
needs_update?: fn _ -> true end needs_update?: fn _ -> true end
]}, ]},
{ActivityPubActor, [:passthrough], {ActivityPubActor, [:passthrough],
make_actor_from_url: fn @actor_url, preload: false -> make_actor_from_url: fn @actor_url, [] ->
{:ok, {:ok,
%Actor{ %Actor{
preferred_username: "tcit", preferred_username: "tcit",
@ -169,7 +169,7 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
assert_called(ActivityPubActor.get_or_fetch_actor_by_url(@actor_url)) assert_called(ActivityPubActor.get_or_fetch_actor_by_url(@actor_url))
assert_called(Actors.get_actor_by_url(@actor_url, false)) assert_called(Actors.get_actor_by_url(@actor_url, false))
assert_called(Actors.needs_update?(:_)) assert_called(Actors.needs_update?(:_))
assert_called(ActivityPubActor.make_actor_from_url(@actor_url, preload: false)) assert_called(ActivityPubActor.make_actor_from_url(@actor_url, []))
end end
end end
@ -182,7 +182,7 @@ defmodule Mobilizon.Federation.ActivityPub.ActorTest do
assert match?( assert match?(
{:error, :actor_deleted}, {:error, :actor_deleted},
ActivityPubActor.make_actor_from_url(@actor_url, preload: false) ActivityPubActor.make_actor_from_url(@actor_url, [])
) )
end end