-
Notifications
You must be signed in to change notification settings - Fork 3k
Partner viewer role and program/link scoping for partner member #3676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devkiran
wants to merge
99
commits into
main
Choose a base branch
from
partner-viewer-role
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 85 commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
e1a1f49
Partner viewer role and program/link scoping for partner profile
devkiran 7fbf6a2
Delete get-scoped-link-ids.ts
devkiran a9a1fef
Updated routes to include assigned program IDs in message retrieval, …
devkiran 2f06b45
Refactor partner profile API routes to destructure assigned program I…
devkiran 4966fbc
Enforce partner role permissions on partner server actions
devkiran 980c110
Merge branch 'main' into partner-viewer-role
devkiran 98ef498
Add 'payouts.read' permission to partner profile payout routes
devkiran 4441542
Add missing partner permission checks for links, bounties, and referrals
devkiran 04e7bcb
Add payout_settings.read permission and scope earnings/customers by a…
devkiran c9817d0
Hide Payouts, Messages, Postbacks tabs from partner viewers
devkiran 9a6db09
Merge branch 'main' into partner-viewer-role
devkiran 12ea11e
Update footer
devkiran c2d6ca8
Partner profile members: programs column, schema, and per-user assign…
devkiran 43df416
Update route.ts
devkiran 14add7c
assign and unassign the program
devkiran 7281874
Update partner-member-programs-sheet.tsx
devkiran 480bd5c
Update route.ts
devkiran 200cc88
Update route.ts
devkiran 39fd5d6
Add link assignment route for partner user programs
devkiran 87684ec
Merge branch 'main' into partner-viewer-role
devkiran 9a172c4
Add programAccess field to PartnerUser with ProgramAccessScope enum
devkiran ad162e0
Add per-program link restrictions for partner users with restricted a…
devkiran 2c15629
Update upload-bounty-submission-file.ts
devkiran f798984
Update withdraw-partner-application.ts
devkiran e0d2728
Update partner-user-permissions.ts
devkiran 9d4fabe
Update partner.ts
devkiran e673234
Add program access handling and link restrictions for partner users
devkiran 1ce6fde
Enhance partner profile API to include assigned link filtering
devkiran 6b4698b
Extract linkScopeFilter and linkIncludeFilter helpers for assignedLin…
devkiran fe46afa
Update route.ts
devkiran 8a28d6c
missed a few spot
devkiran af779b3
Update route.ts
devkiran a898a60
Update partner.ts
devkiran d43d077
Format
devkiran f45837c
Merge branch 'main' into partner-viewer-role
devkiran 3d554c7
Update partner.ts
devkiran 3b60e7b
Merge branch 'main' into partner-viewer-role
devkiran 8b4be02
Refactor partner profile API routes to include additional conditions …
devkiran 4159f05
Update partner.ts
devkiran f1a8296
Update route.ts
devkiran cdf47a0
Merge branch 'main' into partner-viewer-role
devkiran de0c8f2
Update route.ts
devkiran b713410
Update route.ts
devkiran c3326d8
some cleanup
devkiran 3864ad2
Update route.ts
devkiran fd73d3d
Update get-earnings-for-partner.ts
devkiran b92bf4a
fix messages API
devkiran a147724
fix the earning filters
devkiran a96c405
Update route.ts
devkiran b88590b
Update route.ts
devkiran 5130081
Update route.ts
devkiran ba737c3
extract reusable throwIfNoProgramAccess and throwIfNoLinkAccess helpers
devkiran fc731dd
Update playwright.yaml
devkiran d38e7c6
Update route.ts
devkiran 1ae540e
Address CR comments
devkiran a9ff85b
Merge branch 'main' into partner-viewer-role
devkiran 58e4d93
Add "Edit programs" to member row menu and convert program access to …
devkiran 61d6947
Update route.ts
devkiran 3cd2983
Update reject-partner-application-modal.tsx
devkiran 3e095f1
Format
devkiran d02ed20
Sync the UI with Figma design
devkiran 76e3bd2
adjust the UI
devkiran 6d7f08c
Some cleanups
devkiran fc0b108
Update partner-member-programs-sheet.tsx
devkiran 5d9ed5f
Update partner-member-programs-sheet.tsx
devkiran ac6637f
Merge branch 'main' into partner-viewer-role
steven-tey c9db818
Add workspace-scoped dev seed fixtures and -w/--workspace flag
devkiran e9d993e
Update example-workspace.json
devkiran f6faabf
WIP adding tests
devkiran cd79d50
Update rbac.spec.ts
devkiran 6973ac1
Merge main into partner-viewer-role; resolve partner-profile payouts …
devkiran 2fc3303
Merge branch 'main' into partner-viewer-role
steven-tey 12fc9cb
Consolidate Playwright partner RBAC data into main seed script
devkiran 1c24dec
Add defaultPartnerId to auth options and update seed scripts for new IDs
devkiran 48f0a51
Update route.ts
devkiran 86fad7d
Refactor Playwright RBAC tests for partner roles, adding dynamic endp…
devkiran 1dd6ff1
Merge branch 'partner-viewer-role' of https://github.com/dubinc/dub i…
devkiran 40664d3
Skip partner signup test that conflicts with RBAC seed data
devkiran 16c7da8
Refactor partner RBAC tests and add link limits
devkiran 8d76bce
Add payouts/settings endpoint to RBAC test matrix
devkiran 342757b
Update global-setup.ts
devkiran ee2c4ed
Update rbac.spec.ts
devkiran b949614
Update global-setup.ts
devkiran e05f2e7
Update rbac.spec.ts
devkiran 013cdeb
Update rbac.spec.ts
devkiran 1daa8c5
fix the tests
devkiran f892451
fix tests one more time
devkiran eabef59
Update global-setup.ts
devkiran 47c6488
Update playwright.yaml
devkiran 3af5c9e
Update rbac.spec.ts
devkiran efa952d
Update playwright.yaml
devkiran d6a50ec
Refactor RBAC tests to restore commented-out endpoints and enhance on…
devkiran 97c0398
Update playwright.yaml
devkiran d2ce884
Merge branch 'main' into partner-viewer-role
devkiran 2805ece
Update Playwright config to refine test ignore pattern, exclude Playw…
devkiran 6a14bb5
Pass program and link scope objects through partner profile auth
devkiran 236f38f
Format
devkiran e9f5bc4
Update route.ts
devkiran 1da379c
Merge branch 'main' into partner-viewer-role
steven-tey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
47 changes: 27 additions & 20 deletions
47
apps/web/app/(ee)/api/partner-profile/messages/count/route.ts
This file contains hidden or 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,28 +1,35 @@ | ||
| import { withPartnerProfile } from "@/lib/auth/partner"; | ||
| import { programScopeFilter } from "@/lib/auth/partner-users/program-scope-filter"; | ||
| import { countMessagesQuerySchema } from "@/lib/zod/schemas/messages"; | ||
| import { prisma } from "@dub/prisma"; | ||
| import { NextResponse } from "next/server"; | ||
|
|
||
| // GET /api/partner-profile/messages/count - count messages for a partner | ||
| export const GET = withPartnerProfile(async ({ partner, searchParams }) => { | ||
| const { unread } = countMessagesQuerySchema.parse(searchParams); | ||
| export const GET = withPartnerProfile( | ||
| async ({ partner, searchParams, partnerUser: { assignedProgramIds } }) => { | ||
| const { unread } = countMessagesQuerySchema.parse(searchParams); | ||
|
|
||
| const count = await prisma.message.count({ | ||
| where: { | ||
| partnerId: partner.id, | ||
| ...(unread !== undefined && { | ||
| // Only count messages from the program | ||
| senderPartnerId: null, | ||
| readInApp: unread | ||
| ? // Only count unread messages | ||
| null | ||
| : { | ||
| // Only count read messages | ||
| not: null, | ||
| }, | ||
| }), | ||
| }, | ||
| }); | ||
| const count = await prisma.message.count({ | ||
| where: { | ||
| partnerId: partner.id, | ||
| ...(unread !== undefined && { | ||
| // Only count messages from the program | ||
| senderPartnerId: null, | ||
| readInApp: unread | ||
| ? // Only count unread messages | ||
| null | ||
| : { | ||
| // Only count read messages | ||
| not: null, | ||
| }, | ||
| }), | ||
| ...programScopeFilter(assignedProgramIds), | ||
| }, | ||
| }); | ||
|
|
||
| return NextResponse.json(count); | ||
| }); | ||
| return NextResponse.json(count); | ||
| }, | ||
| { | ||
| requiredPermission: "messages.read", | ||
| }, | ||
| ); | ||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.