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>
37 lines
1,012 B
Go
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
|
|
}
|