From c4b997bc5248900fba36e239394e2ca44f5fd4bf Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 5 Feb 2021 14:45:39 +0100 Subject: [PATCH] Fix accessing group event unlogged Signed-off-by: Thomas Citharel --- js/src/components/Comment/Comment.vue | 8 +++----- js/src/components/Comment/CommentTree.vue | 10 ++++------ js/src/views/Event/Edit.vue | 16 +++++++--------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/js/src/components/Comment/Comment.vue b/js/src/components/Comment/Comment.vue index 8040a2c8b..8d86dc9b6 100644 --- a/js/src/components/Comment/Comment.vue +++ b/js/src/components/Comment/Comment.vue @@ -296,11 +296,9 @@ export default class Comment extends Vue { } get commentFromOrganizer(): boolean { - return ( - this.event.organizerActor !== undefined && - this.comment.actor != null && - this.comment.actor.id === this.event.organizerActor.id - ); + const organizerId = + this.event?.organizerActor?.id || this.event?.attributedTo?.id; + return organizerId !== undefined && this.comment?.actor?.id === organizerId; } get commentId(): string { diff --git a/js/src/components/Comment/CommentTree.vue b/js/src/components/Comment/CommentTree.vue index 10c5bbc44..363f517a8 100644 --- a/js/src/components/Comment/CommentTree.vue +++ b/js/src/components/Comment/CommentTree.vue @@ -320,11 +320,9 @@ export default class CommentTree extends Vue { } get isEventOrganiser(): boolean { - return ( - this.currentActor.id !== undefined && - this.event.organizerActor !== undefined && - this.currentActor.id === this.event.organizerActor.id - ); + const organizerId = + this.event?.organizerActor?.id || this.event?.attributedTo?.id; + return organizerId !== undefined && this.currentActor?.id === organizerId; } get areCommentsClosed(): boolean { @@ -335,7 +333,7 @@ export default class CommentTree extends Vue { } get isAbleToComment(): boolean { - if (this.currentActor && this.currentActor.id) { + if (this.currentActor?.id) { return this.areCommentsClosed || this.isEventOrganiser; } return false; diff --git a/js/src/views/Event/Edit.vue b/js/src/views/Event/Edit.vue index 86304b3de..e88e2f946 100644 --- a/js/src/views/Event/Edit.vue +++ b/js/src/views/Event/Edit.vue @@ -579,7 +579,7 @@ export default class EditEvent extends Vue { } private getDefaultActor() { - if (this.event.organizerActor && this.event.organizerActor.id) { + if (this.event.organizerActor?.id) { return this.event.organizerActor; } return this.currentActor; @@ -725,7 +725,7 @@ export default class EditEvent extends Vue { get isCurrentActorOrganizer(): boolean { return !( this.eventId && - this.event.organizerActor && + this.event.organizerActor?.id !== undefined && this.currentActor.id !== this.event.organizerActor.id ) as boolean; } @@ -822,19 +822,17 @@ export default class EditEvent extends Vue { } get attributedToEqualToOrganizerActor(): boolean { - return (this.event.organizerActor && - this.event.attributedTo && - this.event.attributedTo.id === this.event.organizerActor.id) as boolean; + return (this.event.organizerActor?.id !== undefined && + this.event.attributedTo?.id === this.event.organizerActor?.id) as boolean; } /** * Build variables for Event GraphQL creation query */ private async buildVariables() { - this.event.organizerActor = - this.event.organizerActor && this.event.organizerActor.id - ? this.event.organizerActor - : this.currentActor; + this.event.organizerActor = this.event.organizerActor?.id + ? this.event.organizerActor + : this.currentActor; let res = this.event.toEditJSON(); if (this.event.organizerActor) { res = Object.assign(res, {