Merge branch 'fixes' into 'main'

Various fixes

Closes #1275 et #1251

See merge request framasoft/mobilizon!1406
This commit is contained in:
Thomas Citharel 2023-06-05 09:11:20 +00:00
commit d14a1e1288
12 changed files with 55 additions and 15 deletions

View file

@ -295,7 +295,7 @@ export const JOIN_EVENT = gql`
$email: String $email: String
$message: String $message: String
$locale: String $locale: String
$timezone: String $timezone: Timezone
) { ) {
joinEvent( joinEvent(
eventId: $eventId eventId: $eventId

View file

@ -151,7 +151,7 @@ export const LOGGED_USER_TIMEZONE = gql`
export const SET_USER_SETTINGS = gql` export const SET_USER_SETTINGS = gql`
mutation SetUserSettings( mutation SetUserSettings(
$timezone: String $timezone: Timezone
$notificationOnDay: Boolean $notificationOnDay: Boolean
$notificationEachWeek: Boolean $notificationEachWeek: Boolean
$notificationBeforeEvent: Boolean $notificationBeforeEvent: Boolean

View file

@ -426,7 +426,9 @@
> >
<option <option
v-for="timezone in groupTimezones" v-for="timezone in groupTimezones"
:value="`${group}/${timezone}`" :value="
group === t('Other') ? timezone : `${group}/${timezone}`
"
:key="timezone" :key="timezone"
> >
{{ sanitizeTimezone(timezone) }} {{ sanitizeTimezone(timezone) }}

View file

@ -73,7 +73,7 @@
<tr v-for="subType in notificationType.subtypes" :key="subType.id"> <tr v-for="subType in notificationType.subtypes" :key="subType.id">
<td v-for="(method, key) in notificationMethods" :key="key"> <td v-for="(method, key) in notificationMethods" :key="key">
<o-checkbox <o-checkbox
:value="notificationValues[subType.id][key].enabled" :modelValue="notificationValues[subType.id][key].enabled"
@update:modelValue=" @update:modelValue="
(e: boolean) => (e: boolean) =>
updateNotificationValue({ updateNotificationValue({
@ -645,7 +645,7 @@ const dialog = inject<Dialog>("dialog");
const openRegenerateFeedTokensConfirmation = () => { const openRegenerateFeedTokensConfirmation = () => {
dialog?.confirm({ dialog?.confirm({
type: "warning", variant: "warning",
title: t("Regenerate new links") as string, title: t("Regenerate new links") as string,
message: t( message: t(
"You'll need to change the URLs where there were previously entered." "You'll need to change the URLs where there were previously entered."

View file

@ -31,6 +31,7 @@ defmodule Mobilizon.GraphQL.Schema do
import_types(Absinthe.Plug.Types) import_types(Absinthe.Plug.Types)
import_types(Custom.UUID) import_types(Custom.UUID)
import_types(Custom.Point) import_types(Custom.Point)
import_types(Custom.Timezone)
import_types(Schema.ActivityType) import_types(Schema.ActivityType)
import_types(Schema.UserType) import_types(Schema.UserType)

View file

@ -22,7 +22,7 @@ defmodule Mobilizon.GraphQL.Schema.AddressType do
field(:url, :string, description: "The address's URL") field(:url, :string, description: "The address's URL")
field(:id, :id, description: "The address's ID") field(:id, :id, description: "The address's ID")
field(:origin_id, :string, description: "The address's original ID from the provider") field(:origin_id, :string, description: "The address's original ID from the provider")
field(:timezone, :string, description: "The (estimated) timezone of the location") field(:timezone, :timezone, description: "The (estimated) timezone of the location")
field(:picture_info, :picture_info, description: "A picture associated with the address") field(:picture_info, :picture_info, description: "A picture associated with the address")
end end
@ -75,7 +75,7 @@ defmodule Mobilizon.GraphQL.Schema.AddressType do
field(:url, :string, description: "The address's URL") field(:url, :string, description: "The address's URL")
field(:id, :id, description: "The address's ID") field(:id, :id, description: "The address's ID")
field(:origin_id, :string, description: "The address's original ID from the provider") field(:origin_id, :string, description: "The address's original ID from the provider")
field(:timezone, :string, description: "The (estimated) timezone of the location") field(:timezone, :timezone, description: "The (estimated) timezone of the location")
end end
@desc """ @desc """

View file

@ -43,7 +43,7 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
field(:upload_limits, :upload_limits, description: "The configuration for upload limits") field(:upload_limits, :upload_limits, description: "The configuration for upload limits")
field(:timezones, list_of(:string), description: "The instance's available timezones") field(:timezones, list_of(:timezone), description: "The instance's available timezones")
field(:features, :features, description: "The instance's features") field(:features, :features, description: "The instance's features")
field(:restrictions, :restrictions, description: "The instance's restrictions") field(:restrictions, :restrictions, description: "The instance's restrictions")
field(:version, :string, description: "The instance's version") field(:version, :string, description: "The instance's version")

View file

@ -0,0 +1,35 @@
defmodule Mobilizon.GraphQL.Schema.Custom.Timezone do
@moduledoc """
The timezone scalar type allows timezone ID strings to be passed in and out.
"""
use Absinthe.Schema.Notation
import Mobilizon.Web.Gettext, only: [dgettext: 3]
scalar :timezone, name: "Timezone" do
description("""
The `Timezone` scalar type represents a timezone identifier,
as registered in the IANA Time Zone Database.
""")
serialize(&encode/1)
parse(&decode/1)
end
@spec decode(Absinthe.Blueprint.Input.String.t()) :: {:ok, term} | :error
@spec decode(Absinthe.Blueprint.Input.Null.t()) :: {:ok, nil}
defp decode(%Absinthe.Blueprint.Input.String{value: value}) do
if Tzdata.zone_exists?(value),
do: {:ok, value},
else: {:error, dgettext("errors", "Timezone ID %{timezone} is invalid", timezone: value)}
end
defp decode(%Absinthe.Blueprint.Input.Null{}) do
{:ok, nil}
end
defp decode(_) do
:error
end
defp encode(value), do: value
end

View file

@ -250,7 +250,7 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
field(:show_start_time, :boolean, description: "Show event start time") field(:show_start_time, :boolean, description: "Show event start time")
field(:show_end_time, :boolean, description: "Show event end time") field(:show_end_time, :boolean, description: "Show event end time")
field(:timezone, :string, description: "The event's timezone") field(:timezone, :timezone, description: "The event's timezone")
field(:hide_organizer_when_group_event, :boolean, field(:hide_organizer_when_group_event, :boolean,
description: description:
@ -303,7 +303,7 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
field(:show_start_time, :boolean, description: "Show event start time") field(:show_start_time, :boolean, description: "Show event start time")
field(:show_end_time, :boolean, description: "Show event end time") field(:show_end_time, :boolean, description: "Show event end time")
field(:timezone, :string, description: "The event's timezone") field(:timezone, :timezone, description: "The event's timezone")
field(:hide_organizer_when_group_event, :boolean, field(:hide_organizer_when_group_event, :boolean,
description: description:

View file

@ -96,7 +96,7 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
arg(:email, :string, description: "The anonymous participant's email") arg(:email, :string, description: "The anonymous participant's email")
arg(:message, :string, description: "The anonymous participant's message") arg(:message, :string, description: "The anonymous participant's message")
arg(:locale, :string, description: "The anonymous participant's locale") arg(:locale, :string, description: "The anonymous participant's locale")
arg(:timezone, :string, description: "The anonymous participant's timezone") arg(:timezone, :timezone, description: "The anonymous participant's timezone")
middleware(Rajska.QueryAuthorization, permit: :all, rule: :"write:participation") middleware(Rajska.QueryAuthorization, permit: :all, rule: :"write:participation")
resolve(&Participant.actor_join_event/3) resolve(&Participant.actor_join_event/3)
end end

View file

@ -220,7 +220,7 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
""" """
object :user_settings do object :user_settings do
meta(:authorize, :user) meta(:authorize, :user)
field(:timezone, :string, description: "The timezone for this user") field(:timezone, :timezone, description: "The timezone for this user")
field(:notification_on_day, :boolean, field(:notification_on_day, :boolean,
description: "Whether this user will receive an email at the start of the day of an event." description: "Whether this user will receive an email at the start of the day of an event."
@ -450,7 +450,7 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
@desc "Set user settings" @desc "Set user settings"
field :set_user_settings, :user_settings do field :set_user_settings, :user_settings do
arg(:timezone, :string, description: "The timezone for this user") arg(:timezone, :timezone, description: "The timezone for this user")
arg(:notification_on_day, :boolean, arg(:notification_on_day, :boolean,
description: description:

View file

@ -4,6 +4,7 @@ defmodule Mobilizon.GraphQL.Schema.Users.ActivitySetting do
""" """
use Absinthe.Schema.Notation use Absinthe.Schema.Notation
alias Mobilizon.GraphQL.Resolvers.Users.ActivitySettings alias Mobilizon.GraphQL.Resolvers.Users.ActivitySettings
alias Mobilizon.Users.ActivitySetting
object :activity_setting do object :activity_setting do
meta(:authorize, :user) meta(:authorize, :user)
@ -21,8 +22,9 @@ defmodule Mobilizon.GraphQL.Schema.Users.ActivitySetting do
middleware(Rajska.QueryAuthorization, middleware(Rajska.QueryAuthorization,
permit: :user, permit: :user,
scope: false, scope: ActivitySetting,
rule: :"write:user:setting:activity" rule: :"write:user:setting:activity",
args: %{key: :key}
) )
resolve(&ActivitySettings.upsert_user_activity_setting/3) resolve(&ActivitySettings.upsert_user_activity_setting/3)