mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Create users with default socialMedia, append url
- It was such that every time a user updates their social media it would replace the existing url with the one to be added. creating a user with a default empty array means that we can concatenate the url to the array and not have a complicated cypher query to account for an intial NULL value. Co-authored-by: Joseph Ngugi <jngugi88@gmail.com>
This commit is contained in:
parent
e409d6508f
commit
599f3814ba
@ -32,7 +32,7 @@ export default {
|
||||
const session = driver.session()
|
||||
const result = await session.run(
|
||||
'MATCH (user:User {email: $userEmail}) ' +
|
||||
'RETURN user {.id, .slug, .name, .avatar, .email, .password, .role, .disabled} as user LIMIT 1',
|
||||
'RETURN user {.id, .slug, .name, .avatar, .email, .password, .role, .disabled} as user LIMIT 1',
|
||||
{
|
||||
userEmail: email
|
||||
}
|
||||
@ -107,8 +107,9 @@ export default {
|
||||
const { email } = user
|
||||
const result = await session.run(
|
||||
`MATCH (user:User {email: $userEmail})
|
||||
SET user.socialMedia = [$url]
|
||||
RETURN user {.socialMedia}`,
|
||||
SET user.socialMedia = user.socialMedia + $url
|
||||
RETURN user {.socialMedia}
|
||||
`,
|
||||
{
|
||||
userEmail: email,
|
||||
url
|
||||
@ -118,7 +119,7 @@ export default {
|
||||
const [currentUser] = result.records.map(record => {
|
||||
return record.get('user')
|
||||
})
|
||||
return !!currentUser.socialMedia
|
||||
return currentUser.socialMedia
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ type Mutation {
|
||||
disable(id: ID!): ID
|
||||
enable(id: ID!): ID
|
||||
reward(fromBadgeId: ID!, toUserId: ID!): ID
|
||||
addSocialMedia(url: String!): Boolean!
|
||||
addSocialMedia(url: String!): [String]!
|
||||
unreward(fromBadgeId: ID!, toUserId: ID!): ID
|
||||
"Shout the given Type and ID"
|
||||
shout(id: ID!, type: ShoutTypeEnum): Boolean! @cypher(statement: """
|
||||
|
||||
@ -25,7 +25,8 @@ export default function create (params) {
|
||||
about: "${about}",
|
||||
role: ${role},
|
||||
disabled: ${disabled},
|
||||
deleted: ${deleted}
|
||||
deleted: ${deleted},
|
||||
socialMedia: []
|
||||
) {
|
||||
id
|
||||
name
|
||||
@ -34,6 +35,7 @@ export default function create (params) {
|
||||
role
|
||||
deleted
|
||||
disabled
|
||||
socialMedia
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user