Add config option to allow anonymous reporting
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -62,7 +62,7 @@ export const COMMENTS_THREADS = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
${COMMENT_RECURSIVE_FRAGMENT}
|
||||
${COMMENT_FIELDS_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const CREATE_COMMENT_FROM_EVENT = gql`
|
||||
|
||||
@@ -34,6 +34,9 @@ export const CONFIG = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
reports {
|
||||
allowed
|
||||
}
|
||||
actorId
|
||||
}
|
||||
location {
|
||||
|
||||
@@ -39,6 +39,9 @@ export interface IConfig {
|
||||
};
|
||||
};
|
||||
};
|
||||
reports: {
|
||||
allowed: boolean;
|
||||
};
|
||||
actorId: string;
|
||||
};
|
||||
maps: {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user