diff --git a/golemcore/slack/plugin.yaml b/golemcore/slack/plugin.yaml index f8d3416..7ce8c37 100644 --- a/golemcore/slack/plugin.yaml +++ b/golemcore/slack/plugin.yaml @@ -1,7 +1,7 @@ id: golemcore/slack provider: golemcore name: slack -version: 1.0.1 +version: 1.0.2 pluginApiVersion: 1 engineVersion: ">=0.0.0 <1.0.0" entrypoint: me.golemcore.plugins.golemcore.slack.SlackPluginBootstrap diff --git a/golemcore/slack/pom.xml b/golemcore/slack/pom.xml index 3d8190a..c338fd4 100644 --- a/golemcore/slack/pom.xml +++ b/golemcore/slack/pom.xml @@ -9,7 +9,7 @@ ../../pom.xml - 1.0.1 + 1.0.2 golemcore-slack-plugin golemcore/slack Slack Socket Mode channel plugin with interactive approvals for GolemCore diff --git a/golemcore/slack/src/main/java/me/golemcore/plugins/golemcore/slack/SlackPluginConfig.java b/golemcore/slack/src/main/java/me/golemcore/plugins/golemcore/slack/SlackPluginConfig.java index 42ff3af..6913d20 100644 --- a/golemcore/slack/src/main/java/me/golemcore/plugins/golemcore/slack/SlackPluginConfig.java +++ b/golemcore/slack/src/main/java/me/golemcore/plugins/golemcore/slack/SlackPluginConfig.java @@ -1,5 +1,7 @@ package me.golemcore.plugins.golemcore.slack; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -10,6 +12,7 @@ import java.util.List; import java.util.Set; +@JsonIgnoreProperties(ignoreUnknown = true) @Data @NoArgsConstructor @AllArgsConstructor @@ -44,6 +47,7 @@ public void normalize() { allowedChannelIds = normalizeIdentifiers(allowedChannelIds); } + @JsonIgnore public boolean isConfigured() { return botToken != null && !botToken.isBlank() && appToken != null && !appToken.isBlank(); diff --git a/golemcore/slack/src/test/java/me/golemcore/plugins/golemcore/slack/SlackPluginConfigServiceTest.java b/golemcore/slack/src/test/java/me/golemcore/plugins/golemcore/slack/SlackPluginConfigServiceTest.java new file mode 100644 index 0000000..989da9d --- /dev/null +++ b/golemcore/slack/src/test/java/me/golemcore/plugins/golemcore/slack/SlackPluginConfigServiceTest.java @@ -0,0 +1,73 @@ +package me.golemcore.plugins.golemcore.slack; + +import me.golemcore.plugin.api.runtime.PluginConfigurationService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; + +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class SlackPluginConfigServiceTest { + + private PluginConfigurationService pluginConfigurationService; + private SlackPluginConfigService service; + + @BeforeEach + void setUp() { + pluginConfigurationService = mock(PluginConfigurationService.class); + service = new SlackPluginConfigService(pluginConfigurationService); + } + + @Test + void shouldIgnoreLegacyConfiguredFieldWhenReadingStoredPluginConfig() { + when(pluginConfigurationService.getPluginConfig(SlackPluginConfigService.PLUGIN_ID)).thenReturn(Map.of( + "enabled", true, + "botToken", "xoxb-test", + "appToken", "xapp-test", + "replyInThread", false, + "configured", true, + "allowedUserIds", java.util.List.of("U123"), + "allowedChannelIds", java.util.List.of("C123"))); + + SlackPluginConfig config = service.getConfig(); + + assertEquals("xoxb-test", config.getBotToken()); + assertEquals("xapp-test", config.getAppToken()); + assertFalse(Boolean.TRUE.equals(config.getReplyInThread())); + assertEquals(java.util.List.of("U123"), config.getAllowedUserIds()); + assertEquals(java.util.List.of("C123"), config.getAllowedChannelIds()); + } + + @Test + void shouldPersistNormalizedPluginConfigWithoutComputedFields() { + SlackPluginConfig config = SlackPluginConfig.builder() + .enabled(true) + .botToken(" xoxb-token ") + .appToken(" xapp-token ") + .replyInThread(null) + .allowedUserIds(java.util.List.of(" U123 ", "", "U123")) + .allowedChannelIds(java.util.List.of(" C123 ", "C123")) + .build(); + + service.save(config); + + ArgumentCaptor> captor = ArgumentCaptor.forClass(Map.class); + verify(pluginConfigurationService).savePluginConfig(eq(SlackPluginConfigService.PLUGIN_ID), captor.capture()); + + Map saved = captor.getValue(); + assertEquals("xoxb-token", saved.get("botToken")); + assertEquals("xapp-token", saved.get("appToken")); + assertEquals(true, saved.get("enabled")); + assertEquals(true, saved.get("replyInThread")); + assertEquals(java.util.List.of("U123"), saved.get("allowedUserIds")); + assertEquals(java.util.List.of("C123"), saved.get("allowedChannelIds")); + assertFalse(saved.containsKey("configured")); + } +} diff --git a/registry/golemcore/slack/index.yaml b/registry/golemcore/slack/index.yaml index 9ab1691..5c79458 100644 --- a/registry/golemcore/slack/index.yaml +++ b/registry/golemcore/slack/index.yaml @@ -1,8 +1,9 @@ id: golemcore/slack owner: golemcore name: slack -latest: 1.0.1 +latest: 1.0.2 versions: - 1.0.0 - 1.0.1 + - 1.0.2 source: "https://github.com/alexk-dev/golemcore-plugins/tree/main/golemcore/slack" diff --git a/registry/golemcore/slack/versions/1.0.2.yaml b/registry/golemcore/slack/versions/1.0.2.yaml new file mode 100644 index 0000000..8255903 --- /dev/null +++ b/registry/golemcore/slack/versions/1.0.2.yaml @@ -0,0 +1,13 @@ +id: golemcore/slack +version: 1.0.2 +pluginApiVersion: 1 +engineVersion: ">=0.0.0 <1.0.0" +artifactUrl: "dist/golemcore/slack/1.0.2/golemcore-slack-plugin-1.0.2.jar" +checksumSha256: "b68c3377c5fbd511d7d8c1795897d8e1deee0cd94365bcd3e763742bb45fe572" +publishedAt: "2026-03-18T21:59:14Z" +sourceCommit: "e7faba7458c7cbaeeecec2d0a0a78f60de2392ae" +entrypoint: me.golemcore.plugins.golemcore.slack.SlackPluginBootstrap +sourceUrl: "https://github.com/alexk-dev/golemcore-plugins/tree/main/golemcore/slack" +license: "Apache-2.0" +maintainers: + - alexk-dev