[draft] Pricing/fixes (#10424)

* Fix qa core suite

* Update package.json

* Lint

* Handle conflict on account metadata

* Fix issue adding users via csv import when on paid plan

* Fix user invites

* Lint
This commit is contained in:
Rory Powell 2023-04-27 08:25:53 +01:00 committed by GitHub
parent 34b0a1fa2d
commit 972e2257b7
4 changed files with 22 additions and 9 deletions

View File

@ -25,7 +25,7 @@
$: invalidEmails = [] $: invalidEmails = []
$: userCount = $licensing.userCount + userEmails.length $: userCount = $licensing.userCount + userEmails.length
$: willExceed = userCount > $licensing.userLimit $: willExceed = licensing.willExceedUserLimit(userCount)
$: importDisabled = $: importDisabled =
!userEmails.length || !validEmails(userEmails) || !usersRole || willExceed !userEmails.length || !validEmails(userEmails) || !usersRole || willExceed

View File

@ -114,11 +114,13 @@ export function createUsersStore() {
const getUserRole = ({ admin, builder }) => const getUserRole = ({ admin, builder }) =>
admin?.global ? "admin" : builder?.global ? "developer" : "appUser" admin?.global ? "admin" : builder?.global ? "developer" : "appUser"
const refreshUsage = fn => async args => { const refreshUsage =
const response = await fn(args) fn =>
await licensing.setQuotaUsage() async (...args) => {
return response const response = await fn(...args)
} await licensing.setQuotaUsage()
return response
}
return { return {
subscribe, subscribe,
@ -133,7 +135,7 @@ export function createUsersStore() {
updateInvite, updateInvite,
getUserCountByApp, getUserCountByApp,
// any operation that adds or deletes users // any operation that adds or deletes users
acceptInvite: refreshUsage(acceptInvite), acceptInvite,
create: refreshUsage(create), create: refreshUsage(create),
save: refreshUsage(save), save: refreshUsage(save),
bulkDelete: refreshUsage(bulkDelete), bulkDelete: refreshUsage(bulkDelete),

View File

@ -424,7 +424,9 @@ export const inviteAccept = async (
if (err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) { if (err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) {
// explicitly re-throw limit exceeded errors // explicitly re-throw limit exceeded errors
ctx.throw(400, err) ctx.throw(400, err)
return
} }
console.warn("Error inviting user", err)
ctx.throw(400, "Unable to create new user, invitation invalid.") ctx.throw(400, "Unable to create new user, invitation invalid.")
} }
} }

View File

@ -18,8 +18,17 @@ export const saveMetadata = async (
if (existing) { if (existing) {
metadata._rev = existing._rev metadata._rev = existing._rev
} }
const res = await db.put(metadata) try {
metadata._rev = res.rev const res = await db.put(metadata)
metadata._rev = res.rev
} catch (e: any) {
// account can be updated frequently
// ignore 409
if (e.status !== 409) {
throw e
}
}
return metadata return metadata
}) })
} }