Skip to content

Commit 6a97e06

Browse files
authored
Merge pull request #7 from VATSIM-UK/copilot/sub-pr-6
Fix Discord start notification missing webhook URL on import
2 parents 709cd6d + 92e4c05 commit 6a97e06

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

internal/cli/cli.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,14 @@ func importProcess(ctx context.Context, filePath string, cycle string, envPath s
223223
// Get the filename from the command line
224224
path, _ := filepath.Abs(filePath)
225225

226-
err := discord.SendDiscordNotification(discord.DiscordNotificationData{
226+
// Load the .env file before sending Discord notifications so the webhook URL is available
227+
err := godotenv.Overload(envPath)
228+
if err != nil {
229+
log.Error().Err(err).Msg("failed to load environment file")
230+
return ErrCannotLoadDotenv
231+
}
232+
233+
err = discord.SendDiscordNotification(discord.DiscordNotificationData{
227234
WebhookURL: discord.LoadWebhookURL(),
228235
Content: "Starting SRD import for AIRAC cycle " + cycle,
229236
})
@@ -251,13 +258,6 @@ func importProcess(ctx context.Context, filePath string, cycle string, envPath s
251258

252259
log.Info().Msgf("importing SRD file %v for cycle %v", path, airacCycle.Ident)
253260

254-
// Load the .env file
255-
err = godotenv.Overload(envPath)
256-
if err != nil {
257-
log.Error().Err(err).Msg("failed to load environment file")
258-
return ErrCannotLoadDotenv
259-
}
260-
261261
// Get the database connection parameters
262262
dbParams, err := getDatabaseConnectionParams()
263263
if err != nil {

0 commit comments

Comments
 (0)