Improve GraphQL documentation and cleanup API
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -288,7 +288,6 @@ export default class Comment extends Vue {
|
||||
mutation: CREATE_REPORT,
|
||||
variables: {
|
||||
eventId: this.event.id,
|
||||
reporterId: this.currentActor.id,
|
||||
reportedId: this.comment.actor.id,
|
||||
commentsIds: [this.comment.id],
|
||||
content,
|
||||
|
||||
@@ -112,7 +112,6 @@ export default class CommentTree extends Vue {
|
||||
mutation: CREATE_COMMENT_FROM_EVENT,
|
||||
variables: {
|
||||
eventId: this.event.id,
|
||||
actorId: comment.actor.id,
|
||||
text: comment.text,
|
||||
inReplyToCommentId: comment.inReplyToComment ? comment.inReplyToComment.id : null,
|
||||
},
|
||||
@@ -204,7 +203,6 @@ export default class CommentTree extends Vue {
|
||||
mutation: DELETE_COMMENT,
|
||||
variables: {
|
||||
commentId: comment.id,
|
||||
actorId: this.currentActor.id,
|
||||
},
|
||||
update: (store, { data }) => {
|
||||
if (data == null) return;
|
||||
|
||||
@@ -530,7 +530,6 @@ export default class EditorComponent extends Vue {
|
||||
variables: {
|
||||
file: image,
|
||||
name: image.name,
|
||||
actorId: this.currentActor.id,
|
||||
},
|
||||
});
|
||||
if (data.uploadPicture && data.uploadPicture.url) {
|
||||
|
||||
@@ -88,15 +88,12 @@ export default class Image extends Node {
|
||||
});
|
||||
if (!coordinates) return false;
|
||||
const client = apolloProvider.defaultClient as ApolloClient<NormalizedCacheObject>;
|
||||
const editorElem = document.getElementById("tiptab-editor");
|
||||
const actorId = editorElem && editorElem.dataset.actorId;
|
||||
|
||||
try {
|
||||
images.forEach(async (image) => {
|
||||
const { data } = await client.mutate({
|
||||
mutation: UPLOAD_PICTURE,
|
||||
variables: {
|
||||
actorId,
|
||||
file: image,
|
||||
name: image.name,
|
||||
},
|
||||
|
||||
@@ -246,7 +246,7 @@ export default class EventListCard extends mixins(ActorMixin, EventMixin) {
|
||||
async openDeleteEventModalWrapper(): Promise<void> {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
await this.openDeleteEventModal(this.participation.event, this.currentActor);
|
||||
await this.openDeleteEventModal(this.participation.event);
|
||||
}
|
||||
|
||||
async gotToWithCheck(participation: IParticipant, route: RawLocation): Promise<Route> {
|
||||
|
||||
@@ -127,7 +127,6 @@ export default class ParticipationWithoutAccount extends Vue {
|
||||
mutation: JOIN_EVENT,
|
||||
variables: {
|
||||
eventId: this.event.id,
|
||||
actorId: this.config.anonymous.actorId,
|
||||
email: this.anonymousParticipation.email,
|
||||
message: this.anonymousParticipation.message,
|
||||
locale: this.$i18n.locale,
|
||||
|
||||
@@ -68,18 +68,8 @@ export const COMMENTS_THREADS = gql`
|
||||
`;
|
||||
|
||||
export const CREATE_COMMENT_FROM_EVENT = gql`
|
||||
mutation CreateCommentFromEvent(
|
||||
$eventId: ID!
|
||||
$actorId: ID!
|
||||
$text: String!
|
||||
$inReplyToCommentId: ID
|
||||
) {
|
||||
createComment(
|
||||
eventId: $eventId
|
||||
actorId: $actorId
|
||||
text: $text
|
||||
inReplyToCommentId: $inReplyToCommentId
|
||||
) {
|
||||
mutation CreateCommentFromEvent($eventId: ID!, $text: String!, $inReplyToCommentId: ID) {
|
||||
createComment(eventId: $eventId, text: $text, inReplyToCommentId: $inReplyToCommentId) {
|
||||
...CommentRecursive
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ export const DISCUSSION_FIELDS_FRAGMENT = gql`
|
||||
`;
|
||||
|
||||
export const CREATE_DISCUSSION = gql`
|
||||
mutation createDiscussion($title: String!, $creatorId: ID!, $actorId: ID!, $text: String!) {
|
||||
createDiscussion(title: $title, text: $text, creatorId: $creatorId, actorId: $actorId) {
|
||||
mutation createDiscussion($title: String!, $actorId: ID!, $text: String!) {
|
||||
createDiscussion(title: $title, text: $text, actorId: $actorId) {
|
||||
...DiscussionFields
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,8 +498,8 @@ export const CONFIRM_PARTICIPATION = gql`
|
||||
`;
|
||||
|
||||
export const UPDATE_PARTICIPANT = gql`
|
||||
mutation AcceptParticipant($id: ID!, $moderatorActorId: ID!, $role: ParticipantRoleEnum!) {
|
||||
updateParticipation(id: $id, moderatorActorId: $moderatorActorId, role: $role) {
|
||||
mutation UpdateParticipant($id: ID!, $role: ParticipantRoleEnum!) {
|
||||
updateParticipation(id: $id, role: $role) {
|
||||
role
|
||||
id
|
||||
}
|
||||
@@ -507,20 +507,20 @@ export const UPDATE_PARTICIPANT = gql`
|
||||
`;
|
||||
|
||||
export const DELETE_EVENT = gql`
|
||||
mutation DeleteEvent($eventId: ID!, $actorId: ID!) {
|
||||
deleteEvent(eventId: $eventId, actorId: $actorId) {
|
||||
mutation DeleteEvent($eventId: ID!) {
|
||||
deleteEvent(eventId: $eventId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const PARTICIPANTS = gql`
|
||||
query($uuid: UUID!, $page: Int, $limit: Int, $roles: String, $actorId: ID!) {
|
||||
query($uuid: UUID!, $page: Int, $limit: Int, $roles: String) {
|
||||
event(uuid: $uuid) {
|
||||
id,
|
||||
uuid,
|
||||
title,
|
||||
participants(page: $page, limit: $limit, roles: $roles, actorId: $actorId) {
|
||||
participants(page: $page, limit: $limit, roles: $roles) {
|
||||
${participantsQuery}
|
||||
},
|
||||
participantStats {
|
||||
|
||||
@@ -223,7 +223,6 @@ export const GET_GROUP = gql`
|
||||
|
||||
export const CREATE_GROUP = gql`
|
||||
mutation CreateGroup(
|
||||
$creatorActorId: ID!
|
||||
$preferredUsername: String!
|
||||
$name: String!
|
||||
$summary: String
|
||||
@@ -231,7 +230,6 @@ export const CREATE_GROUP = gql`
|
||||
$banner: PictureInput
|
||||
) {
|
||||
createGroup(
|
||||
creatorActorId: $creatorActorId
|
||||
preferredUsername: $preferredUsername
|
||||
name: $name
|
||||
summary: $summary
|
||||
|
||||
@@ -121,7 +121,6 @@ export const REPORT = gql`
|
||||
export const CREATE_REPORT = gql`
|
||||
mutation CreateReport(
|
||||
$eventId: ID
|
||||
$reporterId: ID!
|
||||
$reportedId: ID!
|
||||
$content: String
|
||||
$commentsIds: [ID]
|
||||
@@ -129,7 +128,6 @@ export const CREATE_REPORT = gql`
|
||||
) {
|
||||
createReport(
|
||||
eventId: $eventId
|
||||
reporterId: $reporterId
|
||||
reportedId: $reportedId
|
||||
content: $content
|
||||
commentsIds: $commentsIds
|
||||
@@ -141,8 +139,8 @@ export const CREATE_REPORT = gql`
|
||||
`;
|
||||
|
||||
export const UPDATE_REPORT = gql`
|
||||
mutation UpdateReport($reportId: ID!, $moderatorId: ID!, $status: ReportStatus!) {
|
||||
updateReportStatus(reportId: $reportId, moderatorId: $moderatorId, status: $status) {
|
||||
mutation UpdateReport($reportId: ID!, $status: ReportStatus!) {
|
||||
updateReportStatus(reportId: $reportId, status: $status) {
|
||||
...ReportFragment
|
||||
}
|
||||
}
|
||||
@@ -150,8 +148,8 @@ export const UPDATE_REPORT = gql`
|
||||
`;
|
||||
|
||||
export const CREATE_REPORT_NOTE = gql`
|
||||
mutation CreateReportNote($reportId: ID!, $moderatorId: ID!, $content: String!) {
|
||||
createReportNote(reportId: $reportId, moderatorId: $moderatorId, content: $content) {
|
||||
mutation CreateReportNote($reportId: ID!, $content: String!) {
|
||||
createReportNote(reportId: $reportId, content: $content) {
|
||||
id
|
||||
content
|
||||
insertedAt
|
||||
|
||||
@@ -2,8 +2,8 @@ import gql from "graphql-tag";
|
||||
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
export const UPLOAD_PICTURE = gql`
|
||||
mutation UploadPicture($file: Upload!, $alt: String, $name: String!, $actorId: ID!) {
|
||||
uploadPicture(file: $file, alt: $alt, name: $name, actorId: $actorId) {
|
||||
mutation UploadPicture($file: Upload!, $alt: String, $name: String!) {
|
||||
uploadPicture(file: $file, alt: $alt, name: $name) {
|
||||
url
|
||||
id
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ export default class EventMixin extends mixins(Vue) {
|
||||
this.$notifier.success(this.$t("You have cancelled your participation") as string);
|
||||
}
|
||||
|
||||
protected async openDeleteEventModal(event: IEvent, currentActor: IPerson): Promise<void> {
|
||||
protected async openDeleteEventModal(event: IEvent): Promise<void> {
|
||||
function escapeRegExp(string: string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
||||
}
|
||||
@@ -115,11 +115,11 @@ export default class EventMixin extends mixins(Vue) {
|
||||
placeholder: event.title,
|
||||
pattern: escapeRegExp(event.title),
|
||||
},
|
||||
onConfirm: () => this.deleteEvent(event, currentActor),
|
||||
onConfirm: () => this.deleteEvent(event),
|
||||
});
|
||||
}
|
||||
|
||||
private async deleteEvent(event: IEvent, currentActor: IPerson) {
|
||||
private async deleteEvent(event: IEvent) {
|
||||
const eventTitle = event.title;
|
||||
|
||||
try {
|
||||
@@ -127,7 +127,6 @@ export default class EventMixin extends mixins(Vue) {
|
||||
mutation: DELETE_EVENT,
|
||||
variables: {
|
||||
eventId: event.id,
|
||||
actorId: currentActor.id,
|
||||
},
|
||||
});
|
||||
/**
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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 }) => {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -178,15 +178,10 @@ export default class CreateGroup extends mixins(IdentityEditionMixin) {
|
||||
};
|
||||
}
|
||||
|
||||
const currentActor = {
|
||||
creatorActorId: this.currentActor.id,
|
||||
};
|
||||
|
||||
return {
|
||||
...this.group,
|
||||
...avatarObj,
|
||||
...bannerObj,
|
||||
...currentActor,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }) => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user