-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🛂 (billing) Add isPastDue field in workspace (#1046)
Closes #1039 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Workspaces now include additional status indicator: `isPastDue`. - New pages for handling workspaces that are past due. Meaning, an invoice is unpaid. - **Bug Fixes** - Fixed issues with workspace status checks and redirections for suspended workspaces. - **Refactor** - Refactored workspace-related API functions to accommodate new status fields. - Improved permission checks for reading and writing typebots based on workspace status. - **Chores** - Database schema updated to include `isPastDue` field for workspaces. - Implemented new webhook event handling for subscription and invoice updates. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
94886ca
commit ca79934
Showing
27 changed files
with
450 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 18 additions & 19 deletions
37
apps/builder/src/features/typebot/helpers/isReadTypebotForbidden.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
import prisma from '@typebot.io/lib/prisma' | ||
import { env } from '@typebot.io/env' | ||
import { CollaboratorsOnTypebots, User } from '@typebot.io/prisma' | ||
import { Typebot } from '@typebot.io/schemas' | ||
import { | ||
CollaboratorsOnTypebots, | ||
User, | ||
Workspace, | ||
MemberInWorkspace, | ||
} from '@typebot.io/prisma' | ||
|
||
export const isReadTypebotForbidden = async ( | ||
typebot: Pick<Typebot, 'workspaceId'> & { | ||
typebot: { | ||
collaborators: Pick<CollaboratorsOnTypebots, 'userId'>[] | ||
} & { | ||
workspace: Pick<Workspace, 'isQuarantined' | 'isPastDue'> & { | ||
members: Pick<MemberInWorkspace, 'userId'>[] | ||
} | ||
}, | ||
user: Pick<User, 'email' | 'id'> | ||
) => { | ||
if ( | ||
env.ADMIN_EMAIL === user.email || | ||
typebot.collaborators.find( | ||
) => | ||
typebot.workspace.isQuarantined || | ||
typebot.workspace.isPastDue || | ||
(env.ADMIN_EMAIL !== user.email && | ||
!typebot.collaborators.some( | ||
(collaborator) => collaborator.userId === user.id | ||
) | ||
) | ||
return false | ||
const memberInWorkspace = await prisma.memberInWorkspace.findFirst({ | ||
where: { | ||
workspaceId: typebot.workspaceId, | ||
userId: user.id, | ||
}, | ||
}) | ||
return memberInWorkspace === null | ||
} | ||
) && | ||
!typebot.workspace.members.some((member) => member.userId === user.id)) |
34 changes: 18 additions & 16 deletions
34
apps/builder/src/features/typebot/helpers/isWriteTypebotForbidden.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import prisma from '@typebot.io/lib/prisma' | ||
import { | ||
CollaborationType, | ||
CollaboratorsOnTypebots, | ||
MemberInWorkspace, | ||
User, | ||
Workspace, | ||
} from '@typebot.io/prisma' | ||
import { Typebot } from '@typebot.io/schemas' | ||
import { isNotDefined } from '@typebot.io/lib' | ||
|
||
export const isWriteTypebotForbidden = async ( | ||
typebot: Pick<Typebot, 'workspaceId'> & { | ||
typebot: { | ||
collaborators: Pick<CollaboratorsOnTypebots, 'userId' | 'type'>[] | ||
} & { | ||
workspace: Pick<Workspace, 'isQuarantined' | 'isPastDue'> & { | ||
members: Pick<MemberInWorkspace, 'userId' | 'role'>[] | ||
} | ||
}, | ||
user: Pick<User, 'id'> | ||
) => { | ||
if ( | ||
typebot.collaborators.find( | ||
(collaborator) => collaborator.userId === user.id | ||
)?.type === CollaborationType.WRITE | ||
return ( | ||
typebot.workspace.isQuarantined || | ||
typebot.workspace.isPastDue || | ||
!( | ||
typebot.collaborators.find( | ||
(collaborator) => collaborator.userId === user.id | ||
)?.type === CollaborationType.WRITE && | ||
typebot.workspace.members.some( | ||
(m) => m.userId === user.id && m.role !== 'GUEST' | ||
) | ||
) | ||
) | ||
return false | ||
const memberInWorkspace = await prisma.memberInWorkspace.findFirst({ | ||
where: { | ||
workspaceId: typebot.workspaceId, | ||
userId: user.id, | ||
}, | ||
}) | ||
return isNotDefined(memberInWorkspace) || memberInWorkspace.role === 'GUEST' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ca79934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
builder-v2 – ./apps/builder
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
ca79934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./apps/docs
docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io
ca79934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
landing-page-v2 – ./apps/landing-page
www.typebot.io
landing-page-v2-git-main-typebot-io.vercel.app
landing-page-v2-typebot-io.vercel.app
www.get-typebot.com
get-typebot.com
home.typebot.io
ca79934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viewer-v2 – ./apps/viewer
ai.meant.com
alphamen.pro
bet7k.online
bot.afric.ai
bot.grace.bj
bot.tobb.pro
chatgov.site
cinecorn.com
ezbooking.ai
gniorder.com
help.taxt.co
kusamint.com
p18bm940.fun
psmix.online
receita.info
rhino.cr8.ai
sheep.cr8.ai
snake.cr8.ai
svhm.mprs.in
tiger.cr8.ai
video.cr8.ai
webwhats.fun
webwhats.pro
whatsapp.web
yoda.riku.ai
zebra.cr8.ai
1nkagency.com
akademicq.com
alvodelas.com
atendente.org
bemestar.club
bot.goafk.com
bot.krdfy.com
cat.hidden.sg
cgcassets.com
chat.linky.li
cnvhub.com.br
drapamela.com
facelabko.com
filmylogy.com
gikpro.online
goldorayo.com
headsbet.info
majie.move.sg
payforbet.com
rabbit.cr8.ai
saquegov.site
shop.mexwa.my
signup.cr8.ai
start.taxt.co
cares.urlabout.me
chat.ezbooking.ai
chat.gaswadern.de
chat.gniorder.com
chat.leadmagic.io
chat.onrentme.com
chat.rojie.online
chatdocidadao.com
chatwebonline.com
consultanutri.com
dividaquitada.com
viewer-v2-typebot-io.vercel.app
mdb.assessoria.fernanda.progenbr.com
mdb.assessoria.jbatista.progenbr.com
mdb.assessoria.mauricio.progenbr.com
mdb.evento.autocadastro.progenbr.com
form.shopmercedesbenzsouthorlando.com
mdb.evento.equipeinterna.progenbr.com
bot.studiotecnicoimmobiliaremerelli.it
mdb.assessoria.boaventura.progenbr.com
mdb.assessoria.jtrebesqui.progenbr.com
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
mdb.assessoria.carreirinha.progenbr.com
chrome-os-inquiry-system.itschromeos.com
mdb.assessoria.paulomarques.progenbr.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com
mdb.assessoria.qrcode.ademir.progenbr.com
mdb.assessoria.qrcode.arthur.progenbr.com
mdb.assessoria.qrcode.danilo.progenbr.com
mdb.assessoria.qrcode.marcao.progenbr.com
mdb.assessoria.qrcode.marcio.progenbr.com
mdb.assessoria.qrcode.aloisio.progenbr.com
mdb.assessoria.qrcode.girotto.progenbr.com
mdb.assessoria.qrcode.marinho.progenbr.com
mdb.assessoria.qrcode.rodrigo.progenbr.com
mdb.assessoria.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.desideri.progenbr.com
mdb.assessoria.qrcode.fernanda.progenbr.com
mdb.assessoria.qrcode.jbatista.progenbr.com
mdb.assessoria.qrcode.mauricio.progenbr.com
mdb.assessoria.fernanda.regional.progenbr.com
mdb.assessoria.qrcode.boaventura.progenbr.com
mdb.assessoria.qrcode.jtrebesqui.progenbr.com
mdb.assessoria.qrcode.carreirinha.progenbr.com
mdb.assessoria.qrcode.paulomarques.progenbr.com
mdb.assessoria.qrcode.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.fernanda.regional.progenbr.com