1
0
Fork 0
mirror of synced 2024-09-28 23:31:43 +12:00

[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 = []
$: userCount = $licensing.userCount + userEmails.length
$: willExceed = userCount > $licensing.userLimit
$: willExceed = licensing.willExceedUserLimit(userCount)
$: importDisabled =
!userEmails.length || !validEmails(userEmails) || !usersRole || willExceed

View file

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

View file

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

View file

@ -18,8 +18,17 @@ export const saveMetadata = async (
if (existing) {
metadata._rev = existing._rev
}
const res = await db.put(metadata)
metadata._rev = res.rev
try {
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
})
}