diff --git a/application/src/main/java/run/halo/app/infra/config/WebFluxConfig.java b/application/src/main/java/run/halo/app/infra/config/WebFluxConfig.java index 49109f079..dcf576c46 100644 --- a/application/src/main/java/run/halo/app/infra/config/WebFluxConfig.java +++ b/application/src/main/java/run/halo/app/infra/config/WebFluxConfig.java @@ -26,6 +26,7 @@ import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.lang.NonNull; +import org.springframework.web.filter.reactive.ServerWebExchangeContextFilter; import org.springframework.web.reactive.config.ResourceHandlerRegistration; import org.springframework.web.reactive.config.ResourceHandlerRegistry; import org.springframework.web.reactive.config.WebFluxConfigurer; @@ -252,4 +253,11 @@ public class WebFluxConfig implements WebFluxConfigurer { return new AdditionalWebFilterChainProxy(extensionGetter); } + @Bean + // We expect this filter to be executed before AdditionalWebFilterChainProxy + @Order(-102) + ServerWebExchangeContextFilter serverWebExchangeContextFilter() { + return new ServerWebExchangeContextFilter(); + } + } diff --git a/application/src/test/java/run/halo/app/config/WebFluxConfigTest.java b/application/src/test/java/run/halo/app/config/WebFluxConfigTest.java index 40030c643..55b7fec6f 100644 --- a/application/src/test/java/run/halo/app/config/WebFluxConfigTest.java +++ b/application/src/test/java/run/halo/app/config/WebFluxConfigTest.java @@ -1,6 +1,7 @@ package run.halo.app.config; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; import java.net.URI; @@ -18,10 +19,15 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.web.filter.reactive.ServerWebExchangeContextFilter; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.reactive.socket.WebSocketHandler; import org.springframework.web.reactive.socket.WebSocketMessage; import org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import reactor.test.StepVerifier; import run.halo.app.core.endpoint.WebSocketEndpoint; import run.halo.app.core.extension.Role; @@ -31,7 +37,10 @@ import run.halo.app.extension.Metadata; @SpringBootTest(properties = "halo.console.location=classpath:/console/", webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@Import(WebFluxConfigTest.WebSocketSupportTest.TestWebSocketConfiguration.class) +@Import({ + WebFluxConfigTest.WebSocketSupportTest.TestWebSocketConfiguration.class, + WebFluxConfigTest.ServerWebExchangeContextFilterTest.TestConfig.class +}) @AutoConfigureWebTestClient class WebFluxConfigTest { @@ -154,4 +163,34 @@ class WebFluxConfigTest { .expectStatus().isNotFound(); } } + + + @Nested + class ServerWebExchangeContextFilterTest { + + @TestConfiguration + static class TestConfig { + + @Bean + RouterFunction assertServerWebExchangeRoute() { + return RouterFunctions.route() + .GET("/assert-server-web-exchange", + request -> Mono.deferContextual(contextView -> { + var exchange = ServerWebExchangeContextFilter.getExchange(contextView); + assertTrue(exchange.isPresent()); + return ServerResponse.ok().build(); + })) + .build(); + } + + } + + @Test + void shouldGetExchangeFromContextView() { + webClient.get().uri("/assert-server-web-exchange") + .exchange() + .expectStatus().isOk(); + } + + } } \ No newline at end of file diff --git a/ui/console-src/modules/contents/comments/CommentList.vue b/ui/console-src/modules/contents/comments/CommentList.vue index 047be8216..74e54c55b 100644 --- a/ui/console-src/modules/contents/comments/CommentList.vue +++ b/ui/console-src/modules/contents/comments/CommentList.vue @@ -364,11 +364,9 @@ const handleApproveInBatch = async () => { :title="$t('core.comment.empty.title')" > diff --git a/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue b/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue index 90a9a052e..2d5bd8b9d 100644 --- a/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue +++ b/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue @@ -281,7 +281,7 @@ watch( {{ $t("core.common.buttons.back") }} diff --git a/ui/console-src/modules/contents/pages/SinglePageList.vue b/ui/console-src/modules/contents/pages/SinglePageList.vue index 77b25c0ae..f33e6f583 100644 --- a/ui/console-src/modules/contents/pages/SinglePageList.vue +++ b/ui/console-src/modules/contents/pages/SinglePageList.vue @@ -432,7 +432,7 @@ watch(selectedPageNames, (newValue) => {