Add config option to allow anonymous reporting

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-06-09 14:07:49 +02:00
parent 2e64da11e3
commit dac47d2abb
14 changed files with 177 additions and 47 deletions

View File

@@ -62,7 +62,7 @@ export const COMMENTS_THREADS = gql`
}
}
}
${COMMENT_RECURSIVE_FRAGMENT}
${COMMENT_FIELDS_FRAGMENT}
`;
export const CREATE_COMMENT_FROM_EVENT = gql`

View File

@@ -34,6 +34,9 @@ export const CONFIG = gql`
}
}
}
reports {
allowed
}
actorId
}
location {

View File

@@ -39,6 +39,9 @@ export interface IConfig {
};
};
};
reports: {
allowed: boolean;
};
actorId: string;
};
maps: {

View File

@@ -272,7 +272,7 @@
<b-icon icon="calendar-plus" />
</span>
</b-dropdown-item>
<b-dropdown-item aria-role="listitem">
<b-dropdown-item aria-role="listitem" v-if="ableToReport">
<span @click="isReportModalActive = true">
{{ $t("Report") }}
<b-icon icon="flag" />
@@ -750,14 +750,25 @@ export default class Event extends EventMixin {
async reportEvent(content: string, forward: boolean) {
this.isReportModalActive = false;
// @ts-ignore
this.$refs.reportModal.close();
if (!this.event.organizerActor) return;
const eventTitle = this.event.title;
let reporterId = null;
if (this.currentActor.id) {
reporterId = this.currentActor.id;
} else {
if (this.config.anonymous.reports.allowed) {
reporterId = this.config.anonymous.actorId;
}
}
if (!reporterId) return;
try {
await this.$apollo.mutate<IReport>({
mutation: CREATE_REPORT,
variables: {
eventId: this.event.id,
reporterId: this.currentActor.id,
reporterId,
reportedId: this.event.organizerActor.id,
content,
forward,
@@ -996,6 +1007,12 @@ export default class Event extends EventMixin {
await removeAnonymousParticipation(this.uuid);
this.anonymousParticipation = null;
}
get ableToReport(): boolean {
return (
this.config && (this.currentActor.id != undefined || this.config.anonymous.reports.allowed)
);
}
}
</script>
<style lang="scss" scoped>

View File

@@ -154,7 +154,7 @@ import Subtitle from "../components/Utils/Subtitle.vue";
};
},
update: (data) =>
data.loggedUser.participations.map(
data.loggedUser.participations.elements.map(
(participation: IParticipant) => new Participant(participation)
),
skip() {