From 3b09a9dd4783f18ab3b416e2357f1010c9423850 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Mon, 23 Jun 2025 11:06:17 +0200 Subject: [PATCH 1/9] feat: allow enabling all plugins into a channel --- internal/admin/admin.go | 7 + internal/admin/templates/channel_detail.html | 9 + internal/app/app.go | 28 +- internal/db/db.go | 43 ++- internal/db/db_test.go | 203 ++++++++++++ internal/migration/migrations.go | 58 ++++ internal/model/message.go | 6 + internal/model/message_test.go | 234 +++++++++++++ internal/plugin/plugin.go | 13 + internal/plugin/plugin_test.go | 331 +++++++++++++++++++ 10 files changed, 915 insertions(+), 17 deletions(-) create mode 100644 internal/db/db_test.go create mode 100644 internal/model/message_test.go create mode 100644 internal/plugin/plugin_test.go diff --git a/internal/admin/admin.go b/internal/admin/admin.go index cfa2595..abefb72 100644 --- a/internal/admin/admin.go +++ b/internal/admin/admin.go @@ -564,6 +564,13 @@ func (a *Admin) handleChannelDetail(w http.ResponseWriter, r *http.Request) { return } + // Update enable_all_plugins + enableAllPlugins := r.FormValue("enable_all_plugins") == "true" + if err := a.db.UpdateChannelEnableAllPlugins(id, enableAllPlugins); err != nil { + http.Error(w, "Failed to update channel enable all plugins", http.StatusInternalServerError) + return + } + a.addFlash(w, r, "Channel updated", "success") http.Redirect(w, r, "/admin/channels/"+channelID, http.StatusSeeOther) return diff --git a/internal/admin/templates/channel_detail.html b/internal/admin/templates/channel_detail.html index 78909df..9f9a78d 100644 --- a/internal/admin/templates/channel_detail.html +++ b/internal/admin/templates/channel_detail.html @@ -27,6 +27,15 @@ +
+ +
+ When enabled, all registered plugins will be automatically enabled for this channel. Individual plugin settings will be ignored. +
+
-{{end}} \ No newline at end of file +{{end}} From 377b1723c31975c9cb43587a949c2014e2ae81ae Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Tue, 24 Jun 2025 08:10:56 +0200 Subject: [PATCH 9/9] fix: default parse mode to text --- internal/platform/telegram/telegram.go | 6 +++--- internal/plugin/social/twitter.go | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/platform/telegram/telegram.go b/internal/platform/telegram/telegram.go index d35bb6b..b015793 100644 --- a/internal/platform/telegram/telegram.go +++ b/internal/platform/telegram/telegram.go @@ -237,13 +237,13 @@ func (t *TelegramPlatform) SendMessage(msg *model.Message) error { "text": msg.Text, } - // Set parse_mode based on plugin preference or default to Markdown + // Set parse_mode based on plugin preference or default to empty string if msg.Raw != nil && msg.Raw["parse_mode"] != nil { // Plugin explicitly set parse_mode payload["parse_mode"] = msg.Raw["parse_mode"] } else { - // Default to Markdown for backward compatibility - payload["parse_mode"] = "Markdown" + // Default to empty string (no formatting) + payload["parse_mode"] = "" } // Add reply if needed diff --git a/internal/plugin/social/twitter.go b/internal/plugin/social/twitter.go index 69bd979..f2c6cc9 100644 --- a/internal/plugin/social/twitter.go +++ b/internal/plugin/social/twitter.go @@ -75,7 +75,6 @@ func (p *TwitterExpander) OnMessage(msg *model.Message, config map[string]interf Chat: msg.Chat, ReplyTo: msg.ID, Channel: msg.Channel, - Raw: map[string]interface{}{"parse_mode": ""}, } action := &model.MessageAction{