Adding possibility to query for self
This commit is contained in:
1 parent
a9c8bdd652
commit
20831364ef
1 file changed
+3
-2
@@ -30,7 +30,7 @@ const resolve = (parent, {
|
||||
minEndDate,
|
||||
maxEndDate,
|
||||
}, { userId }) => {
|
||||
if (state === UNPUBLISHED && hostId !== userId) {
|
||||
if (state === UNPUBLISHED && hostId !== userId && hostId !== 'self') {
|
||||
throw new AuthentificationError('You cannot get unpublished events of other users.');
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ const resolve = (parent, {
|
||||
Event.find(
|
||||
Object.assign(
|
||||
state ? { state } : { state: { $nin: [UNPUBLISHED, ARCHIVED] } },
|
||||
hostId ? { hostId } : {},
|
||||
(hostId && hostId !== 'self') ? { hostId } : {},
|
||||
(hostId === 'self') ? { hostId: userId } : {},
|
||||
participantId ? { participants: { $elemMatch: { participantId } } } : {},
|
||||
inviteeId ? { invitations: { $elemMatch: { inviteeId } } } : {},
|
||||
minStartDate || maxStartDate
|
||||
|
||||
Reference in new issue
Block a user