From 2875d263d2f08ae5e63cac22b73c4f592beb21ec Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 20 Dec 2019 13:04:34 +0100 Subject: [PATCH] Add anonymous and remote participations --- config/config.exs | 22 + config/dev.exs | 2 + config/test.exs | 4 +- js/package.json | 1 + js/src/App.vue | 9 +- js/src/assets/undraw_mail_2.svg | 1 + js/src/assets/undraw_profile.svg | 1 + .../components/Event/AddressAutoComplete.vue | 6 +- js/src/components/Event/EventListViewCard.vue | 171 +++++++ .../components/Event/ParticipationButton.vue | 40 +- js/src/components/Footer.vue | 3 + .../Participation/ConfirmParticipation.vue | 59 +++ .../ParticipationWithAccount.vue | 82 ++++ .../ParticipationWithoutAccount.vue | 109 +++++ .../Participation/UnloggedParticipation.vue | 104 +++++ js/src/components/Utils/VerticalDivider.vue | 22 + js/src/graphql/admin.ts | 42 ++ js/src/graphql/config.ts | 39 ++ js/src/graphql/event.ts | 31 +- js/src/i18n/en_US.json | 62 ++- js/src/i18n/fr_FR.json | 110 ++++- js/src/mixins/event.ts | 76 ++- js/src/router/admin.ts | 9 + js/src/router/event.ts | 33 +- js/src/router/index.ts | 14 + .../services/AnonymousParticipationStorage.ts | 128 +++++ js/src/types/admin.model.ts | 15 + js/src/types/config.model.ts | 34 ++ js/src/types/event.model.ts | 9 +- js/src/variables.scss | 8 + js/src/views/Account/MyAccount.vue | 2 +- js/src/views/Account/Register.vue | 2 +- js/src/views/Admin/Dashboard.vue | 9 +- js/src/views/Admin/Follows.vue | 4 +- js/src/views/Admin/Settings.vue | 94 ++++ js/src/views/Event/Edit.vue | 282 +++++------ js/src/views/Event/Event.vue | 162 +++---- js/src/views/Event/Explore.vue | 16 +- js/src/views/Event/MyEvents.vue | 16 +- js/src/views/Event/Participants.vue | 17 +- js/src/views/Home.vue | 16 +- js/src/views/Interact.vue | 57 +++ js/src/views/Moderation/Logs.vue | 4 +- js/src/views/Moderation/Report.vue | 5 +- js/src/views/Moderation/ReportList.vue | 2 +- js/src/views/PageNotFound.vue | 2 +- js/src/views/Terms.vue | 64 +++ js/src/views/User/Login.vue | 128 +++-- js/src/views/User/PasswordChange.vue | 2 +- js/src/views/User/PasswordReset.vue | 2 +- js/src/views/User/Register.vue | 2 +- js/src/views/User/ResendConfirmation.vue | 2 +- js/src/views/User/SendPasswordReset.vue | 2 +- js/src/views/User/Validate.vue | 2 +- js/src/vue-apollo.ts | 6 +- js/yarn.lock | 5 + lib/federation/activity_pub/activity_pub.ex | 38 +- lib/federation/activity_pub/relay.ex | 4 +- lib/federation/activity_pub/utils.ex | 4 + .../activity_stream/converter/event.ex | 2 + lib/federation/web_finger/web_finger.ex | 8 +- lib/graphql/api/participations.ex | 40 +- lib/graphql/resolvers/admin.ex | 47 +- lib/graphql/resolvers/config.ex | 97 +++- lib/graphql/resolvers/event.ex | 124 +---- lib/graphql/resolvers/participant.ex | 262 +++++++++++ lib/graphql/schema/admin.ex | 30 ++ lib/graphql/schema/config.ex | 56 +++ lib/graphql/schema/event.ex | 10 + lib/graphql/schema/events/participant.ex | 27 +- lib/mobilizon.ex | 48 +- lib/mobilizon/actors/actor.ex | 62 ++- lib/mobilizon/actors/actors.ex | 19 +- lib/mobilizon/admin/admin.ex | 47 ++ lib/mobilizon/admin/setting.ex | 27 ++ lib/mobilizon/config.ex | 123 ++++- lib/mobilizon/events/event_options.ex | 3 + .../events/event_participant_stats.ex | 4 + lib/mobilizon/events/events.ex | 45 +- lib/mobilizon/events/participant.ex | 14 + lib/mobilizon/users/user.ex | 24 +- lib/web/channels/graphql_socket.ex | 2 +- lib/web/controllers/page_controller.ex | 62 ++- lib/web/email/checker.ex | 15 + lib/web/email/participation.ex | 60 ++- lib/web/router.ex | 14 +- lib/web/templates/api/terms.html.eex | 163 +++++++ ...nymous_participation_confirmation.html.eex | 81 ++++ ...nymous_participation_confirmation.text.eex | 11 + .../event_participation_approved.html.eex | 2 +- .../event_participation_rejected.html.eex | 2 +- .../templates/email/event_updated.html.eex | 2 +- .../templates/email/password_reset.html.eex | 2 +- .../email/registration_confirmation.html.eex | 2 +- lib/web/templates/email/report.html.eex | 2 +- lib/web/views/api_view.ex | 7 + mix.exs | 76 +-- mix.lock | 2 +- priv/gettext/ar/LC_MESSAGES/default.po | 428 +++++++++++++---- priv/gettext/be/LC_MESSAGES/default.po | 428 +++++++++++++---- priv/gettext/be/LC_MESSAGES/errors.po | 93 ++++ priv/gettext/ca/LC_MESSAGES/default.po | 434 +++++++++++++---- priv/gettext/ca/LC_MESSAGES/errors.po | 87 ++++ priv/gettext/cs/LC_MESSAGES/default.po | 426 +++++++++++++---- priv/gettext/de/LC_MESSAGES/default.po | 428 +++++++++++++---- priv/gettext/default.pot | 426 +++++++++++++---- priv/gettext/en/LC_MESSAGES/default.po | 432 +++++++++++++---- priv/gettext/es/LC_MESSAGES/default.po | 426 +++++++++++++---- priv/gettext/fi/LC_MESSAGES/default.po | 428 +++++++++++++---- priv/gettext/fi/LC_MESSAGES/errors.po | 87 ++++ priv/gettext/fr/LC_MESSAGES/default.po | 434 +++++++++++++---- priv/gettext/it/LC_MESSAGES/default.po | 426 +++++++++++++---- priv/gettext/ja/LC_MESSAGES/default.po | 426 +++++++++++++---- priv/gettext/nl/LC_MESSAGES/default.po | 432 +++++++++++++---- priv/gettext/oc/LC_MESSAGES/default.po | 432 +++++++++++++---- priv/gettext/pl/LC_MESSAGES/default.po | 432 +++++++++++++---- priv/gettext/pt/LC_MESSAGES/default.po | 426 +++++++++++++---- priv/gettext/ru/LC_MESSAGES/default.po | 436 +++++++++++++---- ...1219172017_add_metadata_to_participant.exs | 27 ++ ...d_not_confirmed_status_to_participants.exs | 12 + .../20200116095117_create_admin_settings.exs | 15 + schema.graphql | 328 ++++++++----- .../activity_pub/transmogrifier_test.exs | 4 +- test/fixtures/mastodon-accept-activity.json | 2 +- test/graphql/resolvers/config_test.exs | 33 +- test/graphql/resolvers/participant_test.exs | 442 +++++++++++++++++- test/mobilizon/addresses/addresses_test.exs | 1 + test/service/geospatial/addok_test.exs | 25 +- test/service/geospatial/google_maps_test.exs | 2 +- test/service/geospatial/map_quest_test.exs | 21 +- test/service/geospatial/nominatim_test.exs | 23 +- test/service/geospatial/photon_test.exs | 21 +- test/support/factory.ex | 7 +- test/support/helpers.ex | 38 ++ .../activity_pub_controller_test.exs | 23 + 135 files changed, 10141 insertions(+), 2271 deletions(-) create mode 100644 js/src/assets/undraw_mail_2.svg create mode 100644 js/src/assets/undraw_profile.svg create mode 100644 js/src/components/Event/EventListViewCard.vue create mode 100644 js/src/components/Participation/ConfirmParticipation.vue create mode 100644 js/src/components/Participation/ParticipationWithAccount.vue create mode 100644 js/src/components/Participation/ParticipationWithoutAccount.vue create mode 100644 js/src/components/Participation/UnloggedParticipation.vue create mode 100644 js/src/components/Utils/VerticalDivider.vue create mode 100644 js/src/services/AnonymousParticipationStorage.ts create mode 100644 js/src/views/Admin/Settings.vue create mode 100644 js/src/views/Interact.vue create mode 100644 js/src/views/Terms.vue create mode 100644 lib/graphql/resolvers/participant.ex create mode 100644 lib/mobilizon/admin/setting.ex create mode 100644 lib/web/templates/api/terms.html.eex create mode 100644 lib/web/templates/email/anonymous_participation_confirmation.html.eex create mode 100644 lib/web/templates/email/anonymous_participation_confirmation.text.eex create mode 100644 lib/web/views/api_view.ex create mode 100644 priv/gettext/be/LC_MESSAGES/errors.po create mode 100644 priv/gettext/ca/LC_MESSAGES/errors.po create mode 100644 priv/gettext/fi/LC_MESSAGES/errors.po create mode 100644 priv/repo/migrations/20191219172017_add_metadata_to_participant.exs create mode 100644 priv/repo/migrations/20191223173537_add_not_confirmed_status_to_participants.exs create mode 100644 priv/repo/migrations/20200116095117_create_admin_settings.exs create mode 100644 test/support/helpers.ex diff --git a/config/config.exs b/config/config.exs index a6a947e74..f12d6dc61 100644 --- a/config/config.exs +++ b/config/config.exs @@ -156,6 +156,28 @@ config :mobilizon, :maps, attribution: System.get_env("MAPS_TILES_ATTRIBUTION") ] +config :mobilizon, :anonymous, + participation: [ + allowed: true, + validation: %{ + email: [ + enabled: true, + confirmation_required: true + ], + captcha: [enabled: false] + } + ], + event_creation: [ + allowed: false, + validation: %{ + email: [ + enabled: true, + confirmation_required: true + ], + captcha: [enabled: false] + } + ] + config :mobilizon, Oban, repo: Mobilizon.Storage.Repo, prune: {:maxlen, 10_000}, diff --git a/config/dev.exs b/config/dev.exs index 32883da93..c52310e73 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -73,3 +73,5 @@ config :mobilizon, Mobilizon.Storage.Repo, port: System.get_env("MOBILIZON_DATABASE_PORT") || "5432", pool_size: 10, show_sensitive_data_on_connection_error: true + +config :mobilizon, :activitypub, sign_object_fetches: false diff --git a/config/test.exs b/config/test.exs index c3f70f21d..5049ce143 100644 --- a/config/test.exs +++ b/config/test.exs @@ -18,7 +18,9 @@ config :mobilizon, Mobilizon.Web.Endpoint, # Print only warnings and errors during test config :logger, backends: [:console], - compile_time_purge_level: :debug, + compile_time_purge_matching: [ + [level_lower_than: :debug] + ], level: :info # Configure your database diff --git a/js/package.json b/js/package.json index 4398dc80c..4c1dcac4f 100644 --- a/js/package.json +++ b/js/package.json @@ -28,6 +28,7 @@ "apollo-link-ws": "^1.0.19", "apollo-utilities": "^1.3.2", "buefy": "^0.8.2", + "bulma-divider": "^0.2.0", "graphql": "^14.5.8", "graphql-tag": "^2.10.1", "intersection-observer": "^0.7.0", diff --git a/js/src/App.vue b/js/src/App.vue index 93586999c..7a9c6a16b 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -85,6 +85,7 @@ export default class App extends Vue { /* Bulma imports */ @import "~bulma/bulma"; +@import '~bulma-divider'; /* Buefy imports */ @import "~buefy/src/scss/buefy"; @@ -102,12 +103,12 @@ $mdi-font-path: "~@mdi/font/fonts"; body { // background: #f7f8fa; - background: #ebebeb; + background: $body-background-color; font-family: BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Fira Sans','Droid Sans','Helvetica Neue',Helvetica,Arial,sans-serif; - main { - margin: 1rem auto 0; - } + /*main {*/ + /* margin: 1rem auto 0;*/ + /*}*/ } #mobilizon > .container > .message { diff --git a/js/src/assets/undraw_mail_2.svg b/js/src/assets/undraw_mail_2.svg new file mode 100644 index 000000000..08bd4b415 --- /dev/null +++ b/js/src/assets/undraw_mail_2.svg @@ -0,0 +1 @@ +mail_2 \ No newline at end of file diff --git a/js/src/assets/undraw_profile.svg b/js/src/assets/undraw_profile.svg new file mode 100644 index 000000000..b0eca7b30 --- /dev/null +++ b/js/src/assets/undraw_profile.svg @@ -0,0 +1 @@ +profile \ No newline at end of file diff --git a/js/src/components/Event/AddressAutoComplete.vue b/js/src/components/Event/AddressAutoComplete.vue index fdb5d3304..fd6a85718 100644 --- a/js/src/components/Event/AddressAutoComplete.vue +++ b/js/src/components/Event/AddressAutoComplete.vue @@ -1,5 +1,5 @@