@@ -10,6 +10,7 @@ import type {
1010 ValidationResult ,
1111 SmtpConfig ,
1212 GitHubOAuthConfig ,
13+ GlobalConfig ,
1314 InitializationResult
1415} from './types' ;
1516
@@ -397,6 +398,54 @@ export class GlobalSettingsInitService {
397398 const config = await this . getGitHubOAuthConfiguration ( ) ;
398399 return config !== null ;
399400 }
401+
402+ /**
403+ * Get complete Global configuration
404+ */
405+ static async getGlobalConfiguration ( ) : Promise < GlobalConfig | null > {
406+ try {
407+ const settings = await Promise . all ( [
408+ GlobalSettingsService . get ( 'global.page_url' ) ,
409+ GlobalSettingsService . get ( 'global.send_mail' )
410+ ] ) ;
411+
412+ const [ pageUrl , sendMail ] = settings ;
413+
414+ return {
415+ pageUrl : pageUrl ?. value || 'http://localhost:5173' ,
416+ sendMail : sendMail ?. value === 'true'
417+ } ;
418+ } catch ( error ) {
419+ console . error ( 'Failed to get Global configuration:' , error ) ;
420+ return null ;
421+ }
422+ }
423+
424+ /**
425+ * Check if email sending is enabled
426+ */
427+ static async isEmailSendingEnabled ( ) : Promise < boolean > {
428+ try {
429+ const setting = await GlobalSettingsService . get ( 'global.send_mail' ) ;
430+ return setting ?. value === 'true' ;
431+ } catch ( error ) {
432+ console . error ( 'Failed to check if email sending is enabled:' , error ) ;
433+ return false ; // Default to disabled if there's an error
434+ }
435+ }
436+
437+ /**
438+ * Get the application page URL
439+ */
440+ static async getPageUrl ( ) : Promise < string > {
441+ try {
442+ const setting = await GlobalSettingsService . get ( 'global.page_url' ) ;
443+ return setting ?. value || 'http://localhost:5173' ;
444+ } catch ( error ) {
445+ console . error ( 'Failed to get page URL:' , error ) ;
446+ return 'http://localhost:5173' ; // Default fallback
447+ }
448+ }
400449}
401450
402451// Export the helper class
@@ -409,5 +458,6 @@ export type {
409458 ValidationResult ,
410459 SmtpConfig ,
411460 GitHubOAuthConfig ,
461+ GlobalConfig ,
412462 InitializationResult
413463} ;
0 commit comments