Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/io/getstream/chat/java/models/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,20 @@ public enum HookType {
UNKNOWN
}

public enum Product {
@JsonProperty("chat")
CHAT,
@JsonProperty("video")
VIDEO,
@JsonProperty("moderation")
MODERATION,
@JsonProperty("feeds")
FEEDS,
@JsonProperty("all")
@JsonEnumDefaultValue
ALL
}

public enum AuthType {
@JsonProperty("keys")
KEYS, // Using AWS access key and secret key
Expand Down Expand Up @@ -420,6 +434,10 @@ public static class EventHook {
@JsonProperty("enabled")
private Boolean enabled;

@Nullable
@JsonProperty("product")
private Product product;

@Nullable
@JsonProperty("event_types")
private List<String> eventTypes;
Expand Down
26 changes: 15 additions & 11 deletions src/test/java/io/getstream/chat/java/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,24 @@ void whenUpdatingAppSettingsSizeLimit_thenNoException() {
Assertions.assertEquals(newSizeLimit, appConfig.getFileUploadConfig().getSizeLimit());
}

@DisplayName("Can update app settings with webhook event hook")
@DisplayName("Can update app settings with webhook event hooks with different products")
@Test
void whenUpdatingAppSettingsWithWebhookEventHook_thenNoException() throws StreamException {
EventHook webhookHook = new EventHook();
webhookHook.setId("webhook-1");
webhookHook.setHookType(App.HookType.WEBHOOK);
webhookHook.setEnabled(true);
webhookHook.setEventTypes(Arrays.asList("message.new", "message.updated"));
webhookHook.setWebhookURL("https://example.com/webhook");
webhookHook.setCreatedAt(new Date());
webhookHook.setUpdatedAt(new Date());
void whenUpdatingAppSettingsWithWebhookEventHooks_thenNoException() throws StreamException {
EventHook defaultWebhookHook = new EventHook();
defaultWebhookHook.setHookType(App.HookType.WEBHOOK);
defaultWebhookHook.setEnabled(true);
defaultWebhookHook.setEventTypes(Arrays.asList("message.new", "message.updated"));
defaultWebhookHook.setWebhookURL("https://example.com/webhook-default");

EventHook chatWebhookHook = new EventHook();
chatWebhookHook.setHookType(App.HookType.WEBHOOK);
chatWebhookHook.setEnabled(true);
chatWebhookHook.setEventTypes(Arrays.asList("message.new", "message.updated"));
chatWebhookHook.setWebhookURL("https://example.com/webhook-chat");
chatWebhookHook.setProduct(App.Product.CHAT);

try {
App.update().eventHooks(Collections.singletonList(webhookHook)).request();
App.update().eventHooks(Arrays.asList(defaultWebhookHook, chatWebhookHook)).request();
} catch (StreamException e) {
if (e.getMessage().contains("cannot set event hooks in hook v1 system")) {
return;
Expand Down