From 35851c124c7f074e237eadf2ec09fd85a1d7e5a6 Mon Sep 17 00:00:00 2001 From: Tour Date: Mon, 8 Dec 2025 08:14:42 +0100 Subject: [PATCH] all --- .env | 1 + scripts/BFG.ps1 | 33 +++++++++++++++++++ .../java/auctiora/NotificationService.java | 26 +++++++++++---- 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 .env create mode 100644 scripts/BFG.ps1 diff --git a/.env b/.env new file mode 100644 index 0000000..1f6cd0f --- /dev/null +++ b/.env @@ -0,0 +1 @@ +GMAIL_APP_PASSWORD=agrepolhlnvhipkv \ No newline at end of file diff --git a/scripts/BFG.ps1 b/scripts/BFG.ps1 new file mode 100644 index 0000000..cf96738 --- /dev/null +++ b/scripts/BFG.ps1 @@ -0,0 +1,33 @@ +# BFG.ps1 (run from C:\vibe\auctiora\scripts) +$ErrorActionPreference = "Stop" + +# 1) Download BFG jar once, next to this script +$bfgJar = Join-Path $PSScriptRoot "bfg.jar" +if (-not (Test-Path $bfgJar)) { + Invoke-WebRequest ` + "https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar" ` + -OutFile $bfgJar +} + +# 2) Clone bare mirror next to project root: C:\vibe\auctiora\auctiora.git +$rootDir = Join-Path $PSScriptRoot ".." +$mirrorPath = Join-Path $rootDir "auctiora.git" + +if (Test-Path $mirrorPath) { + Remove-Item $mirrorPath -Recurse -Force +} + +git clone --mirror "https://git.appmodel.nl/Tour/auctiora.git" $mirrorPath + +# 3) Run BFG in mirror +Push-Location $mirrorPath + +java -jar $bfgJar --strip-blobs-bigger-than 50M . + +git reflog expire --expire=now --all +git gc --prune=now --aggressive + +# 4) Force-push cleaned history +git push --force + +Pop-Location diff --git a/src/main/java/auctiora/NotificationService.java b/src/main/java/auctiora/NotificationService.java index d7a1a20..1282c3b 100644 --- a/src/main/java/auctiora/NotificationService.java +++ b/src/main/java/auctiora/NotificationService.java @@ -52,32 +52,46 @@ public record NotificationService(Config cfg) { var props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); + props.put("mail.smtp.starttls.required", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); props.put("mail.smtp.ssl.trust", "smtp.gmail.com"); - + props.put("mail.smtp.ssl.protocols", "TLSv1.2"); + + // Connection timeouts (10 seconds each) + props.put("mail.smtp.connectiontimeout", "10000"); + props.put("mail.smtp.timeout", "10000"); + props.put("mail.smtp.writetimeout", "10000"); + var session = Session.getInstance(props, new Authenticator() { - + @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(cfg.smtpUsername(), cfg.smtpPassword()); } }); - + + // Enable debug mode for troubleshooting (can be disabled in production) + // session.setDebug(true); + var m = new MimeMessage(session); m.setFrom(new InternetAddress(cfg.smtpUsername())); m.setRecipients(Message.RecipientType.TO, InternetAddress.parse(cfg.toEmail())); m.setSubject("[Troostwijk] " + title); m.setText(msg); m.setSentDate(new Date()); - + if (prio > 0) { m.setHeader("X-Priority", "1"); m.setHeader("Importance", "High"); } - + Transport.send(m); - log.info("Email notification: {}", title); + log.info("Email notification sent: {}", title); + } catch (javax.mail.AuthenticationFailedException e) { + log.warn("Email authentication failed - check Gmail App Password: {}", e.getMessage()); + } catch (javax.mail.MessagingException e) { + log.warn("Email connection failed (network/firewall issue?): {}", e.getMessage()); } catch (Exception e) { log.warn("Email failed: {}", e.getMessage()); }