[PR #453] [MERGED] attempt to fix draft versions, missing attachments when sending email #820

Closed
opened 2026-02-25 21:36:20 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/cypht-org/cypht/pull/453
Author: @kroky
Created: 2/15/2021
Status: Merged
Merged: 2/15/2021
Merged by: @jasonmunro

Base: masterHead: bugfix/drafts


📝 Commits (1)

  • 04759c1 attempt to fix draft versions, missing attachments when sending emails and other misc issues

📊 Changes

3 files changed (+37 additions, -16 deletions)

View changed files

📝 modules/imap/handler_modules.php (+2 -1)
📝 modules/smtp/modules.php (+30 -15)
📝 modules/smtp/site.js (+5 -0)

📄 Description

This attempts to fix #421 and #436. The problem I see is with draft version numbers and the fact that new attachments are tied to a draft that is not actually saved in the session, so interactions with cypht in another browser tab could eventually destroy the attachment.

The changes implemented here are making a slight change in behavior which I think is logical. Here are they:

  1. Attaching a file from the compose page to a draft that has not yet been saved automatically saves the draft. This should allow working on other reply/forward/compose pages in the same session in another tab without loosing or interfering with the file you just uploaded.
  2. Fixed numbering issue when deleting drafts - if you had drafts with IDs 0, 1 and 2, deleted 1 and added another one, it would have added that as 2 replacing the previous version 2 because of using the count() method on the drafts array. Instead, we are now using the max key and incrementing that with 1.
  3. Forwarding messages automatically creates an attachment but also automatically creates a draft. It is also automatically saved as soon as the forward compose form is loaded, so we have all the details in the draft itself (rather than just the attached email). This will fix #436 by creating new drafts for each forwarding operation you do.

A side-effect of this change is the auto-saving of drafts happening on 30 seconds interval by default. We now save all draft contents even when no subject is entered (so we can keep the attachments in the drafts without subjects). I think this is behavior similar to other mail clients that won't let you quit an unsaved/unsent compose page even if there is no subject entered. We can improve here by ignoring saving of drafts that are completely empty, so opening the compose page but not doing anything should not actually save as draft.

Jason, let me know your thoughts and what else to improve here!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cypht-org/cypht/pull/453 **Author:** [@kroky](https://github.com/kroky) **Created:** 2/15/2021 **Status:** ✅ Merged **Merged:** 2/15/2021 **Merged by:** [@jasonmunro](https://github.com/jasonmunro) **Base:** `master` ← **Head:** `bugfix/drafts` --- ### 📝 Commits (1) - [`04759c1`](https://github.com/cypht-org/cypht/commit/04759c1ba25dd217d5d0b8d9a7e764c38a358379) attempt to fix draft versions, missing attachments when sending emails and other misc issues ### 📊 Changes **3 files changed** (+37 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `modules/imap/handler_modules.php` (+2 -1) 📝 `modules/smtp/modules.php` (+30 -15) 📝 `modules/smtp/site.js` (+5 -0) </details> ### 📄 Description This attempts to fix #421 and #436. The problem I see is with draft version numbers and the fact that new attachments are tied to a draft that is not actually saved in the session, so interactions with cypht in another browser tab could eventually destroy the attachment. The changes implemented here are making a slight change in behavior which I think is logical. Here are they: 1. Attaching a file from the compose page to a draft that has not yet been saved automatically saves the draft. This should allow working on other reply/forward/compose pages in the same session in another tab without loosing or interfering with the file you just uploaded. 2. Fixed numbering issue when deleting drafts - if you had drafts with IDs 0, 1 and 2, deleted 1 and added another one, it would have added that as 2 replacing the previous version 2 because of using the count() method on the drafts array. Instead, we are now using the max key and incrementing that with 1. 3. Forwarding messages automatically creates an attachment but also automatically creates a draft. It is also automatically saved as soon as the forward compose form is loaded, so we have all the details in the draft itself (rather than just the attached email). This will fix #436 by creating new drafts for each forwarding operation you do. A side-effect of this change is the auto-saving of drafts happening on 30 seconds interval by default. We now save all draft contents even when no subject is entered (so we can keep the attachments in the drafts without subjects). I think this is behavior similar to other mail clients that won't let you quit an unsaved/unsent compose page even if there is no subject entered. We can improve here by ignoring saving of drafts that are completely empty, so opening the compose page but not doing anything should not actually save as draft. Jason, let me know your thoughts and what else to improve here! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-25 21:36:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#820
No description provided.