Improve GraphQL documentation and cleanup API

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-11-19 17:06:28 +01:00
parent e8a3b6aa94
commit 3eacbb2ca3
87 changed files with 6542 additions and 6314 deletions

View File

@@ -70,7 +70,6 @@ export default class CreateDiscussion extends Vue {
title: this.discussion.title,
text: this.discussion.text,
actorId: parseInt(this.group.id, 10),
creatorId: parseInt(this.currentActor.id, 10),
},
});

View File

@@ -761,7 +761,7 @@ export default class Event extends EventMixin {
* Delete the event, then redirect to home.
*/
async openDeleteEventModalWrapper(): Promise<void> {
await this.openDeleteEventModal(this.event, this.currentActor);
await this.openDeleteEventModal(this.event);
}
async reportEvent(content: string, forward: boolean): Promise<void> {
@@ -771,19 +771,12 @@ export default class Event extends EventMixin {
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,
reportedId: this.actorForReport ? this.actorForReport.id : null,
content,
forward,
@@ -808,7 +801,6 @@ export default class Event extends EventMixin {
mutation: JOIN_EVENT,
variables: {
eventId: this.event.id,
actorId: identity.id,
message,
},
update: (store, { data }) => {

View File

@@ -214,7 +214,6 @@ const MESSAGE_ELLIPSIS_LENGTH = 130;
page: 1,
limit: PARTICIPANTS_PER_PAGE,
roles: this.roles,
actorId: this.currentActor.id,
};
},
skip() {
@@ -298,7 +297,6 @@ export default class Participants extends Vue {
mutation: UPDATE_PARTICIPANT,
variables: {
id: participant.id,
moderatorActorId: this.currentActor.id,
role: ParticipantRole.PARTICIPANT,
},
});
@@ -313,7 +311,6 @@ export default class Participants extends Vue {
mutation: UPDATE_PARTICIPANT,
variables: {
id: participant.id,
moderatorActorId: this.currentActor.id,
role: ParticipantRole.REJECTED,
},
});

View File

@@ -178,15 +178,10 @@ export default class CreateGroup extends mixins(IdentityEditionMixin) {
};
}
const currentActor = {
creatorActorId: this.currentActor.id,
};
return {
...this.group,
...avatarObj,
...bannerObj,
...currentActor,
};
}

View File

@@ -481,18 +481,10 @@ export default class Group extends mixins(GroupMixin) {
// @ts-ignore
this.$refs.reportModal.close();
const groupTitle = this.group.name || usernameWithDomain(this.group);
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: {
reporterId,
reportedId: this.group.id,
content,
forward,

View File

@@ -303,7 +303,6 @@ export default class Report extends Vue {
mutation: CREATE_REPORT_NOTE,
variables: {
reportId: this.report.id,
moderatorId: this.currentActor.id,
content: this.noteContent,
},
update: (store, { data }) => {
@@ -372,7 +371,6 @@ export default class Report extends Vue {
mutation: DELETE_EVENT,
variables: {
eventId: this.report.event.id.toString(),
actorId: this.currentActor.id,
},
});
@@ -395,7 +393,6 @@ export default class Report extends Vue {
mutation: DELETE_COMMENT,
variables: {
commentId: comment.id,
actorId: this.currentActor.id,
},
});
this.$notifier.success(this.$t("Comment deleted") as string);
@@ -410,7 +407,6 @@ export default class Report extends Vue {
mutation: UPDATE_REPORT,
variables: {
reportId: this.report.id,
moderatorId: this.currentActor.id,
status,
},
update: (store, { data }) => {

View File

@@ -30,11 +30,11 @@ export default class Validate extends Vue {
failed = false;
async created() {
async created(): Promise<void> {
await this.validateAction();
}
async validateAction() {
async validateAction(): Promise<void> {
try {
await this.$apollo.mutate<{ validateEmail: ICurrentUser }>({
mutation: VALIDATE_EMAIL,
@@ -43,11 +43,10 @@ export default class Validate extends Vue {
},
});
this.loading = false;
return await this.$router.push({ name: RouteName.HOME });
await this.$router.push({ name: RouteName.HOME });
} catch (err) {
console.error(err);
this.failed = true;
return undefined;
}
}
}