@@ -74,36 +74,36 @@ async function ensureExists(tx, model, id, isAdmin = false) {
74
74
if ( model === 'Group' ) {
75
75
if ( validate ( id , 4 ) ) {
76
76
if ( ! isAdmin ) {
77
- res = await tx . run ( `MATCH (e:${ model } {id: {id}, status: '${ constants . GroupStatus . Active } '}) RETURN e` , {
78
- id
79
- } )
77
+ res = await tx . run ( `MATCH (e:${ model } {id: {id}, status: '${ constants . GroupStatus . Active } '}) RETURN e` , { id} )
80
78
} else {
81
- res = await tx . run ( `MATCH (e:${ model } {id: {id}}) RETURN e` , {
82
- id
83
- } )
79
+ res = await tx . run ( `MATCH (e:${ model } {id: {id}}) RETURN e` , { id} )
84
80
}
85
81
} else {
86
82
if ( ! isAdmin ) {
87
83
res = await tx . run ( `MATCH (e:${ model } {oldId: {id}, status: '${ constants . GroupStatus . Active } '}) RETURN e` , {
88
84
id
89
85
} )
90
86
} else {
91
- res = await tx . run ( `MATCH (e:${ model } {oldId: {id}}) RETURN e` , {
92
- id
93
- } )
87
+ res = await tx . run ( `MATCH (e:${ model } {oldId: {id}}) RETURN e` , { id} )
94
88
}
95
89
}
96
90
97
91
if ( res && res . records . length === 0 ) {
98
92
throw new errors . NotFoundError ( `Not found ${ model } of id ${ id } ` )
99
93
}
100
94
} else if ( model === 'User' ) {
101
- res = await tx . run ( `MATCH (e:${ model } {id: {id}}) RETURN e` , {
102
- id
103
- } )
95
+ if ( validate ( id , 4 ) ) {
96
+ res = await tx . run ( `MATCH (e:${ model } {universalUID: {id}}) RETURN e` , { id} )
104
97
105
- if ( res && res . records . length === 0 ) {
106
- res = await tx . run ( `CREATE (user:User {id: {id}}) RETURN user` , { id } )
98
+ if ( res && res . records . length === 0 ) {
99
+ res = await tx . run ( `CREATE (user:User {id: '00000000', universalUID: {id}}) RETURN user` , { id} )
100
+ }
101
+ } else {
102
+ res = await tx . run ( `MATCH (e:${ model } {id: {id}}) RETURN e` , { id} )
103
+
104
+ if ( res && res . records . length === 0 ) {
105
+ res = await tx . run ( `CREATE (user:User {id: {id}, universalUID: '00000000'}) RETURN user` , { id} )
106
+ }
107
107
}
108
108
}
109
109
@@ -123,7 +123,7 @@ async function ensureGroupMember(session, groupId, userId) {
123
123
try {
124
124
const memberCheckRes = await session . run (
125
125
'MATCH (g:Group {id: {groupId}})-[r:GroupContains {type: {membershipType}}]->(u:User {id: {userId}}) RETURN r' ,
126
- { groupId, membershipType : config . MEMBERSHIP_TYPES . User , userId }
126
+ { groupId, membershipType : config . MEMBERSHIP_TYPES . User , userId}
127
127
)
128
128
if ( memberCheckRes . records . length === 0 ) {
129
129
throw new errors . ForbiddenError ( `User is not member of the group` )
@@ -143,7 +143,7 @@ async function getChildGroups(session, groupId) {
143
143
try {
144
144
const res = await session . run (
145
145
'MATCH (g:Group {id: {groupId}})-[r:GroupContains]->(c:Group) RETURN c ORDER BY c.oldId' ,
146
- { groupId }
146
+ { groupId}
147
147
)
148
148
return _ . map ( res . records , ( record ) => record . get ( 0 ) . properties )
149
149
} catch ( error ) {
@@ -161,7 +161,7 @@ async function getParentGroups(session, groupId) {
161
161
try {
162
162
const res = await session . run (
163
163
'MATCH (g:Group)-[r:GroupContains]->(c:Group {id: {groupId}}) RETURN g ORDER BY g.oldId' ,
164
- { groupId }
164
+ { groupId}
165
165
)
166
166
return _ . map ( res . records , ( record ) => record . get ( 0 ) . properties )
167
167
} catch ( error ) {
@@ -176,7 +176,7 @@ async function getParentGroups(session, groupId) {
176
176
* @returns {String } link for the page
177
177
*/
178
178
function getPageLink ( req , page ) {
179
- const q = _ . assignIn ( { } , req . query , { page } )
179
+ const q = _ . assignIn ( { } , req . query , { page} )
180
180
return `${ req . protocol } ://${ req . get ( 'Host' ) } ${ req . baseUrl } ${ req . path } ?${ querystring . stringify ( q ) } `
181
181
}
182
182
0 commit comments