-
-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathmessages.go
More file actions
617 lines (503 loc) · 14.4 KB
/
Copy pathmessages.go
File metadata and controls
617 lines (503 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
package tui
import (
calendar "github.com/floatpane/go-icalendar"
"github.com/floatpane/matcha/backend"
"github.com/floatpane/matcha/config"
"github.com/floatpane/matcha/daemonrpc"
"github.com/floatpane/matcha/fetcher"
)
type MailboxKind string
const (
MailboxInbox MailboxKind = "inbox"
MailboxSent MailboxKind = "sent"
MailboxTrash MailboxKind = "trash"
MailboxArchive MailboxKind = "archive"
)
type ViewEmailMsg struct {
Index int
UID uint32
AccountID string
Mailbox MailboxKind
Email *fetcher.Email
}
type SendEmailMsg struct {
To string
Cc string // Cc recipient(s)
Bcc string // Bcc recipient(s)
Subject string
Body string
AttachmentPaths []string
InReplyTo string
References []string
AccountID string // ID of the account to send from
FromOverride string // Custom From address (used when account is catch-all)
QuotedText string // Hidden quoted text appended when sending
Signature string // Signature to append to email body
SignSMIME bool // Whether to sign the email using S/MIME
EncryptSMIME bool // Whether to encrypt the email using S/MIME
SignPGP bool // Whether to sign the email using PGP
}
type EmailQueuedMsg struct {
JobID string
DelaySeconds int
}
type EmailDelayExpiredMsg struct {
JobID string
}
type UndoSendMsg struct {
JobID string
}
// ActionGracePeriodExpiredMsg is fired when the undo grace period for a delete/archive/move expires.
type ActionGracePeriodExpiredMsg struct {
JobID string
}
type Credentials struct {
Provider string
Name string
Host string // Host (this was the previous "Email Address" field in the UI)
FetchEmail string // Single email address to fetch messages for. If empty, code should default this to Host when creating the account.
SendAsEmail string // Optional From header email. If empty, sending falls back to FetchEmail, then Host.
CatchAll bool // Show all inbox messages regardless of To address.
Password string
IMAPServer string
IMAPPort int
SMTPServer string
SMTPPort int
Insecure bool
AuthMethod string // "password" or "oauth2"
Protocol string // "imap" (default), "jmap", or "pop3"
JMAPEndpoint string // JMAP session URL
POP3Server string // POP3 server hostname
POP3Port int // POP3 server port
MaildirPath string // Local Maildir root
}
// StartOAuth2Msg is sent when the user requests OAuth2 authorization for a Gmail account.
type StartOAuth2Msg struct {
Email string
}
// OAuth2CompleteMsg is sent when OAuth2 authorization completes.
type OAuth2CompleteMsg struct {
Email string
Err error
}
type ChooseServiceMsg struct {
Service string
}
type EmailResultMsg struct {
Err error
}
type ClearStatusMsg struct{}
type EmailsFetchedMsg struct {
Emails []fetcher.Email
AccountID string
Mailbox MailboxKind
}
type UpdatePreviewMsg struct {
UID uint32
AccountID string
}
type PreviewBodyFetchedMsg struct {
UID uint32
AccountID string
Body string
BodyMIMEType string
Attachments []fetcher.Attachment
Err error
}
type FetchErr error
type SearchRequestedMsg struct {
Query backend.SearchQuery
Mailbox MailboxKind
FolderName string
AccountID string
}
type SearchResultsMsg struct {
Query backend.SearchQuery
Emails []fetcher.Email
Err error
}
type ApplySearchResultsMsg struct {
Query backend.SearchQuery
Emails []fetcher.Email
}
type GoToInboxMsg struct{}
type GoToSentInboxMsg struct{}
type GoToSendMsg struct {
To string
Subject string
Body string
}
type GoToSettingsMsg struct{}
type GoToTrashArchiveMsg struct{}
type GoToSignatureEditorMsg struct {
AccountID string
}
type FetchMoreEmailsMsg struct {
Offset uint32
AccountID string
Mailbox MailboxKind
Limit uint32
}
type FetchingMoreEmailsMsg struct{}
type EmailsAppendedMsg struct {
Emails []fetcher.Email
AccountID string
Mailbox MailboxKind
}
type ReplyToEmailMsg struct {
Email fetcher.Email
}
type ForwardEmailMsg struct {
Email fetcher.Email
}
type OpenHTMLEmailMsg struct {
Email fetcher.Email
}
type SetComposerCursorToStartMsg struct{}
type GoToFilePickerMsg struct{}
type FileSelectedMsg struct {
Paths []string
}
type CancelFilePickerMsg struct{}
type DeleteEmailMsg struct {
UID uint32
AccountID string
Mailbox MailboxKind
}
type ArchiveEmailMsg struct {
UID uint32
AccountID string
Mailbox MailboxKind
}
type EmailActionDoneMsg struct {
UID uint32
AccountID string
Mailbox MailboxKind
Err error
}
// Batch operation messages
type BatchDeleteEmailsMsg struct {
UIDs []uint32
AccountID string
Mailbox MailboxKind
}
type BatchArchiveEmailsMsg struct {
UIDs []uint32
AccountID string
Mailbox MailboxKind
}
type BatchMoveEmailsMsg struct {
UIDs []uint32
AccountID string
SourceFolder string
DestFolder string
}
type BatchEmailActionDoneMsg struct {
Count int
SuccessCount int
FailureCount int
Action string // "delete", "archive", or "move"
Mailbox MailboxKind
Err error
}
type GoToChoiceMenuMsg struct{}
type DownloadAttachmentMsg struct {
Index int
Filename string
PartID string
Data []byte
AccountID string
Encoding string
Mailbox MailboxKind
}
type AttachmentDownloadedMsg struct {
Path string
Err error
}
type RestoreViewMsg struct{}
type BackToInboxMsg struct{}
type BackToMailboxMsg struct {
Mailbox MailboxKind
}
// --- Draft Messages ---
// DiscardDraftMsg signals that a draft should be cached.
type DiscardDraftMsg struct {
ComposerState *Composer
}
type EmailBodyFetchedMsg struct {
UID uint32
Body string
BodyMIMEType string
Attachments []fetcher.Attachment
Err error
AccountID string
Mailbox MailboxKind
}
// --- Multi-Account Messages ---
// GoToAddAccountMsg signals navigation to the add account screen.
type GoToAddAccountMsg struct{}
// GoToAddMailingListMsg signals navigation to the add mailing list screen.
type GoToAddMailingListMsg struct{}
// GoToEditAccountMsg signals navigation to edit an existing account.
type GoToEditAccountMsg struct {
AccountID string
Provider string
Name string
Email string
FetchEmail string
SendAsEmail string
CatchAll bool
IMAPServer string
IMAPPort int
SMTPServer string
SMTPPort int
Insecure bool
Protocol string
JMAPEndpoint string
POP3Server string
POP3Port int
MaildirPath string
}
// GoToEditMailingListMsg signals navigation to edit an existing mailing list.
type GoToEditMailingListMsg struct {
Index int
Name string
Addresses string
}
// SaveMailingListMsg signals that a new or edited mailing list should be saved.
type SaveMailingListMsg struct {
Name string
Addresses string
EditIndex int // -1 means new, >= 0 means editing existing
}
// AddAccountMsg signals that a new account should be added.
type AddAccountMsg struct {
Credentials Credentials
}
// AccountAddedMsg signals that an account was successfully added.
type AccountAddedMsg struct {
AccountID string
Err error
}
// DeleteAccountMsg signals that an account should be deleted.
type DeleteAccountMsg struct {
AccountID string
}
// AccountDeletedMsg signals that an account was successfully deleted.
type AccountDeletedMsg struct {
AccountID string
Err error
}
// SwitchAccountMsg signals switching to view a specific account's inbox.
type SwitchAccountMsg struct {
AccountID string // Empty string means "ALL" accounts
}
// AllEmailsFetchedMsg signals that emails from all accounts have been fetched.
type AllEmailsFetchedMsg struct {
EmailsByAccount map[string][]fetcher.Email
Mailbox MailboxKind
}
// SwitchFromAccountMsg signals changing the "From" account in composer.
type SwitchFromAccountMsg struct {
AccountID string
}
// GoToAccountListMsg signals navigation to the account list in settings.
type GoToAccountListMsg struct{}
// --- Draft Messages (persisted) ---
// SaveDraftMsg signals that the current draft should be saved to disk.
type SaveDraftMsg struct {
Draft config.Draft
}
// DraftSavedMsg signals that a draft was saved successfully.
type DraftSavedMsg struct {
DraftID string
Err error
}
// LoadDraftsMsg signals a request to load all saved drafts.
type LoadDraftsMsg struct{}
// DraftsLoadedMsg signals that drafts were loaded from disk.
type DraftsLoadedMsg struct {
Drafts []config.Draft
}
// OpenDraftMsg signals that a specific draft should be opened in the composer.
type OpenDraftMsg struct {
Draft config.Draft
}
// DeleteDraftMsg signals that a draft should be deleted.
type DeleteSavedDraftMsg struct {
DraftID string
}
// DraftDeletedMsg signals that a draft was deleted.
type DraftDeletedMsg struct {
DraftID string
Err error
}
// GoToDraftsMsg signals navigation to the drafts list.
type GoToDraftsMsg struct{}
// --- Cache Messages ---
// CachedEmailsLoadedMsg signals that cached emails were loaded from disk.
type CachedEmailsLoadedMsg struct {
Cache *config.EmailCache
}
// RefreshingEmailsMsg signals that a background refresh is in progress.
type RefreshingEmailsMsg struct {
Mailbox MailboxKind
}
// EmailsRefreshedMsg signals that fresh emails have been fetched in the background.
type EmailsRefreshedMsg struct {
EmailsByAccount map[string][]fetcher.Email
Mailbox MailboxKind
}
// RequestRefreshMsg signals a request to refresh emails from the server.
type RequestRefreshMsg struct {
Mailbox MailboxKind
Counts map[string]int
FolderName string
}
// --- Folder Messages ---
// FoldersFetchedMsg signals that IMAP folders have been fetched for all accounts.
//
// Errors holds per-account fetch failures (e.g. broken IMAP login, network
// unreachable). Accounts that succeeded appear in FoldersByAccount; accounts
// that failed appear in Errors. The two are disjoint by construction. This
// lets the TUI surface a non-fatal warning instead of silently dropping the
// affected account's folder list.
type FoldersFetchedMsg struct {
FoldersByAccount map[string][]fetcher.Folder // accountID -> folders
MergedFolders []fetcher.Folder // unique folders across all accounts
Errors map[string]error // accountID -> fetch error, if any
}
// SwitchFolderMsg signals switching to a different IMAP folder.
type SwitchFolderMsg struct {
FolderName string
PreviousFolder string
AccountID string
}
// FolderEmailsFetchedMsg signals that emails from a folder have been fetched.
type FolderEmailsFetchedMsg struct {
Emails []fetcher.Email
AccountID string
FolderName string
}
// FolderEmailsAppendedMsg signals that more emails from a folder have been fetched (pagination).
type FolderEmailsAppendedMsg struct {
Emails []fetcher.Email
AccountID string
FolderName string
}
// MoveEmailMsg signals a request to show the move-to-folder picker.
type MoveEmailMsg struct {
UID uint32
AccountID string
SourceFolder string
}
// MoveEmailToFolderMsg signals that an email should be moved to a folder.
type MoveEmailToFolderMsg struct {
UID uint32
AccountID string
SourceFolder string
DestFolder string
}
// EmailMovedMsg signals that an email was moved to a folder.
type EmailMovedMsg struct {
UID uint32
AccountID string
SourceFolder string
DestFolder string
Err error
}
// MarkEmailAsReadMsg signals that an email should be marked as read on the server.
type MarkEmailAsReadMsg struct {
UID uint32
AccountID string
FolderName string
}
// EmailMarkedReadMsg signals that an email was marked as read.
type EmailMarkedReadMsg struct {
UID uint32
AccountID string
Err error
}
// EmailMarkedUnreadMsg signals that an email was marked as unread.
type EmailMarkedUnreadMsg struct {
UID uint32
AccountID string
Err error
}
// FetchFolderMoreEmailsMsg signals a request to fetch more emails from a folder (pagination).
type FetchFolderMoreEmailsMsg struct {
Offset uint32
AccountID string
FolderName string
Limit uint32
}
// --- External Editor Messages ---
// OpenEditorMsg signals that the composer body should be opened in $EDITOR.
type OpenEditorMsg struct{}
// EditorFinishedMsg signals that the external editor has closed.
type EditorFinishedMsg struct {
Body string
Err error
}
// --- IDLE Messages ---
// IdleNewMailMsg signals that IMAP IDLE detected new mail for an account/folder.
type IdleNewMailMsg struct {
AccountID string
FolderName string
}
// --- Daemon Messages ---
// DaemonEventMsg wraps an event pushed from the daemon process.
type DaemonEventMsg struct {
Event *daemonrpc.Event
}
// --- Plugin Messages ---
// PluginNotifyMsg signals that a plugin wants to show a notification.
type PluginNotifyMsg struct {
Message string
Duration float64 // Duration in seconds (default 2)
}
// PluginKeyBinding describes a plugin-registered keyboard shortcut for display in the help bar.
type PluginKeyBinding struct {
Key string
Description string
}
// PluginPromptSubmitMsg signals that the user submitted a plugin prompt input.
type PluginPromptSubmitMsg struct {
Value string
}
// PluginPromptCancelMsg signals that the user cancelled a plugin prompt input.
type PluginPromptCancelMsg struct{}
// GoToMarketplaceMsg signals navigation to the plugin marketplace.
type GoToMarketplaceMsg struct{}
// PasswordVerifiedMsg signals that the encryption password was verified (or failed).
type PasswordVerifiedMsg struct {
Key []byte // The derived encryption key (nil on failure)
Err error // Non-nil if verification failed
}
// SecureModeEnabledMsg signals that encryption was enabled from settings.
type SecureModeEnabledMsg struct {
Err error
}
// SecureModeDisabledMsg signals that encryption was disabled from settings.
type SecureModeDisabledMsg struct {
Err error
}
// SendRSVPMsg signals that user wants to send RSVP to calendar invite
type SendRSVPMsg struct {
OriginalICS []byte
Event *calendar.Event
Response string // "ACCEPTED", "DECLINED", "TENTATIVE"
AccountID string
InReplyTo string
References []string
}
// RSVPResultMsg signals that RSVP was sent (or failed)
type LanguageChangedMsg struct{}
// ConfigSavedMsg signals the config was written to disk and downstream
// consumers (notably the daemon) should reload it.
type ConfigSavedMsg struct{}
type RSVPResultMsg struct {
Err error
Response string // "ACCEPTED", "DECLINED", "TENTATIVE"
Organizer string // organizer email for Google Calendar note
}