From 32caebb1d0f977f6993959f82d5d4416a88d30b1 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 3 Dec 2023 18:05:52 +0100 Subject: [PATCH] fix: prevent sending group physical address if it's empty and allow empty text for timezone As old addresses don't hold TZ information Closes #1357 Signed-off-by: Thomas Citharel --- lib/graphql/schema/custom/timezone.ex | 2 ++ src/views/Group/CreateView.vue | 6 +++++- src/views/Group/GroupSettings.vue | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/graphql/schema/custom/timezone.ex b/lib/graphql/schema/custom/timezone.ex index cd20efc01..ad409acf4 100644 --- a/lib/graphql/schema/custom/timezone.ex +++ b/lib/graphql/schema/custom/timezone.ex @@ -17,6 +17,8 @@ defmodule Mobilizon.GraphQL.Schema.Custom.Timezone do @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: ""}), do: {:ok, nil} + defp decode(%Absinthe.Blueprint.Input.String{value: value}) do if Tzdata.zone_exists?(value), do: {:ok, value}, diff --git a/src/views/Group/CreateView.vue b/src/views/Group/CreateView.vue index 232b4975e..94fa1a3e3 100644 --- a/src/views/Group/CreateView.vue +++ b/src/views/Group/CreateView.vue @@ -287,12 +287,16 @@ const buildVariables = computed(() => { preferredUsername: group.value.preferredUsername, name: group.value.name, summary: group.value.summary, - physicalAddress: cloneGroup.physicalAddress, visibility: group.value.visibility, openness: group.value.openness, manuallyApprovesFollowers: group.value.manuallyApprovesFollowers, }; + if (cloneGroup.physicalAddress?.id || cloneGroup.physicalAddress?.geom) { + // @ts-expect-error No type for this variable + groupBasic.physicalAddress = cloneGroup.physicalAddress; + } + if (avatarFile.value) { avatarObj = { avatar: { diff --git a/src/views/Group/GroupSettings.vue b/src/views/Group/GroupSettings.vue index f49ba39d1..d32d32cb5 100644 --- a/src/views/Group/GroupSettings.vue +++ b/src/views/Group/GroupSettings.vue @@ -345,7 +345,7 @@ const currentAddress = computed({ return editableGroup.value?.physicalAddress ?? null; }, set(address: IAddress | null) { - if (editableGroup.value && address) { + if (editableGroup.value && address && (address.id || address.geom)) { editableGroup.value = { ...editableGroup.value, physicalAddress: address,