Skip to content

Commit 0215f8c

Browse files
authored
Add product scope hook config (#196)
* Add product scope hook config * Fix lint
1 parent c4d394d commit 0215f8c

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

src/main/java/io/getstream/chat/java/models/App.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,20 @@ public enum HookType {
375375
UNKNOWN
376376
}
377377

378+
public enum Product {
379+
@JsonProperty("chat")
380+
CHAT,
381+
@JsonProperty("video")
382+
VIDEO,
383+
@JsonProperty("moderation")
384+
MODERATION,
385+
@JsonProperty("feeds")
386+
FEEDS,
387+
@JsonProperty("all")
388+
@JsonEnumDefaultValue
389+
ALL
390+
}
391+
378392
public enum AuthType {
379393
@JsonProperty("keys")
380394
KEYS, // Using AWS access key and secret key
@@ -420,6 +434,10 @@ public static class EventHook {
420434
@JsonProperty("enabled")
421435
private Boolean enabled;
422436

437+
@Nullable
438+
@JsonProperty("product")
439+
private Product product;
440+
423441
@Nullable
424442
@JsonProperty("event_types")
425443
private List<String> eventTypes;

src/test/java/io/getstream/chat/java/AppTest.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,24 @@ void whenUpdatingAppSettingsSizeLimit_thenNoException() {
184184
Assertions.assertEquals(newSizeLimit, appConfig.getFileUploadConfig().getSizeLimit());
185185
}
186186

187-
@DisplayName("Can update app settings with webhook event hook")
187+
@DisplayName("Can update app settings with webhook event hooks with different products")
188188
@Test
189-
void whenUpdatingAppSettingsWithWebhookEventHook_thenNoException() throws StreamException {
190-
EventHook webhookHook = new EventHook();
191-
webhookHook.setId("webhook-1");
192-
webhookHook.setHookType(App.HookType.WEBHOOK);
193-
webhookHook.setEnabled(true);
194-
webhookHook.setEventTypes(Arrays.asList("message.new", "message.updated"));
195-
webhookHook.setWebhookURL("https://example.com/webhook");
196-
webhookHook.setCreatedAt(new Date());
197-
webhookHook.setUpdatedAt(new Date());
189+
void whenUpdatingAppSettingsWithWebhookEventHooks_thenNoException() throws StreamException {
190+
EventHook defaultWebhookHook = new EventHook();
191+
defaultWebhookHook.setHookType(App.HookType.WEBHOOK);
192+
defaultWebhookHook.setEnabled(true);
193+
defaultWebhookHook.setEventTypes(Arrays.asList("message.new", "message.updated"));
194+
defaultWebhookHook.setWebhookURL("https://example.com/webhook-default");
195+
196+
EventHook chatWebhookHook = new EventHook();
197+
chatWebhookHook.setHookType(App.HookType.WEBHOOK);
198+
chatWebhookHook.setEnabled(true);
199+
chatWebhookHook.setEventTypes(Arrays.asList("message.new", "message.updated"));
200+
chatWebhookHook.setWebhookURL("https://example.com/webhook-chat");
201+
chatWebhookHook.setProduct(App.Product.CHAT);
198202

199203
try {
200-
App.update().eventHooks(Collections.singletonList(webhookHook)).request();
204+
App.update().eventHooks(Arrays.asList(defaultWebhookHook, chatWebhookHook)).request();
201205
} catch (StreamException e) {
202206
if (e.getMessage().contains("cannot set event hooks in hook v1 system")) {
203207
return;

0 commit comments

Comments
 (0)