|
|
@ -125,7 +125,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError || err.message;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
@ -156,11 +156,11 @@ export function resolver(req: any, res: any): any {
|
|
|
|
value: user.token(),
|
|
|
|
value: user.token(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
res.status(400);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(400);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return new GraphQLError("No email or password specified.");
|
|
|
|
return new GraphQLError("No email or password specified.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -178,7 +178,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError || err.message;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
@ -193,7 +193,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
await user.save();
|
|
|
|
await user.save();
|
|
|
|
return user.settings;
|
|
|
|
return user.settings;
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
res.status(400);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return new GraphQLError("Invalid settings json.");
|
|
|
|
return new GraphQLError("Invalid settings json.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -278,7 +278,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError || err.message;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
@ -291,7 +291,12 @@ export function resolver(req: any, res: any): any {
|
|
|
|
return new NotLoggedInGqlError();
|
|
|
|
return new NotLoggedInGqlError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (receiver && type) {
|
|
|
|
if (receiver && type) {
|
|
|
|
return await dataaccess.createRequest(req.session.userId, receiver, type);
|
|
|
|
try {
|
|
|
|
|
|
|
|
return await dataaccess.createRequest(req.session.userId, receiver, type);
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return new GraphQLError("No receiver or type given.");
|
|
|
|
return new GraphQLError("No receiver or type given.");
|
|
|
@ -325,7 +330,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.warn(err.message);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
globals.logger.debug(err.stack);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError || err.message;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
@ -346,7 +351,12 @@ export function resolver(req: any, res: any): any {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async createGroup({name, members}: { name: string, members: number[] }) {
|
|
|
|
async createGroup({name, members}: { name: string, members: number[] }) {
|
|
|
|
if (req.session.userId) {
|
|
|
|
if (req.session.userId) {
|
|
|
|
return await dataaccess.createGroup(name, req.session.userId, members);
|
|
|
|
try {
|
|
|
|
|
|
|
|
return await dataaccess.createGroup(name, req.session.userId, members);
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new NotLoggedInGqlError();
|
|
|
|
return new NotLoggedInGqlError();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -358,7 +368,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
.changeGroupMembership(id, req.session.userId, dataaccess.MembershipChangeAction.ADD);
|
|
|
|
.changeGroupMembership(id, req.session.userId, dataaccess.MembershipChangeAction.ADD);
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
@ -372,7 +382,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
.changeGroupMembership(id, req.session.userId, dataaccess.MembershipChangeAction.REMOVE);
|
|
|
|
.changeGroupMembership(id, req.session.userId, dataaccess.MembershipChangeAction.REMOVE);
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
@ -392,7 +402,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
.changeGroupMembership(groupId, userId, dataaccess.MembershipChangeAction.OP);
|
|
|
|
.changeGroupMembership(groupId, userId, dataaccess.MembershipChangeAction.OP);
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -417,7 +427,7 @@ export function resolver(req: any, res: any): any {
|
|
|
|
.changeGroupMembership(groupId, userId, dataaccess.MembershipChangeAction.DEOP);
|
|
|
|
.changeGroupMembership(groupId, userId, dataaccess.MembershipChangeAction.DEOP);
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError;
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
|