mattermost-plugin-cleanup-c.../server/plugin.go
Felipe M. 2ecbd2442d
Some checks failed
ci / test (push) Failing after 1m5s
ci / lint (push) Failing after 1m6s
ci / build (push) Failing after 1m6s
release / release (push) Failing after 50s
Add Mattermost plugin for system-admin channel cleanup.
Provide a channel header menu action and /cleanup-channel slash command so system administrators can remove all messages from a channel, with admin checks enforced on both the web app and server. Configure CI and release workflows for the Forgejo runner and signed plugin bundles.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-25 18:46:39 +02:00

37 lines
1,012 B
Go

package main
import (
"net/http"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/plugin"
"github.com/mattermost/mattermost/server/public/pluginapi"
"github.com/fmartingr/mattermost-plugin-cleanup-channel/server/command"
)
type Plugin struct {
plugin.MattermostPlugin
client *pluginapi.Client
commandClient command.Command
router *mux.Router
}
func (p *Plugin) OnActivate() error {
p.client = pluginapi.NewClient(p.API, p.Driver)
p.commandClient = command.NewCommandHandler(p.client, p.cleanupChannel)
p.router = p.initRouter()
return nil
}
func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
response, err := p.commandClient.Handle(args)
if err != nil {
return nil, model.NewAppError("ExecuteCommand", "plugin.command.execute_command.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return response, nil
}