commitCreated
This commit is contained in:
@@ -11,28 +11,12 @@ const { Roles } = require('@speckle/shared')
|
||||
*/
|
||||
|
||||
// subscription events
|
||||
const COMMIT_CREATED = CommitPubsubEvents.CommitCreated
|
||||
const COMMIT_UPDATED = CommitPubsubEvents.CommitUpdated
|
||||
const COMMIT_DELETED = CommitPubsubEvents.CommitDeleted
|
||||
|
||||
/** @type {import('@/modules/core/graph/generated/graphql').Resolvers} */
|
||||
module.exports = {
|
||||
Subscription: {
|
||||
commitCreated: {
|
||||
subscribe: withFilter(
|
||||
() => pubsub.asyncIterator([COMMIT_CREATED]),
|
||||
async (payload, variables, context) => {
|
||||
await authorizeResolver(
|
||||
context.userId,
|
||||
payload.streamId,
|
||||
Roles.Stream.Reviewer,
|
||||
context.resourceAccessRules
|
||||
)
|
||||
return payload.streamId === variables.streamId
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
commitUpdated: {
|
||||
subscribe: withFilter(
|
||||
() => pubsub.asyncIterator([COMMIT_UPDATED]),
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { CommitNotFoundError } from '@/modules/core/errors/commit'
|
||||
import { publish } from '@/modules/shared/utils/subscriptions'
|
||||
import {
|
||||
CommitSubscriptions,
|
||||
filteredSubscribe,
|
||||
publish
|
||||
} from '@/modules/shared/utils/subscriptions'
|
||||
import { authorizeResolver } from '@/modules/shared'
|
||||
|
||||
import {
|
||||
@@ -381,5 +385,21 @@ export = {
|
||||
await batchDeleteCommits(args.input, ctx.userId!)
|
||||
return true
|
||||
}
|
||||
},
|
||||
Subscription: {
|
||||
commitCreated: {
|
||||
subscribe: filteredSubscribe(
|
||||
CommitSubscriptions.CommitCreated,
|
||||
async (payload, variables, context) => {
|
||||
await authorizeResolver(
|
||||
context.userId,
|
||||
payload.streamId,
|
||||
Roles.Stream.Reviewer,
|
||||
context.resourceAccessRules
|
||||
)
|
||||
return payload.streamId === variables.streamId
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
} as Resolvers
|
||||
|
||||
@@ -39,7 +39,9 @@ import {
|
||||
StreamUpdateInput,
|
||||
ProjectUpdateInput,
|
||||
SubscriptionStreamUpdatedArgs,
|
||||
SubscriptionStreamDeletedArgs
|
||||
SubscriptionStreamDeletedArgs,
|
||||
SubscriptionCommitCreatedArgs,
|
||||
CommitCreateInput
|
||||
} from '@/modules/core/graph/generated/graphql'
|
||||
import { Merge } from 'type-fest'
|
||||
import {
|
||||
@@ -301,6 +303,13 @@ type SubscriptionTypeMap = {
|
||||
payload: { streamDeleted: { streamId: string }; streamId: string }
|
||||
variables: SubscriptionStreamDeletedArgs
|
||||
}
|
||||
[CommitSubscriptions.CommitCreated]: {
|
||||
payload: {
|
||||
commitCreated: CommitCreateInput & { id: string; authorId: string }
|
||||
streamId: string
|
||||
}
|
||||
variables: SubscriptionCommitCreatedArgs
|
||||
}
|
||||
} & { [k in SubscriptionEvent]: { payload: unknown; variables: unknown } }
|
||||
|
||||
type SubscriptionEvent =
|
||||
|
||||
Reference in New Issue
Block a user