From 03434071b42b32a84d29503d709d4c920d1e9108 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 4 Oct 2022 05:44:11 +0200 Subject: [PATCH] fix cypher to have signup verification to block posts of groups for new users --- backend/src/db/graphql/authentications.js | 1 + backend/src/schema/resolvers/registration.js | 21 +++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/backend/src/db/graphql/authentications.js b/backend/src/db/graphql/authentications.js index f05970650..91605ec9f 100644 --- a/backend/src/db/graphql/authentications.js +++ b/backend/src/db/graphql/authentications.js @@ -19,6 +19,7 @@ export const signupVerificationMutation = gql` nonce: $nonce termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion ) { + id slug } } diff --git a/backend/src/schema/resolvers/registration.js b/backend/src/schema/resolvers/registration.js index ea420bc2a..52c92b033 100644 --- a/backend/src/schema/resolvers/registration.js +++ b/backend/src/schema/resolvers/registration.js @@ -72,19 +72,19 @@ const signupCypher = (inviteCode) => { (inviteCode:InviteCode {code: $inviteCode})<-[:GENERATED]-(host:User) ` optionalMerge = ` - MERGE(user)-[:REDEEMED { createdAt: toString(datetime()) }]->(inviteCode) - MERGE(host)-[:INVITED { createdAt: toString(datetime()) }]->(user) - MERGE(user)-[:FOLLOWS { createdAt: toString(datetime()) }]->(host) - MERGE(host)-[:FOLLOWS { createdAt: toString(datetime()) }]->(user) + MERGE (user)-[:REDEEMED { createdAt: toString(datetime()) }]->(inviteCode) + MERGE (host)-[:INVITED { createdAt: toString(datetime()) }]->(user) + MERGE (user)-[:FOLLOWS { createdAt: toString(datetime()) }]->(host) + MERGE (host)-[:FOLLOWS { createdAt: toString(datetime()) }]->(user) ` } const cypher = ` - MATCH(email:EmailAddress {nonce: $nonce, email: $email}) + MATCH (email:EmailAddress {nonce: $nonce, email: $email}) WHERE NOT (email)-[:BELONGS_TO]->() ${optionalMatch} CREATE (user:User) - MERGE(user)-[:PRIMARY_EMAIL]->(email) - MERGE(user)<-[:BELONGS_TO]-(email) + MERGE (user)-[:PRIMARY_EMAIL]->(email) + MERGE (user)<-[:BELONGS_TO]-(email) ${optionalMerge} SET user += $args SET user.id = randomUUID() @@ -95,6 +95,13 @@ const signupCypher = (inviteCode) => { SET user.showShoutsPublicly = false SET user.sendNotificationEmails = true SET email.verifiedAt = toString(datetime()) + WITH user + OPTIONAL MATCH (post:Post)-[:IN]->(group:Group) + WHERE NOT group.groupType = 'public' + WITH user, collect(post) AS invisiblePosts + FOREACH (invisiblePost IN invisiblePosts | + MERGE (user)-[:CANNOT_SEE]->(invisiblePost) + ) RETURN user {.*} ` return cypher