Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
2bc0a8c
받은 첨부파일 목록 표시와 저장 추가
littlebit0 Nov 21, 2026
e284391
첨부 다운로드 실패 시 기존 파일 보존, 첨부 메일(rfc822) 자체를 첨부로 노출
littlebit0 Nov 21, 2026
bcd2b54
첨부 다운로드를 앱 임시 폴더에 받은 뒤 성공 시에만 대상 파일로 복사
littlebit0 Nov 21, 2026
9d9f379
인증 전에는 첨부 다운로드를 로컬 요청에만 허용
littlebit0 Nov 21, 2026
c4a3681
첨부 다운로드에 Host·Origin 검사를 추가
littlebit0 Nov 21, 2026
d82bf59
첨부 Host·Origin 검사 import 누락 수정 및 테스트 추가
littlebit0 Nov 21, 2026
4809bd6
base64 첨부 크기를 디코딩 기준 추정값으로 표시
littlebit0 Nov 21, 2026
8980cde
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
1f12577
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
e4f81f1
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
22bb0ea
단일 파트 첨부를 노출하고 텍스트 첨부를 원본 바이트로 내려받기
littlebit0 Nov 26, 2026
c683b32
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
ab0f403
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
e089b8f
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
8015307
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
1480e88
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
d2d552f
Merge remote-tracking branch 'origin/main' into feat/issue-28-attachm…
littlebit0 Nov 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/client/lib/core/i18n/language_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ class AppStrings {
: 'The new password is checked before saving. Stored mail and settings are kept.';
String get reconnectSucceeded =>
_ko ? '다시 연결했습니다. 메일을 가져오는 중입니다.' : 'Reconnected. Fetching mail now.';
String get attachments => _ko ? '첨부파일' : 'Attachments';
String get saveAttachment => _ko ? '저장' : 'Save';
String attachmentSaved(String path) =>
_ko ? '$path에 저장했습니다' : 'Saved to $path';
String get attachmentSaveFailed =>
_ko ? '첨부파일을 저장하지 못했습니다' : 'Could not save the attachment';
String get messageLoadFailedTitle =>
_ko ? '메일 본문을 불러오지 못했습니다' : 'Could not open this message';
String syncFailure(String? code, String? error) {
Expand Down
76 changes: 76 additions & 0 deletions apps/client/lib/features/message/attachment_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../core/i18n/language_controller.dart';
import '../../services/mail_api_client.dart';

class AttachmentList extends ConsumerWidget {
const AttachmentList({
super.key,
required this.accountId,
required this.messageId,
required this.attachments,
});

final String accountId;
final String messageId;
final List<MessageAttachment> attachments;

Future<void> _save(
BuildContext context,
WidgetRef ref,
MessageAttachment attachment,
) async {
final strings = ref.read(appStringsProvider);
final messenger = ScaffoldMessenger.of(context);
try {
// shortcut: file_selector save dialog is desktop only, add a mobile
// share/save flow in a follow-up.
final location = await getSaveLocation(
suggestedName: attachment.filename,
);
if (location == null) return;
await ref.read(mailApiClientProvider).downloadAttachment(
accountId: accountId,
messageId: messageId,
part: attachment.part,
savePath: location.path,
);
messenger.showSnackBar(
SnackBar(content: Text(strings.attachmentSaved(location.path))),
);
} catch (_) {
messenger.showSnackBar(
SnackBar(content: Text(strings.attachmentSaveFailed)),
);
}
}

@override
Widget build(BuildContext context, WidgetRef ref) {
final strings = ref.watch(appStringsProvider);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Divider(height: 32),
Text(strings.attachments,
style: Theme.of(context).textTheme.titleSmall),
for (final attachment in attachments)
ListTile(
contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.attach_file),
title: Text(attachment.filename),
subtitle: Text(
'${formatAttachmentSize(attachment.size)} · ${attachment.contentType}',
),
trailing: IconButton(
tooltip: strings.saveAttachment,
onPressed: () => _save(context, ref, attachment),
icon: const Icon(Icons.download),
),
),
],
);
}
}
7 changes: 7 additions & 0 deletions apps/client/lib/features/message/message_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:go_router/go_router.dart';
import '../../core/i18n/language_controller.dart';
import '../../services/mail_api_client.dart';
import '../../widgets/app_shell.dart';
import 'attachment_list.dart';
import 'linked_message_body.dart';
import 'reply_draft.dart';

Expand Down Expand Up @@ -79,6 +80,12 @@ class MessagePage extends ConsumerWidget {
Text(item.receivedAtLabel),
const Divider(height: 32),
LinkedMessageBody(body: item.body, links: item.links),
if (item.attachments.isNotEmpty)
AttachmentList(
accountId: accountId,
messageId: messageId,
attachments: item.attachments,
),
],
),
loading: () => const Center(child: CircularProgressIndicator()),
Expand Down
65 changes: 65 additions & 0 deletions apps/client/lib/services/mail_api_client.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -94,6 +96,28 @@ class MailApiClient {
return MessageDetail.fromJson(response.data ?? {});
}

Future<void> downloadAttachment({
required String accountId,
required String messageId,
required String part,
required String savePath,
}) async {
// Download into a unique app-accessible temp dir (the sandbox may deny
// writes next to the selected file); touch the destination only on success.
final tempDir = await Directory.systemTemp.createTemp('attachment_');
try {
final temp = File('${tempDir.path}/download');
await _dio.download(
'/accounts/$accountId/messages/$messageId/attachments/$part',
temp.path,
options: Options(receiveTimeout: const Duration(minutes: 2)),
);
await temp.copy(savePath);
} finally {
await tempDir.delete(recursive: true);
}
}

