mattermost/server
Felipe Martin 1be8a68dd7
feat: pluginapi: filewillbedownloaded / sendtoastmessage (#34596)
* feat: filewillbedonwloaded hook

* feat: error popup

* chore: make generated pluginapi

* tests

* feat: different errors for different download types

* feat: allow toast positions

* fix: avoid using deprecated i18n function

* feat: add plugin API to show toasts

* feat: downloadType parameter

* tests: updated tests

* chore: make check-style

* chore: i18n

* chore: missing fields in tests

* chore: sorted i18n for webapp

* chore: run mmjstool

* test: fixed webapp tests with new changes

* test: missing mocks

* fix: ensure one-file attachments (previews) are handler properly as thumbnails

* chore: lint

* test: added new logic to tests

* chore: lint

* Add SendToastMessage API and FileWillBeDownloaded hook

- Introduced SendToastMessage method for sending toast notifications to users with customizable options.
- Added FileWillBeDownloaded hook to handle file download requests, allowing plugins to control access to files.
- Updated related types and constants for file download handling.
- Enhanced PluginSettings to include HookTimeoutSeconds for better timeout management.

* Update webapp/channels/src/components/single_image_view/single_image_view.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: copilot reviews

* test: head requests

* chore: linted the webapp

* tests: fixed path

* test: fixed mocked args

* allow sending message to a connection directly

* fix: hook thread safety

* chore: formatting

* chore: remove configuration from system console

* chore: release version

* chore: update signature

* chore: update release version

* chore: addressed comments

* fix: update file rejection handling to use 403 Forbidden status and include rejection reason header

* Fix nil pointer panic in runFileWillBeDownloadedHook

The atomic.Value in runFileWillBeDownloadedHook can be nil if no
plugins implement the FileWillBeDownloaded hook. This causes a panic
when trying to assert the nil interface to string.

This fix adds a nil check before the type assertion, defaulting to
an empty string (which allows the download) when no hooks have run.

Fixes:
- TestUploadDataMultipart/success panic
- TestUploadDataMultipart/resume_success panic

* test: move the logout test last

* chore: restored accidential deletion

* chore: lint

* chore: make generated

* refactor: move websocket events to new package

* chore: go vet

* chore: missing mock

* chore: revert incorrect fmt

* chore: import ordering

* chore: npm i18n-extract

* chore: update constants.tsx from master

* chore: make i18n-extract

* revert: conflict merge

* fix: add missing isFileRejected prop to SingleImageView tests

* fix: mock fetch in SingleImageView tests for async thumbnail check

The component now performs an async fetch to check thumbnail availability
before rendering. Tests need to mock fetch and use waitFor to handle
the async state updates.

* refactor: move hook logic to app layer

* chore: update version to 11.5

* Scope file download rejection toast to the requesting connection

Thread the Connection-Id header through RunFileWillBeDownloadedHook and
sendFileDownloadRejectedEvent so the WebSocket event is sent only to the
connection that initiated the download, instead of all connections for
the user.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-16 17:10:39 +01:00
..
bin Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
build server: ignore tmp mattermost/shared in file (#35316) 2026-02-16 14:45:33 +01:00
channels feat: pluginapi: filewillbedownloaded / sendtoastmessage (#34596) 2026-02-16 17:10:39 +01:00
cmd MM-67335 Fix export files having mismatched permissions (#35182) 2026-02-11 11:04:58 -05:00
config MM-66625 - Drop EnableChannelScopeAccessControl; use permission system only (#35232) 2026-02-12 01:07:15 -05:00
einterfaces [MM-65979] Add Prometheus metrics for plugin webapp performance (#35075) 2026-02-13 18:07:54 +05:30
enterprise [MM-65979] Add Prometheus metrics for plugin webapp performance (#35075) 2026-02-13 18:07:54 +05:30
fips MM-65959: Add FIPS indicator to about dialog (#34463) 2025-12-11 18:37:29 -04:00
fonts Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
i18n feat: pluginapi: filewillbedownloaded / sendtoastmessage (#34596) 2026-02-16 17:10:39 +01:00
platform MM-67099 - Membership Sync fix (#35230) 2026-02-16 16:05:04 +01:00
public feat: pluginapi: filewillbedownloaded / sendtoastmessage (#34596) 2026-02-16 17:10:39 +01:00
scripts [MM-67030] Remove newsletter signup and replace with terms/privacy agreement (#34801) 2026-01-23 18:24:27 +00:00
templates MM-59966 - Compliance Export overhaul - feature branch (#29789) 2025-01-10 16:56:02 -05:00
tests Remove vestigial MySQL support (#34865) 2026-01-20 21:01:59 +00:00
.gitignore Update .server/gitignore to ignore all JSON files under the directory (#27593) 2024-07-11 09:12:57 +02:00
.go-version bumps go version to 1.24.13 (#35289) 2026-02-13 17:39:39 +01:00
.golangci.yml support for Elastic(Open)search CJK analysis plugins (#34784) 2026-02-12 10:05:23 +01:00
.sass-lint.yml Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
config.mk Enabling Prometheus, Grafana, Loki and Promtail running as containers by default in local dev environments (#34263) 2025-10-23 14:08:53 +02:00
copyright.txt Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
docker-compose.makefile.m1.yml support for Elastic(Open)search CJK analysis plugins (#34784) 2026-02-12 10:05:23 +01:00
docker-compose.makefile.yml Explicitly name Postgres container volume (#33954) 2025-10-02 09:29:00 -04:00
docker-compose.pgvector.yml Add support for pgvector in local dev (#33900) 2025-09-15 18:58:43 +00:00
docker-compose.yaml selinux security context fixes in docker compose (#34394) 2025-11-14 17:32:56 +01:00
go.mod bumps go version to 1.24.13 (#35289) 2026-02-13 17:39:39 +01:00
go.sum Add Default Agent Support and promote Agents to be part of suite (#35091) 2026-02-12 02:59:20 +00:00
Makefile Bumping prepackaged version of GitHub plugin (#35223) 2026-02-10 15:11:09 +02:00
path.go Centralize the GetPackagePath (#27004) 2024-05-15 12:05:13 -03:00