Merge branch 'fixes' into 'main'

Various fixes

Closes #1198 et #1210

See merge request framasoft/mobilizon!1341
This commit is contained in:
Thomas Citharel 2022-11-22 12:28:05 +00:00
commit 454a6188cc
11 changed files with 83 additions and 30 deletions

View file

@ -39,7 +39,7 @@ config :mobilizon, Mobilizon.Storage.Repo,
password: System.get_env("MOBILIZON_DATABASE_PASSWORD", "password"),
database: System.get_env("MOBILIZON_DATABASE_DBNAME", "mobilizon"),
hostname: System.get_env("MOBILIZON_DATABASE_HOST", "postgres"),
port: System.get_env("MOBILIZON_DATABASE_PORT", 5432),
port: System.get_env("MOBILIZON_DATABASE_PORT", "5432"),
pool_size: 10
config :mobilizon, Mobilizon.Web.Email.Mailer,

View file

@ -1,12 +1,12 @@
<template>
<li
class="bg-white dark:bg-zinc-800 rounded p-2"
:class="{
reply: comment.inReplyToComment,
'bg-purple-2': comment.isAnnouncement,
'bg-violet-1': commentSelected,
'bg-mbz-purple-50 dark:bg-mbz-purple-500': comment.isAnnouncement,
'bg-mbz-bluegreen-50 dark:bg-mbz-bluegreen-600': commentSelected,
'shadow-none': !rootComment,
}"
class="bg-white dark:bg-zinc-900 rounded p-2"
>
<article :id="commentId" dir="auto" class="mbz-comment">
<div>
@ -53,6 +53,7 @@
v-html="comment.text"
dir="auto"
:lang="comment.language"
class="prose dark:prose-invert xl:prose-lg !max-w-full" :class="{ 'text-black dark:text-white': comment.isAnnouncement}"
/>
<div v-else>{{ t("[This comment has been deleted]") }}</div>
<nav class="flex gap-1 mt-1" v-if="!comment.deletedAt">

View file

@ -1,5 +1,6 @@
<template>
<o-button
tag="a"
outlined
variant="primary"
:icon-left="oauthProvider.id"
@ -9,6 +10,7 @@
<span>{{ SELECTED_PROVIDERS[oauthProvider.id] }}</span></o-button
>
<o-button
tag="a"
outlined
variant="primary"
:href="`/auth/${oauthProvider.id}`"

View file

