feat(webhook): ⚡️ Show linked typebots results in webhook sample
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
import { CollaborationType, Prisma, User } from 'db'
|
||||
|
||||
const parseWhereFilter = (
|
||||
typebotId: string,
|
||||
typebotIds: string[] | string,
|
||||
user: User,
|
||||
type: 'read' | 'write'
|
||||
): Prisma.TypebotWhereInput => ({
|
||||
OR: [
|
||||
{
|
||||
id: typebotId,
|
||||
id: typeof typebotIds === 'string' ? typebotIds : { in: typebotIds },
|
||||
ownerId:
|
||||
(type === 'read' && user.email === process.env.ADMIN_EMAIL) ||
|
||||
process.env.NEXT_PUBLIC_E2E_TEST
|
||||
@ -15,7 +15,7 @@ const parseWhereFilter = (
|
||||
: user.id,
|
||||
},
|
||||
{
|
||||
id: typebotId,
|
||||
id: typeof typebotIds === 'string' ? typebotIds : { in: typebotIds },
|
||||
collaborators: {
|
||||
some: {
|
||||
userId: user.id,
|
||||
@ -31,3 +31,9 @@ export const canReadTypebot = (typebotId: string, user: User) =>
|
||||
|
||||
export const canWriteTypebot = (typebotId: string, user: User) =>
|
||||
parseWhereFilter(typebotId, user, 'write')
|
||||
|
||||
export const canReadTypebots = (typebotIds: string[], user: User) =>
|
||||
parseWhereFilter(typebotIds, user, 'read')
|
||||
|
||||
export const canWriteTypebots = (typebotIds: string[], user: User) =>
|
||||
parseWhereFilter(typebotIds, user, 'write')
|
||||
|
Reference in New Issue
Block a user