Skip to content

Commit

Permalink
fix(groups): DO Binding (#2469)
Browse files Browse the repository at this point in the history
* fix(groups): DO Binding

* Added unique filtering on identity group result

* Added some comments in stripe webhook
  • Loading branch information
Cosmin-Parvulescu authored Jul 11, 2023
1 parent 9266977 commit 8165f54
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions apps/console/app/routes/__layout/gnillib/webhook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export const action: ActionFunction = getRollupReqFunctionErrorWrapper(
}
}

// If previous attributes had a handled flag and the current
// event does not, then the webhook is handling only the
// handled removal so we shouldn't move further
if (
!subMeta.handled &&
metadata?.handled &&
Expand All @@ -84,6 +87,10 @@ export const action: ActionFunction = getRollupReqFunctionErrorWrapper(
}
}

// When synchronously handling subscription update effects
// a flag is set to prevent the webhook from handling it again
// when it is received asynchronously
// This call clears the flag
if (subMeta.handled) {
console.info(
`Subscription ${id} - ${event.type} already handled synchronously`
Expand Down
2 changes: 1 addition & 1 deletion platform/account/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { appRouter } from './jsonrpc/router'
import type { Environment } from './types'

export { default as Account } from './nodes/account'
export { default as IdentityGroup } from './nodes/account'
export { default as IdentityGroup } from './nodes/identity-group'

export default {
async fetch(request: Request, env: Environment): Promise<Response> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@ export const listIdentityGroups = async ({
(result) => result.edges
)

const uniqueIdentityGroupEdges = [
...new Set(identityGroupEdges.map((edge) => edge.dst.baseUrn)),
]
.map((baseUrn) =>
identityGroupEdges.find((edge) => edge.dst.baseUrn === baseUrn)
)
.filter((edge) => edge != null)

const identityGroups: ListIdentityGroupsOutput = await Promise.all(
identityGroupEdges.map(async (edge) => {
const URN = edge.dst.baseUrn as IdentityGroupURN
const name = edge.dst.qc.name
uniqueIdentityGroupEdges.map(async (edge) => {
const URN = edge!.dst.baseUrn as IdentityGroupURN
const name = edge!.dst.qc.name

const { edges: groupMemberEdges } = await ctx.edges.getEdges.query({
query: {
Expand Down

0 comments on commit 8165f54

Please sign in to comment.