From 7554fd0a2757880993dd0d0c6168948ffa2046cb Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 2 Sep 2020 15:08:47 +0200 Subject: [PATCH] Allow to disable event creation And change the group toggle Signed-off-by: Thomas Citharel --- config/config.exs | 15 +++++++++------ js/src/components/NavBar.vue | 2 +- js/src/graphql/config.ts | 1 + js/src/types/config.model.ts | 1 + lib/graphql/resolvers/config.ex | 3 ++- lib/graphql/schema/config.ex | 1 + lib/mobilizon/config.ex | 6 +++++- lib/web/controllers/page_controller.ex | 1 - 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/config/config.exs b/config/config.exs index 9f75a3205..70cb04b26 100644 --- a/config/config.exs +++ b/config/config.exs @@ -22,8 +22,6 @@ config :mobilizon, :instance, repository: Mix.Project.config()[:source_url], allow_relay: true, federating: true, - # Groups are to be activated with Mobilizon 1.0.0 - groups: false, remote_limit: 100_000, upload_limit: 10_000_000, avatar_upload_limit: 2_000_000, @@ -31,10 +29,10 @@ config :mobilizon, :instance, email_from: "noreply@localhost", email_reply_to: "noreply@localhost" -config :mime, :types, %{ - "application/activity+json" => ["activity-json"], - "application/jrd+json" => ["jrd-json"] -} +# Groups are to be activated with Mobilizon 1.0.0 +config :mobilizon, :groups, enabled: false + +config :mobilizon, :events, creation: true # Configures the endpoint config :mobilizon, Mobilizon.Web.Endpoint, @@ -51,6 +49,11 @@ config :mobilizon, Mobilizon.Web.Endpoint, cache_static_manifest: "priv/static/manifest.json", has_reverse_proxy: true +config :mime, :types, %{ + "application/activity+json" => ["activity-json"], + "application/jrd+json" => ["jrd-json"] +} + # Upload configuration config :mobilizon, Mobilizon.Web.Upload, uploader: Mobilizon.Web.Upload.Uploader.Local, diff --git a/js/src/components/NavBar.vue b/js/src/components/NavBar.vue index 5d52f8c18..872f6a93a 100644 --- a/js/src/components/NavBar.vue +++ b/js/src/components/NavBar.vue @@ -18,7 +18,7 @@ v-if="config && config.features.groups" >{{ $t("My groups") }} - + {{ $t("Create") }} diff --git a/js/src/graphql/config.ts b/js/src/graphql/config.ts index 44471990c..d9eb57d6c 100644 --- a/js/src/graphql/config.ts +++ b/js/src/graphql/config.ts @@ -61,6 +61,7 @@ export const CONFIG = gql` } features { groups + eventCreation } auth { ldap diff --git a/js/src/types/config.model.ts b/js/src/types/config.model.ts index 3e53bf3bf..fa1b4922e 100644 --- a/js/src/types/config.model.ts +++ b/js/src/types/config.model.ts @@ -70,6 +70,7 @@ export interface IConfig { resourceProviders: IProvider[]; timezones: string[]; features: { + eventCreation: boolean; groups: boolean; }; federating: boolean; diff --git a/lib/graphql/resolvers/config.ex b/lib/graphql/resolvers/config.ex index 21f536f7e..a96773654 100644 --- a/lib/graphql/resolvers/config.ex +++ b/lib/graphql/resolvers/config.ex @@ -120,7 +120,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do resource_providers: Config.instance_resource_providers(), timezones: Tzdata.zone_list(), features: %{ - groups: Config.instance_group_feature_enabled?() + groups: Config.instance_group_feature_enabled?(), + event_creation: Config.instance_event_creation_enabled?() }, rules: Config.instance_rules(), version: Config.instance_version(), diff --git a/lib/graphql/schema/config.ex b/lib/graphql/schema/config.ex index e8070cbe6..56c66e189 100644 --- a/lib/graphql/schema/config.ex +++ b/lib/graphql/schema/config.ex @@ -131,6 +131,7 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do object :features do field(:groups, :boolean) + field(:event_creation, :boolean) end object :auth do diff --git a/lib/mobilizon/config.ex b/lib/mobilizon/config.ex index 9789d4bd9..f0e523536 100644 --- a/lib/mobilizon/config.ex +++ b/lib/mobilizon/config.ex @@ -227,7 +227,11 @@ defmodule Mobilizon.Config do end end - def instance_group_feature_enabled?, do: Application.get_env(:mobilizon, :instance)[:groups] + def instance_group_feature_enabled?, + do: :mobilizon |> Application.get_env(:groups) |> Keyword.get(:enabled) + + def instance_event_creation_enabled?, + do: :mobilizon |> Application.get_env(:events) |> Keyword.get(:creation) def anonymous_actor_id, do: get_cached_value(:anonymous_actor_id) def relay_actor_id, do: get_cached_value(:relay_actor_id) diff --git a/lib/web/controllers/page_controller.ex b/lib/web/controllers/page_controller.ex index 64bef0b88..b85f6f540 100644 --- a/lib/web/controllers/page_controller.ex +++ b/lib/web/controllers/page_controller.ex @@ -7,7 +7,6 @@ defmodule Mobilizon.Web.PageController do alias Mobilizon.Discussions.Comment alias Mobilizon.Events.Event alias Mobilizon.Federation.ActivityPub - alias Mobilizon.Posts.Post alias Mobilizon.Tombstone alias Mobilizon.Web.{ActivityPubController, Cache, PageController}