File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1669,6 +1669,22 @@ export const getSearchContexts = async (domain: string) => sew(() =>
16691669 } , /* minRequiredRole = */ OrgRole . GUEST ) , /* allowAnonymousAccess = */ true
16701670 ) ) ;
16711671
1672+ export const clearSearchContexts = async ( domain : string ) => sew ( ( ) =>
1673+ withAuth ( ( userId ) =>
1674+ withOrgMembership ( userId , domain , async ( { org } ) => {
1675+ await prisma . searchContext . deleteMany ( {
1676+ where : {
1677+ orgId : org . id ,
1678+ } ,
1679+ } ) ;
1680+
1681+ return {
1682+ success : true ,
1683+ } ;
1684+ } , /* minRequiredRole = */ OrgRole . OWNER )
1685+ )
1686+ )
1687+
16721688export const getRepoImage = async ( repoId : number ) : Promise < ArrayBuffer | ServiceError > => sew ( async ( ) => {
16731689 return await withOptionalAuthV2 ( async ( { org, prisma } ) => {
16741690 const repo = await prisma . repo . findUnique ( {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { getOrgFromDomain } from './data/org';
77import { SINGLE_TENANT_ORG_DOMAIN , SINGLE_TENANT_ORG_ID , SOURCEBOT_GUEST_USER_ID } from './lib/constants' ;
88import { ServiceErrorException } from './lib/serviceError' ;
99import { getOrgMetadata , isServiceError } from './lib/utils' ;
10+ import { clearSearchContexts , getSearchContexts } from './actions' ;
1011
1112const logger = createLogger ( 'web-initialize' ) ;
1213
@@ -62,6 +63,16 @@ const initSingleTenancy = async () => {
6263 }
6364 }
6465
66+ // If we don't have the search context entitlement then wipe any existing
67+ // search contexts that may be present in the DB
68+ const hasSearchContextEntitlement = hasEntitlement ( "search-contexts" )
69+ if ( ! hasSearchContextEntitlement ) {
70+ const searchContexts = await getSearchContexts ( SINGLE_TENANT_ORG_DOMAIN ) ;
71+ if ( ! isServiceError ( searchContexts ) && searchContexts . length > 0 ) {
72+ clearSearchContexts ( SINGLE_TENANT_ORG_DOMAIN )
73+ }
74+ }
75+
6576 // Sync anonymous access config from the config file
6677 const config = await loadConfig ( env . CONFIG_PATH ) ;
6778 const forceEnableAnonymousAccess = config . settings ?. enablePublicAccess ?? env . FORCE_ENABLE_ANONYMOUS_ACCESS === 'true' ;
You can’t perform that action at this time.
0 commit comments