diff --git a/src/app/mail/index.ts b/src/app/mail/index.ts index 291c5023..849c1a83 100644 --- a/src/app/mail/index.ts +++ b/src/app/mail/index.ts @@ -12,9 +12,8 @@ export class MailNotifications { _controller = maybe() async register(email: string, frequency: string) { - const $app = app.get() - const $pubkey = User.require($app).pubkey - const $signer = $app.signer + const $user = User.require(app.get()) + const $signer = $user.signer if (!$signer) throw new Error("No signer available") @@ -23,7 +22,7 @@ export class MailNotifications { const res = await fetch(buildUrl(EMAIL_NOTIFICATION_SERVER, "subscription", "email"), { method: "POST", - body: JSON.stringify({email, frequency, pubkey: $pubkey}), + body: JSON.stringify({email, frequency, pubkey: $user.pubkey}), headers: {Authorization: authHeader, "Content-Type": "application/json"}, }) @@ -37,8 +36,7 @@ export class MailNotifications { const {key} = emailNotificationState.get() if (!key) return - const $app = app.get() - const $signer = $app.signer + const $signer = app.get().user?.signer if (!$signer) return try {