Skip to content

Commit

Permalink
branchDeleted
Browse files Browse the repository at this point in the history
fabis94 committed Oct 25, 2024
1 parent 64d2888 commit f690f10
Showing 4 changed files with 24 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ActionTypes, ResourceTypes } from '@/modules/activitystream/helpers/types'
import {
pubsub,
BranchSubscriptions as BranchPubsubEvents,
PublishSubscription
} from '@/modules/shared/utils/subscriptions'
@@ -113,7 +112,7 @@ export const addBranchDeletedActivityFactory =
info: { branch: { ...input, name: branchName } },
message: `Branch deleted: '${branchName}' (${input.id})`
}),
pubsub.publish(BranchPubsubEvents.BranchDeleted, {
publish(BranchPubsubEvents.BranchDeleted, {
branchDeleted: input,
streamId
}),
35 changes: 0 additions & 35 deletions packages/server/modules/core/graph/resolvers/branches.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -173,6 +173,21 @@ export = {
return streamMatch
}
)
},
branchDeleted: {
subscribe: filteredSubscribe(
BranchPubsubEvents.BranchDeleted,
async (payload, variables, context) => {
await authorizeResolver(
context.userId,
payload.streamId,
Roles.Stream.Reviewer,
context.resourceAccessRules
)

return payload.streamId === variables.streamId
}
)
}
}
} as Resolvers
9 changes: 8 additions & 1 deletion packages/server/modules/shared/utils/subscriptions.ts
Original file line number Diff line number Diff line change
@@ -43,7 +43,10 @@ import {
SubscriptionBranchCreatedArgs,
SubscriptionBranchUpdatedArgs,
BranchUpdateInput,
UpdateModelInput
UpdateModelInput,
SubscriptionBranchDeletedArgs,
BranchDeleteInput,
DeleteModelInput
} from '@/modules/core/graph/generated/graphql'
import { Merge } from 'type-fest'
import {
@@ -318,6 +321,10 @@ type SubscriptionTypeMap = {
}
variables: SubscriptionBranchUpdatedArgs
}
[BranchSubscriptions.BranchDeleted]: {
payload: { branchDeleted: BranchDeleteInput | DeleteModelInput; streamId: string }
variables: SubscriptionBranchDeletedArgs
}
} & { [k in SubscriptionEvent]: { payload: unknown; variables: unknown } }

type SubscriptionEvent =

0 comments on commit f690f10

Please sign in to comment.