@ -246,6 +246,8 @@ const icons: Record<string, () => Promise<any>> = {
import(
`../../../node_modules/vue-material-design-icons/BellOffOutline.vue`
),
ExitToApp: () =>
import(`../../../node_modules/vue-material-design-icons/ExitToApp.vue`),
};
const props = withDefaults(

View file

@ -8,10 +8,16 @@ const shortDisjunctionFormatter = new Intl.ListFormat(undefined, {
type: "disjunction",
});
const listFormatAvailable = typeof Intl?.ListFormat === "function";
export const listShortConjunctionFormatter = (list: Array<string>): string => {
return shortConjunctionFormatter.format(list);
return listFormatAvailable
? shortConjunctionFormatter.format(list)
: list.join(",");
};
export const listShortDisjunctionFormatter = (list: Array<string>): string => {
return shortDisjunctionFormatter.format(list);
return listFormatAvailable
? shortDisjunctionFormatter.format(list)
: list.join(",");
};

View file

@ -184,7 +184,7 @@
<o-button
variant="success"
v-if="props.row.role === MemberRole.NOT_APPROVED"
@click="approveMember(props.row.id)"
@click="approveMember({ memberId: props.row.id })"
icon-left="check"
>{{ t("Approve member") }}</o-button
>
@ -238,7 +238,6 @@
</template>
<script lang="ts" setup>
import { FETCH_GROUP } from "@/graphql/group";
import { MemberRole } from "@/types/enums";
import { IMember } from "@/types/actor/member.model";
import RouteName from "@/router/name";
@ -312,6 +311,12 @@ const {
refetchQueries: [
{
query: GROUP_MEMBERS,
variables: {
groupName: props.preferredUsername,
page: page.value,
limit: MEMBERS_PER_PAGE,
roles: roles.value,
},
},
],
}));
@ -363,6 +368,12 @@ const {
refetchQueries: [
{
query: GROUP_MEMBERS,
variables: {
groupName: props.preferredUsername,
page: page.value,
limit: MEMBERS_PER_PAGE,
roles: roles.value,
},
},
],
}));
@ -423,7 +434,20 @@ const {
onDone: onApproveMemberDone,
onError: onApproveMemberError,
} = useMutation<{ approveMember: IMember }, { memberId: string }>(
APPROVE_MEMBER
APPROVE_MEMBER,
{
refetchQueries: [
{
query: GROUP_MEMBERS,
variables: {
groupName: props.preferredUsername,
page: page.value,
limit: MEMBERS_PER_PAGE,
roles: roles.value,
},
},
],
}
);
onApproveMemberDone(() => {
@ -452,8 +476,13 @@ const {
>(UPDATE_MEMBER, () => ({
refetchQueries: [
{
query: FETCH_GROUP,
variables: { name: props.preferredUsername },
query: GROUP_MEMBERS,
variables: {
groupName: props.preferredUsername,
page: page.value,
limit: MEMBERS_PER_PAGE,
roles: roles.value,
},
},
],
}));

View file

@ -38,16 +38,16 @@ module.exports = {
},
"mbz-purple": {
DEFAULT: "#424056",
50: "#9C9AB4",
100: "#918EAB",
200: "#7A779A",
300: "#666385",
400: "#54516D",
500: "#424056",
600: "#292836",
700: "#111016",
800: "#000000",
900: "#000000",
50: "#CAC9D7",
100: "#BEBDCE",
200: "#A8A6BC",
300: "#918EAB",
400: "#7A779A",
500: "#666385",
600: "#54516D",
700: "#424056",
800: "#292836",
900: "#111016",
},
"mbz-bluegreen": {
DEFAULT: "#1E7D97",

View file

@ -31,7 +31,7 @@ defmodule Mobilizon.Storage.Page do
fn -> Repo.all(paginate(query, page, limit)) end
]
|> Enum.map(&Task.async/1)
|> Enum.map(&Task.await(&1, 15_000))
|> Enum.map(&Task.await(&1, 30_000))
%__MODULE__{total: total, elements: elements}
end

View file

@ -14,11 +14,11 @@ defmodule Mobilizon.Service.Workers.EventDelayedNotificationWorker do
@impl Oban.Worker
def perform(%Job{args: %{"action" => "notify_of_new_event", "event_uuid" => event_uuid}}) do
case Events.get_event_by_uuid_with_preload(event_uuid) do
%Event{} = event ->
%Event{draft: false} = event ->
Group.notify_of_new_event(event)
nil ->
# Event deleted inbetween, no worries, just ignore
# Event still a draft or event deleted inbetween, no worries, just ignore
:ok
end
end
@ -44,7 +44,7 @@ defmodule Mobilizon.Service.Workers.EventDelayedNotificationWorker do
)
_ ->
# Event deleted inbetween, no worries, just ignore
# Event still a draft or event deleted inbetween, no worries, just ignore
:ok
end
end

View file

@ -85,8 +85,9 @@ defmodule Mobilizon.Web.ActivityPubController do
actor = Map.get(conn.assigns, :actor)
if actor_applicant_group_member?(group, actor) do
json(
conn,
conn
|> put_resp_content_type("application/activity+json")
|> json(
ActorView.render("member.json", %{
member: member,
actor_applicant: actor
@ -168,7 +169,7 @@ defmodule Mobilizon.Web.ActivityPubController do
def relay(conn, _params) do
with {status, %Actor{} = actor} when status in [:commit, :ok] <- Cache.get_relay() do
conn
|> put_resp_header("content-type", "application/activity+json")
|> put_resp_content_type("application/activity+json")
|> json(ActorView.render("actor.json", %{actor: actor}))
end
end
@ -194,7 +195,7 @@ defmodule Mobilizon.Web.ActivityPubController do
page <- max(page, 1),
%Actor{} = actor <- Actors.get_local_actor_by_name_with_preload(name) do
conn
|> put_resp_header("content-type", "application/activity+json")
|> put_resp_content_type("application/activity+json")
|> json(
ActorView.render("#{collection}.json", %{
actor: actor,
@ -208,7 +209,7 @@ defmodule Mobilizon.Web.ActivityPubController do
defp actor_collection(conn, collection, %{"name" => name}) do
with %Actor{} = actor <- Actors.get_local_actor_by_name_with_preload(name) do
conn
|> put_resp_header("content-type", "application/activity+json")
|> put_resp_content_type("application/activity+json")
|> json(
ActorView.render("#{collection}.json", %{
actor: actor,

View file

@ -141,11 +141,13 @@ defmodule Mobilizon.Web.PageController do
%Tombstone{} ->
conn
|> put_status(:gone)
|> maybe_add_content_type_header()
|> render(object_type, object: object)
_ ->
conn
|> maybe_add_noindex_header(object)
|> maybe_add_content_type_header()
|> render(object_type, object: object)
end
@ -199,4 +201,14 @@ defmodule Mobilizon.Web.PageController do
@spec is_person?(Actor.t()) :: boolean()
defp is_person?(%Actor{type: :Person}), do: true
defp is_person?(_), do: false
defp maybe_add_content_type_header(conn) do
case get_format(conn) do
"html" ->
conn
"activity-json" ->
put_resp_content_type(conn, "application/activity+json")
end
end
end