diff --git a/graphql-schemas/plus.js b/graphql-schemas/plus.js index ebf05d2be..700567e17 100644 --- a/graphql-schemas/plus.js +++ b/graphql-schemas/plus.js @@ -395,6 +395,25 @@ const resolvers = { "Suggested user is already a member of the server." ) + const date = new Date() + const month = date.getMonth() + 1 + const year = date.getFullYear() + + const kickedSummary = await Summary.findOne({ + discord_id: args.discord_id, + plus_server: args.server, + suggested: { $in: [null, false] }, + month, + year, + score: { $lt: 0 }, + }) + + if (kickedSummary) { + throw new UserInputError( + "Can't suggest because user got kicked less than month ago." + ) + } + if (ctx.user.plus.membership_status !== "ONE" && args.server === "ONE") throw new UserInputError("Can't suggest to +1 without being +1 member.") @@ -464,6 +483,25 @@ const resolvers = { ) throw new UserInputError("User already has access.") + const date = new Date() + const month = date.getMonth() + 1 + const year = date.getFullYear() + + const kickedSummary = await Summary.findOne({ + discord_id: args.discord_id, + plus_server: args.server, + suggested: { $in: [null, false] }, + month, + year, + score: { $lt: 0 }, + }) + + if (kickedSummary) { + throw new UserInputError( + "Can't vouch because user got kicked less than month ago." + ) + } + if (!user.plus) user.plus = {} user.plus.vouch_status = args.server user.plus.voucher_discord_id = ctx.user.discord_id