Skip to content

Commit

Permalink
fix #1077
Browse files Browse the repository at this point in the history
  • Loading branch information
liujunzxcv committed Oct 28, 2022
1 parent 0980b79 commit a4cf7d7
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public class WebHookController {

private static final String CONTENT_TYPE = "content-type";

private static final String UUID_GENERATE_MODE = "uuid";

private static final String WEBSITE_PREFIX = "www.";

private static final String WEBSITE_SUFFIX = ".com";

private static final String DOT = ".";

/**
* protocol pool
*/
Expand Down Expand Up @@ -106,13 +114,13 @@ public void execute(String path, Map<String, String> header, byte[] body) throws
}

// 3. convert to cloudEvent obj
String cloudEventId = "uuid".equals(webHookConfig.getCloudEventIdGenerateMode()) ? UUID.randomUUID().toString()
String cloudEventId = UUID_GENERATE_MODE.equals(webHookConfig.getCloudEventIdGenerateMode()) ? UUID.randomUUID().toString()
: webHookRequest.getManufacturerEventId();
String eventType = manufacturerName + "." + webHookConfig.getManufacturerEventName();
String eventType = manufacturerName + DOT + webHookConfig.getManufacturerEventName();

WebhookProtocolTransportObject webhookProtocolTransportObject = WebhookProtocolTransportObject.builder()
.cloudEventId(cloudEventId).eventType(eventType).cloudEventName(webHookConfig.getCloudEventName())
.cloudEventSource("www." + webHookConfig.getManufacturerName() + ".com")
.cloudEventSource(WEBSITE_PREFIX + webHookConfig.getManufacturerName() + WEBSITE_SUFFIX)
.dataContentType(webHookConfig.getDataContentType()).body(body).build();

// 4. send cloudEvent
Expand Down

0 comments on commit a4cf7d7

Please sign in to comment.