Future<void> addAccount({
required String providerId,
required String emailAddress,
Expand Down Expand Up @@ -307,6 +331,7 @@ class MessageDetail {
required this.body,
required this.links,
required this.receivedAtLabel,
this.attachments = const [],
this.receivedAt,
this.accountId,
this.messageId,
Expand All @@ -328,6 +353,7 @@ class MessageDetail {
final String body;
final List<MessageLink> links;
final String receivedAtLabel;
final List<MessageAttachment> attachments;
final DateTime? receivedAt;

factory MessageDetail.fromJson(Map<String, dynamic> json) {
Expand All @@ -341,6 +367,10 @@ class MessageDetail {
.map(MessageLink.fromJson)
.toList(growable: false),
receivedAtLabel: _formatReceivedAt(json['receivedAt'] as String?),
attachments: (json['attachments'] as List<dynamic>? ?? const [])
.whereType<Map<String, dynamic>>()
.map(MessageAttachment.fromJson)
.toList(growable: false),
receivedAt:
DateTime.tryParse(json['receivedAt'] as String? ?? '')?.toLocal(),
accountId: json['accountId'] as String?,
Expand All @@ -353,6 +383,41 @@ class MessageDetail {
}
}

class MessageAttachment {
const MessageAttachment({
required this.part,
required this.filename,
required this.contentType,
required this.size,
});

final String part;
final String filename;
final String contentType;
final int size;

factory MessageAttachment.fromJson(Map<String, dynamic> json) {
return MessageAttachment(
part: json['part'] as String? ?? '',
filename: json['filename'] as String? ?? '',
contentType: json['contentType'] as String? ?? '',
size: (json['size'] as num?)?.toInt() ?? 0,
);
}
}

String formatAttachmentSize(int bytes) {
if (bytes < 1024) return '$bytes B';
const units = ['KB', 'MB', 'GB'];
var value = bytes / 1024;
var unit = 0;
while (value >= 1024 && unit < units.length - 1) {
value /= 1024;
unit += 1;
}
return '${value.toStringAsFixed(value < 10 ? 1 : 0)} ${units[unit]}';
}

List<String> _strings(Object? value) =>
(value as List<dynamic>? ?? const []).whereType<String>().toList();

Expand Down
2 changes: 2 additions & 0 deletions apps/client/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import FlutterMacOS
import Foundation

import file_selector_macos
import shared_preferences_foundation
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
2 changes: 2 additions & 0 deletions apps/client/macos/Runner/DebugProfile.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<string>development</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.client</key>
Expand Down
2 changes: 2 additions & 0 deletions apps/client/macos/Runner/Release.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<string>development</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
Expand Down
80 changes: 80 additions & 0 deletions apps/client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: f141ea4f277af142a0356955707f6556f37b03947d39d55585981a06ca437bd6
url: "https://pub.dev"
source: hosted
version: "0.3.5+5"
cupertino_icons:
dependency: "direct main"
description:
Expand Down Expand Up @@ -97,6 +105,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.1"
file_selector:
dependency: "direct main"
description:
name: file_selector
sha256: bd15e43e9268db636b53eeaca9f56324d1622af30e5c34d6e267649758c84d9a
url: "https://pub.dev"
source: hosted
version: "1.1.0"
file_selector_android:
dependency: transitive
description:
name: file_selector_android
sha256: d670cd0ce77a2e785b18d8b4d0a8d6a222d6a813ec9b7ddf2790a1b4fb6fa92c
url: "https://pub.dev"
source: hosted
version: "0.5.2+11"
file_selector_ios:
dependency: transitive
description:
name: file_selector_ios
sha256: "97269e5307a0ab813b1fa2430bada0a96e0afb74848417f8676f64ba5de0051c"
url: "https://pub.dev"
source: hosted
version: "0.5.3+6"
file_selector_linux:
dependency: transitive
description:
name: file_selector_linux
sha256: da76400e7872ce7637ffdce12749ec24169c25f6195c28372208e65a24bcd2ab
url: "https://pub.dev"
source: hosted
version: "0.9.4+1"
file_selector_macos:
dependency: transitive
description:
name: file_selector_macos
sha256: d57c62362766b5e7ae739448650b66c6aab7a68ba7ecc65e04018652645ae0f4
url: "https://pub.dev"
source: hosted
version: "0.9.5+1"
file_selector_platform_interface:
dependency: transitive
description:
name: file_selector_platform_interface
sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85"
url: "https://pub.dev"
source: hosted
version: "2.7.0"
file_selector_web:
dependency: transitive
description:
name: file_selector_web
sha256: "73181fbc5257776d8ecaa6a94ab3c8e920ad143b9132a6d984a9271dfc6928d3"
url: "https://pub.dev"
source: hosted
version: "0.9.5"
file_selector_windows:
dependency: transitive
description:
name: file_selector_windows
sha256: fbefc5fb92c6d3cbe8d284a2cd971b593bb07d2cd6da8557b81a862250b4acec
url: "https://pub.dev"
source: hosted
version: "0.9.3+6"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -141,6 +213,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "14.8.1"
http:
dependency: transitive
description:
name: http
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
url: "https://pub.dev"
source: hosted
version: "1.6.0"
http_parser:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions apps/client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
go_router: ^14.6.2
intl: ^0.20.1
url_launcher: ^6.3.2
file_selector: ^1.1.0
shared_preferences: ^2.5.6

dev_dependencies:
Expand Down
Loading
Loading