TF-3023 Get SMime signature status in headers email
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import 'package:model/email/presentation_email.dart';
|
||||||
|
import 'package:model/extensions/list_email_header_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/presentation/model/smime_signature_status.dart';
|
||||||
|
|
||||||
|
extension PresentationEmailExtension on PresentationEmail {
|
||||||
|
|
||||||
|
SMimeSignatureStatus get sMimeStatus {
|
||||||
|
final status = emailHeader?.toSet().sMimeStatus;
|
||||||
|
if (status == 'Good signature') {
|
||||||
|
return SMimeSignatureStatus.goodSignature;
|
||||||
|
} else if (status == 'Bad signature') {
|
||||||
|
return SMimeSignatureStatus.badSignature;
|
||||||
|
} else {
|
||||||
|
return SMimeSignatureStatus.notSigned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
enum SMimeSignatureStatus {
|
||||||
|
goodSignature,
|
||||||
|
badSignature,
|
||||||
|
notSigned
|
||||||
|
}
|
||||||
@@ -22,4 +22,6 @@ class EmailProperty {
|
|||||||
static const String headerMdnKey = 'Disposition-Notification-To';
|
static const String headerMdnKey = 'Disposition-Notification-To';
|
||||||
static const String messageId = 'messageId';
|
static const String messageId = 'messageId';
|
||||||
static const String references = 'references';
|
static const String references = 'references';
|
||||||
|
static const String headerUnsubscribeKey = 'List-Unsubscribe';
|
||||||
|
static const String headerSMimeStatusKey = 'X-SMIME-Status';
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:core/domain/extensions/datetime_extension.dart';
|
import 'package:core/domain/extensions/datetime_extension.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
|
||||||
@@ -14,8 +12,6 @@ import 'package:model/model.dart';
|
|||||||
|
|
||||||
extension EmailExtension on Email {
|
extension EmailExtension on Email {
|
||||||
|
|
||||||
static const String unsubscribeHeaderName = 'List-Unsubscribe';
|
|
||||||
|
|
||||||
String asString() => jsonEncode(toJson());
|
String asString() => jsonEncode(toJson());
|
||||||
|
|
||||||
bool get hasRead => keywords?.containsKey(KeyWordIdentifier.emailSeen) == true;
|
bool get hasRead => keywords?.containsKey(KeyWordIdentifier.emailSeen) == true;
|
||||||
@@ -30,11 +26,7 @@ extension EmailExtension on Email {
|
|||||||
|
|
||||||
bool get withAttachments => hasAttachment == true;
|
bool get withAttachments => hasAttachment == true;
|
||||||
|
|
||||||
String get listUnsubscribe {
|
String get listUnsubscribe => headers.listUnsubscribe;
|
||||||
final listUnsubscribe = headers?.firstWhereOrNull((header) => header.name == unsubscribeHeaderName);
|
|
||||||
log('EmailExtension::listUnsubscribe: $listUnsubscribe');
|
|
||||||
return listUnsubscribe?.value ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get hasListUnsubscribe => listUnsubscribe.isNotEmpty;
|
bool get hasListUnsubscribe => listUnsubscribe.isNotEmpty;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email_header.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email_header.dart';
|
||||||
import 'package:model/email/email_property.dart';
|
import 'package:model/email/email_property.dart';
|
||||||
|
|
||||||
@@ -11,4 +12,14 @@ extension ListEmailHeaderExtension on Set<EmailHeader>? {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get listUnsubscribe {
|
||||||
|
final listUnsubscribe = this?.firstWhereOrNull((header) => header.name == EmailProperty.headerUnsubscribeKey);
|
||||||
|
return listUnsubscribe?.value ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
String get sMimeStatus {
|
||||||
|
final sMimeStatus = this?.firstWhereOrNull((header) => header.name == EmailProperty.headerSMimeStatusKey);
|
||||||
|
return sMimeStatus?.value ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user