Fix issues
This commit is contained in:
parent
1a380509fe
commit
3eb61e3107
2 changed files with 40 additions and 20 deletions
|
@ -76,17 +76,18 @@ void main(List<String> argsRaw) async {
|
|||
"✉️ Sending...",
|
||||
);
|
||||
|
||||
final from = mail.MailAddress(settings.mailName, settings.email);
|
||||
final mailClient = await container.read(
|
||||
MailClientController.provider.future,
|
||||
);
|
||||
await mailClient.sendMessageBuilder(
|
||||
mail.MessageBuilder.prepareMultipartAlternativeMessage(
|
||||
await container
|
||||
.read(MailClientController.provider.notifier)
|
||||
.sendMessage(
|
||||
plainText:
|
||||
"""Your registration for Federated Nexus has been accepted! Your credentials are:
|
||||
Username: ${registration.username}.
|
||||
Password: $password""",
|
||||
htmlText: markdownToHtml(
|
||||
Password: $password
|
||||
|
||||
If you have any questions, check out our documentation: https://federated.nexus/services/matrix/.
|
||||
|
||||
If you have any issues, reply to this email.""",
|
||||
markdown:
|
||||
"""# Your registration for Federated Nexus has been accepted!
|
||||
## Your credentials are:
|
||||
- ### Username: ${registration.username}.
|
||||
|
@ -95,14 +96,11 @@ Password: $password""",
|
|||
If you have any questions, check out [our documentation](https://federated.nexus/services/matrix/).
|
||||
|
||||
If you have any issues, reply to this email.""",
|
||||
),
|
||||
)..subject = "Your registration for Federated Nexus has been accepted!",
|
||||
from: from,
|
||||
recipients: [
|
||||
mail.MailAddress(registration.username, registration.email),
|
||||
],
|
||||
subject:
|
||||
"Your registration for Federated Nexus has been accepted!",
|
||||
from: mail.MailAddress(settings.mailName, settings.email),
|
||||
to: mail.MailAddress(registration.username, registration.email),
|
||||
);
|
||||
|
||||
await event.room.redactEvent(reactionEvent!);
|
||||
await event.room.sendReaction(event.eventId, "✉️ Sent!");
|
||||
}
|
||||
|
@ -114,7 +112,9 @@ If you have any issues, reply to this email.""",
|
|||
(Router()..post("/", (Request request) async {
|
||||
final body = await request.readAsString();
|
||||
final registration = Registration.fromJson(
|
||||
Uri.splitQueryString(body),
|
||||
Uri.splitQueryString(
|
||||
body,
|
||||
).map((key, value) => MapEntry(key, value.toLowerCase())),
|
||||
);
|
||||
|
||||
final client = await container.read(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import "dart:io";
|
||||
import "package:enough_mail/enough_mail.dart";
|
||||
import "package:markdown/markdown.dart";
|
||||
import "package:nexusbot/controllers/settings_controller.dart";
|
||||
import "package:riverpod/riverpod.dart";
|
||||
|
||||
|
@ -20,6 +21,25 @@ class MailClientController extends AsyncNotifier<MailClient> {
|
|||
return client;
|
||||
}
|
||||
|
||||
Future<void> sendMessage({
|
||||
required String plainText,
|
||||
required String markdown,
|
||||
required String subject,
|
||||
required MailAddress from,
|
||||
required MailAddress to,
|
||||
}) async {
|
||||
final client = await future;
|
||||
return await client.sendMessageBuilder(
|
||||
MessageBuilder.prepareMultipartAlternativeMessage(
|
||||
plainText: plainText,
|
||||
htmlText: markdownToHtml(markdown),
|
||||
)
|
||||
..subject = subject
|
||||
..from = [from]
|
||||
..to = [to],
|
||||
);
|
||||
}
|
||||
|
||||
static final provider =
|
||||
AsyncNotifierProvider<MailClientController, MailClient>(
|
||||
MailClientController.new,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue