File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,3 +74,25 @@ export async function getAccountCount(): Promise<number> {
7474 return 0 ;
7575 }
7676}
77+
78+ export async function getClientIds ( ) : Promise < Map < string , boolean > > {
79+ try {
80+ const accounts = await prisma . account . findMany ( {
81+ select : {
82+ clientId : true ,
83+ isRoot : true ,
84+ } ,
85+ } ) ;
86+
87+ const clientIds = new Map < string , boolean > ( ) ;
88+ accounts . forEach ( ( account ) => {
89+ clientIds . set ( account . clientId , account . isRoot ) ;
90+ } ) ;
91+
92+ return clientIds ;
93+ } catch ( error ) {
94+ Sentry . captureException ( error ) ;
95+ log . error ( "Database" , "Failed to get client IDs." , error ) ;
96+ return new Map < string , boolean > ( ) ;
97+ }
98+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import {
1616 PHISHTANK_AUTO_UPDATE ,
1717 PROJECT_THRESHOLD_MEMORY ,
1818} from "./config" ;
19- import { getRootAccount } from "./components/services/account" ;
19+ import { getClientIds , getRootAccount } from "./components/services/account" ;
2020
2121const monitor = new MemoryMonitor ( {
2222 interval : 60000 ,
@@ -39,8 +39,13 @@ async function main() {
3939 ] ) ;
4040
4141 phishingSet = phishtank . getPhishingSet ( ) ;
42- const rootClientId = await getRootAccount ( ) ;
43- await addAccount ( rootClientId , undefined , true ) ;
42+
43+ const accountsIds = await getClientIds ( ) ;
44+ await Promise . all (
45+ Array . from ( accountsIds . entries ( ) ) . map ( async ( [ clientId , isRoot ] ) => {
46+ await addAccount ( clientId , undefined , isRoot ) ;
47+ } ) ,
48+ ) ;
4449
4550 await mapCommands ( ) ;
4651 // Watch for changes
You can’t perform that action at this time.
0 commit comments