Skip to content

Commit e585a33

Browse files
committed
Migrate createRelationship calls to use currentUser global instead of session
1 parent 80fc72b commit e585a33

File tree

9 files changed

+22
-13
lines changed

9 files changed

+22
-13
lines changed

src/components/comments/comment-thread.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ACTIVE,
77
createNode,
88
createRelationships,
9+
currentUser,
910
merge,
1011
paginate,
1112
sorting,
@@ -30,7 +31,7 @@ export class CommentThreadRepository extends DtoRepository(CommentThread) {
3031
.apply(
3132
createRelationships(CommentThread, {
3233
in: { commentThread: ['BaseNode', parent] },
33-
out: { creator: ['User', session.userId] },
34+
out: { creator: currentUser },
3435
}),
3536
)
3637
.return('node as thread');

src/components/comments/comment.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ACTIVE,
99
createNode,
1010
createRelationships,
11+
currentUser,
1112
matchProps,
1213
merge,
1314
paginate,
@@ -50,7 +51,7 @@ export class CommentRepository extends DtoRepository(Comment) {
5051
.apply(
5152
createRelationships(Comment, {
5253
in: { comment: variable('thread') },
53-
out: { creator: ['User', session.userId] },
54+
out: { creator: currentUser },
5455
}),
5556
)
5657
.return<{ id: ID; threadId: ID }>([

src/components/file/file.repository.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
createNode,
2828
createProperty,
2929
createRelationships,
30+
currentUser,
3031
matchProps,
3132
merge,
3233
paginate,
@@ -379,7 +380,7 @@ export class FileRepository extends CommonRepository {
379380
.apply(await createNode(Directory, { initialProps }))
380381
.apply(
381382
createRelationships(Directory, 'out', {
382-
createdBy: ['User', session.userId],
383+
createdBy: currentUser,
383384
parent: ['Directory', parentId],
384385
}),
385386
)
@@ -417,7 +418,7 @@ export class FileRepository extends CommonRepository {
417418
.apply(
418419
createRelationships(Directory, {
419420
in: { [relation]: ['BaseNode', resource.id] },
420-
out: { createdBy: ['User', session.userId] },
421+
out: { createdBy: currentUser },
421422
}),
422423
)
423424
.return<{ id: ID }>('node.id as id');
@@ -458,7 +459,7 @@ export class FileRepository extends CommonRepository {
458459
.apply(
459460
createRelationships(File, {
460461
out: {
461-
createdBy: ['User', session.userId],
462+
createdBy: currentUser,
462463
parent: ['Directory', parentId],
463464
},
464465
in: {
@@ -501,7 +502,7 @@ export class FileRepository extends CommonRepository {
501502
)
502503
.apply(
503504
createRelationships(FileVersion, 'out', {
504-
createdBy: ['User', session.userId],
505+
createdBy: currentUser,
505506
parent: ['File', fileId],
506507
}),
507508
)

src/components/periodic-report/periodic-report.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
ACTIVE,
2424
createNode,
2525
createRelationships,
26+
currentUser,
2627
defineSorters,
2728
deleteBaseNode,
2829
filter,
@@ -161,7 +162,7 @@ export class PeriodicReportRepository extends DtoRepository<
161162
.apply(
162163
createRelationships(File, {
163164
in: { reportFileNode: variable('report') },
164-
out: { createdBy: ['User', input.session.userId] },
165+
out: { createdBy: currentUser },
165166
}),
166167
)
167168
.return<{ id: ID; interval: Range<CalendarDate> }>(

src/components/post/post.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ACTIVE,
99
createNode,
1010
createRelationships,
11+
currentUser,
1112
matchProps,
1213
merge,
1314
paginate,
@@ -37,7 +38,7 @@ export class PostRepository extends DtoRepository<typeof Post, [Session] | []>(
3738
post: ['BaseNode', input.parentId],
3839
},
3940
out: {
40-
creator: ['User', session.userId],
41+
creator: currentUser,
4142
},
4243
}),
4344
)

src/components/progress-report/media/progress-report-media.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ACTIVE,
1515
createNode,
1616
createRelationships,
17+
currentUser,
1718
deleteBaseNode,
1819
filter,
1920
matchProjectScopedRoles,
@@ -161,7 +162,7 @@ export class ProgressReportMediaRepository extends DtoRepository<
161162
)
162163
.apply(
163164
createRelationships(this.resource, 'out', {
164-
creator: ['User', session.userId],
165+
creator: currentUser,
165166
}),
166167
)
167168
.apply(

src/components/progress-report/workflow/progress-report-workflow.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ACTIVE,
1616
createNode,
1717
createRelationships,
18+
currentUser,
1819
merge,
1920
sorting,
2021
} from '~/core/database/query';
@@ -97,7 +98,7 @@ export class ProgressReportWorkflowRepository extends DtoRepository(
9798
.apply(
9899
createRelationships(WorkflowEvent, {
99100
in: { workflowEvent: ['ProgressReport', report] },
100-
out: { who: ['User', session.userId] },
101+
out: { who: currentUser },
101102
}),
102103
)
103104
.apply(this.hydrate())

src/components/project/workflow/project-workflow.neo4j.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ACTIVE,
1313
createNode,
1414
createRelationships,
15+
currentUser,
1516
INACTIVE,
1617
merge,
1718
sorting,
@@ -109,7 +110,7 @@ export class ProjectWorkflowNeo4jRepository
109110
.apply(
110111
createRelationships(WorkflowEvent, {
111112
in: { workflowEvent: ['Project', project] },
112-
out: { who: ['Actor', session.userId] },
113+
out: { who: currentUser },
113114
}),
114115
)
115116
.apply(this.hydrate())

src/components/prompts/prompt-variant-response.repository.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ACTIVE,
2121
createNode,
2222
createRelationships,
23+
currentUser,
2324
defaultPermanentAfter,
2425
merge,
2526
paginate,
@@ -163,7 +164,7 @@ export const PromptVariantResponseRepository = <
163164
child: ['BaseNode', input.resource],
164165
},
165166
out: {
166-
creator: ['User', session.userId],
167+
creator: currentUser,
167168
},
168169
}),
169170
)
@@ -222,7 +223,7 @@ export const PromptVariantResponseRepository = <
222223
child: variable('parent'),
223224
},
224225
out: {
225-
creator: ['User', session.userId],
226+
creator: currentUser,
226227
},
227228
}),
228229
)

0 commit comments

Comments
 (0)