From 57f0b5dad1f3dacd42cb7697d0d8398f96070415 Mon Sep 17 00:00:00 2001 From: Thomas Citharel <tcit@tcit.fr> Date: Sun, 13 Oct 2019 10:51:22 +0200 Subject: [PATCH] Participation fixes Closes #208 and #210 Signed-off-by: Thomas Citharel <tcit@tcit.fr> --- js/src/views/Event/Event.vue | 21 +++++++++++++++++++-- lib/service/activity_pub/activity_pub.ex | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue index 5228ff83c..0ae8b6eba 100644 --- a/js/src/views/Event/Event.vue +++ b/js/src/views/Event/Event.vue @@ -1,3 +1,4 @@ +import {ParticipantRole} from "@/types/event.model"; <template> <div class="container"> <b-loading :active.sync="$apollo.loading"></b-loading> @@ -350,7 +351,7 @@ export default class Event extends EventMixin { async joinEvent(identity: IPerson) { this.isJoinModalActive = false; try { - await this.$apollo.mutate<{ joinEvent: IParticipant }>({ + const { data } = await this.$apollo.mutate<{ joinEvent: IParticipant }>({ mutation: JOIN_EVENT, variables: { eventId: this.event.id, @@ -393,6 +394,14 @@ export default class Event extends EventMixin { store.writeQuery({ query: FETCH_EVENT, variables: { uuid: this.uuid }, data: { event } }); }, }); + if (data) { + this.$buefy.notification.open({ + message: (data.joinEvent.role === ParticipantRole.NOT_APPROVED ? this.$t('Your participation has been requested') : this.$t('Your participation has been confirmed')) as string, + type: 'is-success', + position: 'is-bottom-right', + duration: 5000, + }); + } } catch (error) { console.error(error); } @@ -412,7 +421,7 @@ export default class Event extends EventMixin { async leaveEvent() { try { - await this.$apollo.mutate<{ leaveEvent: IParticipant }>({ + const { data } = await this.$apollo.mutate<{ leaveEvent: IParticipant }>({ mutation: LEAVE_EVENT, variables: { eventId: this.event.id, @@ -454,6 +463,14 @@ export default class Event extends EventMixin { store.writeQuery({ query: FETCH_EVENT, variables: { uuid: this.uuid }, data: { event } }); }, }); + if (data) { + this.$buefy.notification.open({ + message: this.$t('You have cancelled your participation') as string, + type: 'is-success', + position: 'is-bottom-right', + duration: 5000, + }); + } } catch (error) { console.error(error); } diff --git a/lib/service/activity_pub/activity_pub.ex b/lib/service/activity_pub/activity_pub.ex index f3de44b05..181807b82 100644 --- a/lib/service/activity_pub/activity_pub.ex +++ b/lib/service/activity_pub/activity_pub.ex @@ -414,10 +414,10 @@ defmodule Mobilizon.Service.ActivityPub do def join(%Event{options: options} = event, %Actor{} = actor, local) do # TODO Refactor me for federation with maximum_attendee_capacity <- - Map.get(options, :maximum_attendee_capacity, 2_000_000) || false, + Map.get(options, :maximum_attendee_capacity) || 0, {:maximum_attendee_capacity, true} <- {:maximum_attendee_capacity, - !maximum_attendee_capacity || + maximum_attendee_capacity == 0 || Mobilizon.Events.count_participant_participants(event.id) < maximum_attendee_capacity}, role <- Mobilizon.Events.get_default_participant_role(event),