From 4acff84ef3e1ab074748b84ea8a374901fc872c7 Mon Sep 17 00:00:00 2001 From: Robert Virkus Date: Mon, 22 Jan 2024 14:01:07 +0100 Subject: [PATCH] chore: improve code style --- lib/src/message_builder.dart | 4 - lib/src/private/imap/search_parser.dart | 2 +- lib/src/private/imap/sort_parser.dart | 2 +- test/message_builder_test.dart | 152 ------------------------ 4 files changed, 2 insertions(+), 158 deletions(-) diff --git a/lib/src/message_builder.dart b/lib/src/message_builder.dart index 7e56a610..a1beb0fc 100644 --- a/lib/src/message_builder.dart +++ b/lib/src/message_builder.dart @@ -1360,8 +1360,6 @@ class MessageBuilder extends PartBuilder { MimeMessage? replyToMessage, bool replyToSimplifyReferences = false, String? messageId, - bool isChat = false, - String? chatGroupId, CharacterSet characterSet = CharacterSet.utf8, TransferEncoding transferEncoding = TransferEncoding.quotedPrintable, }) { @@ -1377,8 +1375,6 @@ class MessageBuilder extends PartBuilder { ..originalMessage = replyToMessage ..replyToSimplifyReferences = replyToSimplifyReferences ..messageId = messageId - ..isChat = isChat - ..chatGroupId = chatGroupId ..characterSet = characterSet ..transferEncoding = transferEncoding; diff --git a/lib/src/private/imap/search_parser.dart b/lib/src/private/imap/search_parser.dart index 5bafaacc..e2bbc931 100644 --- a/lib/src/private/imap/search_parser.dart +++ b/lib/src/private/imap/search_parser.dart @@ -110,7 +110,7 @@ class SearchParser extends ResponseParser { if (entry == '(TAG') { i++; tag = listEntries[i].substring(1, listEntries[i].length - 2); - } else if (entry == 'UID') { + // } else if (entry == 'UID') { // Included for completeness. } else if (entry == 'MIN') { i++; diff --git a/lib/src/private/imap/sort_parser.dart b/lib/src/private/imap/sort_parser.dart index 13d72246..206827cf 100644 --- a/lib/src/private/imap/sort_parser.dart +++ b/lib/src/private/imap/sort_parser.dart @@ -109,7 +109,7 @@ class SortParser extends ResponseParser { if (entry == '(TAG') { i++; tag = listEntries[i].substring(1, listEntries[i].length - 2); - } else if (entry == 'UID') { + // } else if (entry == 'UID') { // Included for completeness. } else if (entry == 'MIN') { i++; diff --git a/test/message_builder_test.dart b/test/message_builder_test.dart index 3498102f..9dbca509 100644 --- a/test/message_builder_test.dart +++ b/test/message_builder_test.dart @@ -114,158 +114,6 @@ void main() { ); //print(message.renderMessage()); }); - - test('Simple chat message', () { - const from = MailAddress('Personal Name', 'sender@domain.com'); - final to = [ - const MailAddress('Recipient Personal Name', 'recipient@domain.com'), - ]; - const subject = 'Hello from test'; - const text = - 'Hello World - here\'s some text that should spans two lines in the ' - 'end when this sentence is finished.'; - final message = MessageBuilder.buildSimpleTextMessage( - from, - to, - text, - subject: subject, - isChat: true, - ); - expect(message.getHeaderValue('subject'), 'Hello from test'); - var id = message.getHeaderValue('message-id') ?? ''; - expect(id, isNotNull); - expect(id.startsWith('', - ); - expect( - message.getHeaderValue('to'), - '"Recipient Personal Name" ', - ); - expect( - message.getHeaderValue('Content-Type'), - 'text/plain; charset="utf-8"', - ); - expect( - message.getHeaderValue('Content-Transfer-Encoding'), - 'quoted-printable', - ); - - final messageText = message.renderMessage(); - //print(messageText); - final parsed = MimeMessage.parseFromText(messageText); - - expect(parsed.getHeaderValue('subject'), 'Hello from test'); - id = parsed.getHeaderValue('message-id') ?? ''; - expect(id, isNotNull); - expect(id.startsWith('', - ); - expect( - parsed.getHeaderValue('to'), - '"Recipient Personal Name" ', - ); - expect( - parsed.getHeaderValue('Content-Type'), - 'text/plain; charset="utf-8"', - ); - expect( - parsed.getHeaderValue('Content-Transfer-Encoding'), - 'quoted-printable', - ); - expect( - parsed.decodeContentText(), - 'Hello World - here\'s some text that should spans two lines in the ' - 'end when this sentence is finished.', - ); - }); - - test('Simple chat group message', () { - const from = MailAddress('Personal Name', 'sender@domain.com'); - final to = [ - const MailAddress('Recipient Personal Name', 'recipient@domain.com'), - const MailAddress('Other Recipient', 'other@domain.com'), - ]; - const subject = 'Hello from test'; - const text = - 'Hello World - here\s some text that should spans two lines in the ' - 'end when this sentence is finished.'; - final message = MessageBuilder.buildSimpleTextMessage( - from, - to, - text, - subject: subject, - isChat: true, - chatGroupId: '1234abc123', - ); - expect(message.getHeaderValue('subject'), 'Hello from test'); - var id = message.getHeaderValue('message-id') ?? ''; - expect(id, isNotNull); - expect(id.startsWith('', - ); - expect( - message.getHeaderValue('to'), - '"Recipient Personal Name" , ' - '"Other Recipient" ', - ); - expect( - message.getHeaderValue('Content-Type'), - 'text/plain; charset="utf-8"', - ); - expect( - message.getHeaderValue('Content-Transfer-Encoding'), - 'quoted-printable', - ); - - final buffer = StringBuffer(); - message.render(buffer); - final messageText = buffer.toString(); - //print(messageText); - final parsed = MimeMessage.parseFromText(messageText); - - expect(parsed.getHeaderValue('subject'), 'Hello from test'); - id = parsed.getHeaderValue('message-id') ?? ''; - expect(id, isNotNull); - expect(id.startsWith('', - ); - final toRecipients = parsed.decodeHeaderMailAddressValue('to') ?? []; - expect(toRecipients, isNotNull); - expect(toRecipients.length, 2); - expect(toRecipients[0].email, 'recipient@domain.com'); - expect(toRecipients[0].hostName, 'domain.com'); - expect(toRecipients[0].mailboxName, 'recipient'); - expect(toRecipients[0].personalName, 'Recipient Personal Name'); - expect(toRecipients[1].email, 'other@domain.com'); - expect(toRecipients[1].hostName, 'domain.com'); - expect(toRecipients[1].mailboxName, 'other'); - expect(toRecipients[1].personalName, 'Other Recipient'); - expect( - parsed.getHeaderValue('Content-Type'), - 'text/plain; charset="utf-8"', - ); - expect( - parsed.getHeaderValue('Content-Transfer-Encoding'), - 'quoted-printable', - ); - expect( - parsed.decodeContentText(), - 'Hello World - here\s some text that should spans two lines in the ' - 'end when this sentence is finished.', - ); - }); }); group('multipart tests', () {