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