Skip to content

feat: add 3 new plugin hooks : onBeforeBlobUpload, onBeforeDraftAutoS…#586

Merged
rathlinus merged 2 commits into
bulwarkmail:mainfrom
paulhenry46:main
Jul 9, 2026
Merged

feat: add 3 new plugin hooks : onBeforeBlobUpload, onBeforeDraftAutoS…#586
rathlinus merged 2 commits into
bulwarkmail:mainfrom
paulhenry46:main

Conversation

@paulhenry46

@paulhenry46 paulhenry46 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR add 3 new hooks onBeforeBlobUpload, onBeforeDraftAutoSave, onBeforeEditDraft and 2 new host.api methods.
This is needed for true e2e encryption. Indeed, now, when we write an email and then send it encrypted with recipients pub key, the server has seen the drafts and attachments used in the email. This PR try to fix that.

Changes

Hooks

  • add onBeforeBlobUpload file transformer hook. It is called just before the file is uploaded to the server. This transforms the file and not its properties (name, type, etc) registered in email. It will be used to encrypt the attachments.
  • add onBeforeDraftAutoSave AlmostSavedDraft transformer hook. It is called just before the draft is saved by client. It will be used to encrypt the content of the draft.
  • add onBeforeEditDraft Email transformer hook. It is called just before the composer is populated with values from draft we edit. It is useful to decrypt the draft we encrypt earlier.

Host API

Added

upfiles: {
      save: (formerFileId:string, file:File) =>
        callApi('upfiles.save', [formerFileId, file]) as Promise<string>,
      get: (fileId:string) =>
        callApi('upfiles.get', [fileId]) as Promise<File>,
    },

This is related to onBeforeBlobUpload hook. Indeed, editing files uploaded is dangerous, so we want a permission for that. This new host API are created to prevent plugins without permission to just register the onBeforeBlobUpload without declaring the good permission. This new api methods allow the plugin to get the raw file and replace it before upload.

Before uploading email-composer save the file in a store of indexedDB and pass the ID to the transformer. The plugins can edit file and save it to the indexedDB. They return the new ID of the File saved in indexedDB. The save method automatically remove precedent version of File in the indexedDB.

plugin-storage

We added the store file-plugin to save the files and expose the fileStorage API used in the API host methods.

Related Issues

This add hooks to create a PGP plugin to (#481)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactor / code quality improvement
  • Chore / dependency update / CI change

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style and conventions
  • I have run npm run typecheck && npm run lint and there are no errors
  • The build passes (npm run build)
  • I have tested my changes locally
  • I have added or updated documentation if needed => I will do a separate PR on plugins repo it this PR is accepted.
  • I have updated translations (locales/) if my changes affect user-facing text (N/A)
  • I have included screenshots or a screen recording for UI changes (N/A)

Screenshots / Demo

Notes for Reviewers

The two new API methods are privileged tiers.

@paulhenry46 paulhenry46 closed this Jul 9, 2026
@paulhenry46 paulhenry46 reopened this Jul 9, 2026
@paulhenry46
paulhenry46 marked this pull request as ready for review July 9, 2026 12:44
@rathlinus
rathlinus merged commit 752e711 into bulwarkmail:main Jul 9, 2026
@rathlinus

Copy link
Copy Markdown
Member

also check out the new sidebar and popup options, if you need/want to use them

paulhenry46 added a commit to paulhenry46/webmail that referenced this pull request Jul 9, 2026
paulhenry46 added a commit to paulhenry46/webmail that referenced this pull request Jul 12, 2026
rathlinus pushed a commit that referenced this pull request Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants