MCPcopy Index your code
hub / github.com/simstudioai/sim / blockOrgMembers

Function blockOrgMembers

apps/sim/lib/billing/organizations/membership.ts:90–116  ·  view source on GitHub ↗
(
  organizationId: string,
  reason: BillingBlockReason
)

Source from the content-addressed store, hash-verified

88 * A payment_failed block won't overwrite an existing dispute block
89 */
90export async function blockOrgMembers(
91 organizationId: string,
92 reason: BillingBlockReason
93): Promise<number> {
94 const memberIds = await getOrgMemberIds(organizationId)
95
96 if (memberIds.length === 0) {
97 return 0
98 }
99
100 // Don't overwrite dispute blocks with payment_failed (dispute is higher priority)
101 const whereClause =
102 reason === 'payment_failed'
103 ? and(
104 inArray(userStats.userId, memberIds),
105 or(ne(userStats.billingBlockedReason, 'dispute'), isNull(userStats.billingBlockedReason))
106 )
107 : inArray(userStats.userId, memberIds)
108
109 const result = await db
110 .update(userStats)
111 .set({ billingBlocked: true, billingBlockedReason: reason })
112 .where(whereClause)
113 .returning({ userId: userStats.userId })
114
115 return result.length
116}
117
118/**
119 * Unblock all members of an organization blocked for a specific reason

Callers 2

handleChargeDisputeFunction · 0.90

Calls 2

getOrgMemberIdsFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected