aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-11-29 08:26:17 +0100
committerivarlovlie <git@ivarlovlie.no>2022-11-29 08:26:28 +0100
commit5779fb8f54306d5397a37a3a29791ffc46a8941a (patch)
treef746cc70f95d9c4b743dc3759e9c1926a32a2ce7
parentc743fad6657e691a42ed2613dbeaa0c7bbb80564 (diff)
downloadgreatoffice-5779fb8f54306d5397a37a3a29791ffc46a8941a.tar.xz
greatoffice-5779fb8f54306d5397a37a3a29791ffc46a8941a.zip
feat: Brush up
-rw-r--r--code/api/src/Services/MailService.cs7
-rw-r--r--code/app/src/routes/(main)/+layout.server.ts4
-rw-r--r--code/app/src/routes/(main)/+layout.ts1
3 files changed, 4 insertions, 8 deletions
diff --git a/code/api/src/Services/MailService.cs b/code/api/src/Services/MailService.cs
index d160762..6f9ff18 100644
--- a/code/api/src/Services/MailService.cs
+++ b/code/api/src/Services/MailService.cs
@@ -3,16 +3,14 @@ namespace IOL.GreatOffice.Api.Services;
public class MailService
{
private readonly ILogger<MailService> _logger;
- private static string _postmarkToken;
private static string _fromEmail;
private readonly HttpClient _httpClient;
public MailService(VaultService vaultService, ILogger<MailService> logger, HttpClient httpClient) {
var configuration = vaultService.GetCurrentAppConfiguration();
- _postmarkToken = configuration.POSTMARK_TOKEN;
_fromEmail = configuration.EMAIL_FROM_ADDRESS;
_logger = logger;
- httpClient.DefaultRequestHeaders.Add("X-Postmark-Server-Token", _postmarkToken);
+ httpClient.DefaultRequestHeaders.Add("X-Postmark-Server-Token", configuration.POSTMARK_TOKEN);
_httpClient = httpClient;
}
@@ -43,8 +41,7 @@ public class MailService
if (message.HtmlBody.IsNullOrWhiteSpace() && message.TextBody.IsNullOrWhiteSpace()) {
throw new ArgumentNullException(nameof(message), "Both HtmlBody and TextBody is empty, nothing to send");
}
-
- // TODO: Log response if unsuccessful
+
var response = await _httpClient.PostAsJsonAsync("https://api.postmarkapp.com/email", message);
_logger.LogInformation("Postmark returned with message: {0}", (await response.Content.ReadFromJsonAsync<PostmarkSendResponse>()).Message);
} catch (Exception e) {
diff --git a/code/app/src/routes/(main)/+layout.server.ts b/code/app/src/routes/(main)/+layout.server.ts
index 5a3c1a2..acb9c22 100644
--- a/code/app/src/routes/(main)/+layout.server.ts
+++ b/code/app/src/routes/(main)/+layout.server.ts
@@ -1,5 +1,5 @@
import { api_base, CookieNames } from "$lib/configuration";
-import { log_error } from "$lib/logger";
+import { log_debug, log_error } from "$lib/logger";
import { error, redirect } from "@sveltejs/kit";
import type { LayoutServerLoad } from "./$types";
@@ -17,7 +17,7 @@ export const load: LayoutServerLoad = async ({ route, cookies, locals }) => {
})
})).ok;
- console.log("Base Layout loaded", {
+ log_debug("Base Layout loaded", {
sessionIsValid,
isPublicRoute,
routeId: route.id
diff --git a/code/app/src/routes/(main)/+layout.ts b/code/app/src/routes/(main)/+layout.ts
index 491ea1f..cf08d66 100644
--- a/code/app/src/routes/(main)/+layout.ts
+++ b/code/app/src/routes/(main)/+layout.ts
@@ -4,7 +4,6 @@ import { loadLocaleAsync } from '$lib/i18n/i18n-util.async'
import { setLocale } from '$lib/i18n/i18n-svelte'
export const load: LayoutLoad<{ locale: Locales }> = async ({ data: { locale } }) => {
- // load dictionary into memory
await loadLocaleAsync(locale)
setLocale(locale)
return { locale }