Skip to content

Commit

Permalink
chore: improve code style
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-virkus committed Jan 20, 2024
1 parent da199db commit 70a0e36
Show file tree
Hide file tree
Showing 10 changed files with 2,437 additions and 1,671 deletions.
39 changes: 28 additions & 11 deletions lib/src/private/smtp/commands/smtp_send_bdat_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,22 @@ class _SmtpSendBdatCommand extends SmtpCommand {
result.add(chunkData);
startIndex += chunkSize;
}

return result;
}

@override
String get command {
if (supportUnicode) {
print('supportUnicode $supportUnicode');
// cSpell:ignore SMTPUTF8

return 'MAIL FROM:<$fromEmail> SMTPUTF8';
}
if (use8BitEncoding) {
return 'MAIL FROM:<$fromEmail> BODY=8BITMIME';
}

return 'MAIL FROM:<$fromEmail>';
}

Expand All @@ -74,13 +78,18 @@ class _SmtpSendBdatCommand extends SmtpCommand {
_currentStep = _BdatSequence.rcptTo;
_recipientIndex++;
return SmtpCommandData(
_getRecipientToCommand(recipientEmails[0]), null);
_getRecipientToCommand(recipientEmails[0]),
null,
);
case _BdatSequence.rcptTo:
final index = _recipientIndex;
if (index < recipientEmails.length) {
_recipientIndex++;

return SmtpCommandData(
_getRecipientToCommand(recipientEmails[index]), null);
_getRecipientToCommand(recipientEmails[index]),
null,
);
} else if (response.type == SmtpResponseType.success) {
return _getCurrentChunk();
} else {
Expand All @@ -99,6 +108,7 @@ class _SmtpSendBdatCommand extends SmtpCommand {
if (_chunkIndex >= _chunks.length) {
_currentStep = _BdatSequence.done;
}

return SmtpCommandData(null, chunk);
}

Expand All @@ -109,6 +119,7 @@ class _SmtpSendBdatCommand extends SmtpCommand {
if (_currentStep == _BdatSequence.bdat) {
return response.code == 354;
}

return (response.type != SmtpResponseType.success) ||
(_currentStep == _BdatSequence.done);
}
Expand Down Expand Up @@ -147,13 +158,14 @@ class SmtpSendBdatMailDataCommand extends _SmtpSendBdatCommand {
required bool use8BitEncoding,
required bool supportUnicode,
}) : super(
() => data
.toString()
.replaceAll(RegExp('^Bcc:.*\r\n', multiLine: true), ''),
from.email,
recipientEmails,
use8BitEncoding: use8BitEncoding,
supportUnicode: supportUnicode);
() => data
.toString()
.replaceAll(RegExp('^Bcc:.*\r\n', multiLine: true), ''),
from.email,
recipientEmails,
use8BitEncoding: use8BitEncoding,
supportUnicode: supportUnicode,
);

/// The message data to be sent
final MimeData data;
Expand All @@ -168,8 +180,13 @@ class SmtpSendBdatMailTextCommand extends _SmtpSendBdatCommand {
List<String> recipientEmails, {
required bool use8BitEncoding,
required bool supportUnicode,
}) : super(() => data, from.email, recipientEmails,
use8BitEncoding: use8BitEncoding, supportUnicode: supportUnicode);
}) : super(
() => data,
from.email,
recipientEmails,
use8BitEncoding: use8BitEncoding,
supportUnicode: supportUnicode,
);

/// The message text data
final String data;
Expand Down
Loading

0 comments on commit 70a0e36

Please sign in to comment.