mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-18 18:18:23 -05:00
* 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>
39 lines
1.6 KiB
Go
39 lines
1.6 KiB
Go
package pluginapi
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/public/plugin"
|
|
)
|
|
|
|
// FrontendService exposes methods to interact with the frontend.
|
|
type FrontendService struct {
|
|
api plugin.API
|
|
}
|
|
|
|
// OpenInteractiveDialog will open an interactive dialog on a user's client that
|
|
// generated the trigger ID. Used with interactive message buttons, menus
|
|
// and slash commands.
|
|
//
|
|
// Minimum server version: 5.6
|
|
func (f *FrontendService) OpenInteractiveDialog(dialog model.OpenDialogRequest) error {
|
|
return normalizeAppErr(f.api.OpenInteractiveDialog(dialog))
|
|
}
|
|
|
|
// PublishWebSocketEvent sends an event to WebSocket connections.
|
|
// event is the type and will be prepended with "custom_<pluginid>_".
|
|
// payload is the data sent with the event. Interface values must be primitive Go types or mattermost-server/model types.
|
|
// broadcast determines to which users to send the event.
|
|
//
|
|
// Minimum server version: 5.2
|
|
func (f *FrontendService) PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast) {
|
|
f.api.PublishWebSocketEvent(event, payload, broadcast)
|
|
}
|
|
|
|
// SendToastMessage sends a toast notification to a specific user or user session.
|
|
// The userID parameter specifies the user to send the toast to.
|
|
// If connectionID is set, the toast will only be sent to that specific connection.
|
|
//
|
|
// Minimum server version: 11.5
|
|
func (f *FrontendService) SendToastMessage(userID, connectionID, message string, options model.SendToastMessageOptions) error {
|
|
return normalizeAppErr(f.api.SendToastMessage(userID, connectionID, message, options))
|
|
}
|