feat: allow enabling all plugins into a channel
This commit is contained in:
parent
899ac49336
commit
3b09a9dd47
10 changed files with 915 additions and 17 deletions
|
@ -314,11 +314,21 @@ func (a *App) handleMessage(item queue.Item) {
|
|||
}
|
||||
|
||||
// Process message with plugins
|
||||
for pluginID, channelPlugin := range channel.Plugins {
|
||||
if !channel.HasEnabledPlugin(pluginID) {
|
||||
continue
|
||||
}
|
||||
var pluginsToProcess []string
|
||||
|
||||
if channel.EnableAllPlugins {
|
||||
// If EnableAllPlugins is true, process all registered plugins
|
||||
pluginsToProcess = plugin.GetAvailablePluginIDs()
|
||||
} else {
|
||||
// Otherwise, process only explicitly enabled plugins
|
||||
for pluginID := range channel.Plugins {
|
||||
if channel.HasEnabledPlugin(pluginID) {
|
||||
pluginsToProcess = append(pluginsToProcess, pluginID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, pluginID := range pluginsToProcess {
|
||||
// Get plugin
|
||||
p, err := plugin.Get(pluginID)
|
||||
if err != nil {
|
||||
|
@ -326,11 +336,19 @@ func (a *App) handleMessage(item queue.Item) {
|
|||
continue
|
||||
}
|
||||
|
||||
// Get plugin configuration (empty map if EnableAllPlugins and plugin not explicitly configured)
|
||||
var config map[string]interface{}
|
||||
if channelPlugin, exists := channel.Plugins[pluginID]; exists {
|
||||
config = channelPlugin.Config
|
||||
} else {
|
||||
config = make(map[string]interface{})
|
||||
}
|
||||
|
||||
// Create cache instance for this plugin
|
||||
pluginCache := cache.New(a.db, pluginID)
|
||||
|
||||
// Process message and get actions
|
||||
actions := p.OnMessage(message, channelPlugin.Config, pluginCache)
|
||||
actions := p.OnMessage(message, config, pluginCache)
|
||||
|
||||
// Get platform for processing actions
|
||||
platform, err := platform.Get(item.Platform)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue