fix(graph): HttpNode supports user-defined variable filtering methods. #2178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
在通过HttpNode实现WebHook发送通知信息场景,请求的文本内容是需要包含/n等字符的;因此,做以下两点建议:
1、将json处理的objectMapper允许用户自定义,例如自定义如下objectMapper:
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature());
2、对变量的过滤替换规则也允许由用户自定义;当然如果是state中的全局变量,更建议是在KeyStrategy中进行处理。本次提交为兼容原先逻辑,保留原默认的替换方式
参考数据按理:
String message = """今日AI工单智能助手总结
Does this pull request fix one issue?
Describe how you did it
Describe how to verify it
build a HttpNode with objectMapper and variableFilter, run it
HttpNode.builder()
.method(HttpMethod.POST)
.url(url)
.body(formBody)
.outputKey("message_sender_result")
.objectMapper(objectMapper)
.variableFilter(variable -> variable)
.build();
Special notes for reviews