TF-56 Send email with attachment
This commit is contained in:
@@ -14,7 +14,7 @@ class AccountRequest with EquatableMixin {
|
||||
'password': password.value,
|
||||
};
|
||||
|
||||
String basicAuth() => 'Basic ${base64Encode(utf8.encode('${userName.userName}:${password.value}'))}';
|
||||
String get basicAuth => 'Basic ${base64Encode(utf8.encode('${userName.userName}:${password.value}'))}';
|
||||
|
||||
@override
|
||||
List<Object> get props => [userName, password];
|
||||
|
||||
@@ -9,12 +9,15 @@ import 'package:uri/uri.dart';
|
||||
|
||||
class Attachment with EquatableMixin {
|
||||
|
||||
static final String dispositionAttachment = 'attachment';
|
||||
|
||||
final PartId? partId;
|
||||
final Id? blobId;
|
||||
final UnsignedInt? size;
|
||||
final String? name;
|
||||
final MediaType? type;
|
||||
final String? cid;
|
||||
final String? disposition;
|
||||
|
||||
Attachment({
|
||||
this.partId,
|
||||
@@ -22,7 +25,8 @@ class Attachment with EquatableMixin {
|
||||
this.size,
|
||||
this.name,
|
||||
this.type,
|
||||
this.cid
|
||||
this.cid,
|
||||
this.disposition,
|
||||
});
|
||||
|
||||
String getDownloadUrl(String baseDownloadUrl, AccountId accountId) {
|
||||
@@ -37,5 +41,5 @@ class Attachment with EquatableMixin {
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [partId, blobId, size, name, type, cid];
|
||||
List<Object?> get props => [partId, blobId, size, name, type, cid, disposition];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension AttachmentExtension on Attachment {
|
||||
EmailBodyPart toEmailBodyPart(String disposition) => EmailBodyPart(
|
||||
blobId: blobId,
|
||||
size: size,
|
||||
name: name,
|
||||
type: type,
|
||||
disposition: disposition);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension EmailBodyPartExtension on EmailBodyPart {
|
||||
Attachment toAttachment() => Attachment(
|
||||
partId: partId,
|
||||
blobId: blobId,
|
||||
size: size,
|
||||
name: name,
|
||||
type: type,
|
||||
cid: cid,
|
||||
disposition: disposition);
|
||||
}
|
||||
@@ -35,6 +35,8 @@ export 'extensions/user_profile_extension.dart';
|
||||
export 'extensions/presentation_email_extension.dart';
|
||||
export 'extensions/keyword_identifier_extension.dart';
|
||||
export 'extensions/presentation_mailbox_extension.dart';
|
||||
export 'extensions/email_body_part_extension.dart';
|
||||
export 'extensions/attachment_extension.dart';
|
||||
|
||||
// Download
|
||||
export 'download/download_task_id.dart';
|
||||
|
||||
@@ -8,10 +8,9 @@ class UploadRequest with EquatableMixin {
|
||||
final Uri uploadUrl;
|
||||
final FileInfo fileInfo;
|
||||
final AccountId accountId;
|
||||
final AccountRequest accountRequest;
|
||||
|
||||
UploadRequest(this.uploadUrl, this.accountId, this.fileInfo, this.accountRequest);
|
||||
UploadRequest(this.uploadUrl, this.accountId, this.fileInfo);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [uploadUrl, accountId, fileInfo, accountRequest];
|
||||
List<Object?> get props => [uploadUrl, accountId, fileInfo];
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class UploadResponse with EquatableMixin {
|
||||
}
|
||||
|
||||
extension UploadResponseExtension on UploadResponse {
|
||||
Attachment toAttachmentFile(String nameFile) {
|
||||
return Attachment(blobId: blobId, size: UnsignedInt(size), name: nameFile, type: type);
|
||||
Attachment toAttachmentFile(String nameFile, {MediaType? mediaType}) {
|
||||
return Attachment(blobId: blobId, size: UnsignedInt(size), name: nameFile, type: mediaType ?? type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user