commitUpdated
This commit is contained in:
@@ -11,33 +11,11 @@ const { Roles } = require('@speckle/shared')
|
||||
*/
|
||||
|
||||
// subscription events
|
||||
const COMMIT_UPDATED = CommitPubsubEvents.CommitUpdated
|
||||
const COMMIT_DELETED = CommitPubsubEvents.CommitDeleted
|
||||
|
||||
/** @type {import('@/modules/core/graph/generated/graphql').Resolvers} */
|
||||
module.exports = {
|
||||
Subscription: {
|
||||
commitUpdated: {
|
||||
subscribe: withFilter(
|
||||
() => pubsub.asyncIterator([COMMIT_UPDATED]),
|
||||
async (payload, variables, context) => {
|
||||
await authorizeResolver(
|
||||
context.userId,
|
||||
payload.streamId,
|
||||
Roles.Stream.Reviewer,
|
||||
context.resourceAccessRules
|
||||
)
|
||||
|
||||
const streamMatch = payload.streamId === variables.streamId
|
||||
if (streamMatch && variables.commitId) {
|
||||
return payload.commitId === variables.commitId
|
||||
}
|
||||
|
||||
return streamMatch
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
commitDeleted: {
|
||||
subscribe: withFilter(
|
||||
() => pubsub.asyncIterator([COMMIT_DELETED]),
|
||||
|
||||
@@ -401,5 +401,25 @@ export = {
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
commitUpdated: {
|
||||
subscribe: filteredSubscribe(
|
||||
CommitSubscriptions.CommitUpdated,
|
||||
async (payload, variables, context) => {
|
||||
await authorizeResolver(
|
||||
context.userId,
|
||||
payload.streamId,
|
||||
Roles.Stream.Reviewer,
|
||||
context.resourceAccessRules
|
||||
)
|
||||
|
||||
const streamMatch = payload.streamId === variables.streamId
|
||||
if (streamMatch && variables.commitId) {
|
||||
return payload.commitId === variables.commitId
|
||||
}
|
||||
|
||||
return streamMatch
|
||||
}
|
||||
)
|
||||
}
|
||||
} as Resolvers
|
||||
|
||||
@@ -41,7 +41,9 @@ import {
|
||||
SubscriptionStreamUpdatedArgs,
|
||||
SubscriptionStreamDeletedArgs,
|
||||
SubscriptionCommitCreatedArgs,
|
||||
CommitCreateInput
|
||||
CommitCreateInput,
|
||||
SubscriptionCommitUpdatedArgs,
|
||||
CommitUpdateInput
|
||||
} from '@/modules/core/graph/generated/graphql'
|
||||
import { Merge } from 'type-fest'
|
||||
import {
|
||||
@@ -310,6 +312,10 @@ type SubscriptionTypeMap = {
|
||||
}
|
||||
variables: SubscriptionCommitCreatedArgs
|
||||
}
|
||||
[CommitSubscriptions.CommitUpdated]: {
|
||||
payload: { commitUpdated: CommitUpdateInput; streamId: string; commitId: string }
|
||||
variables: SubscriptionCommitUpdatedArgs
|
||||
}
|
||||
} & { [k in SubscriptionEvent]: { payload: unknown; variables: unknown } }
|
||||
|
||||
type SubscriptionEvent =
|
||||
|
||||
Reference in New Issue
Block a user