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
15 changes: 14 additions & 1 deletion src/main/java/io/getstream/Webhook.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ public class Webhook {
// for Stream's always-JSON payloads.
private static final byte[] GZIP_MAGIC = {0x1F, (byte) 0x8B};

/**
* Caps the decompressed size of a gzip webhook body. {@link #gunzipPayload(byte[])} runs before
* the signature check, so without a cap an unsigned gzip bomb could exhaust memory. Raise it if
* your events are larger.
*/
public static long maxPayloadBytes = 10L * 1024 * 1024;

/** Webhook event type constants. */
public static class EventType {
public static final String WILDCARD = "*";
Expand Down Expand Up @@ -1009,18 +1016,24 @@ public static boolean verifySignature(String body, String signature, String secr
*
* @param body the raw request body, possibly gzip-compressed
* @return the uncompressed bytes (or {@code body} unchanged if no gzip prefix)
* @throws InvalidWebhookError if the body has the gzip magic prefix but isn't a valid gzip stream
* @throws InvalidWebhookError if the body has the gzip magic prefix but isn't a valid gzip
* stream, or decompresses to more than {@link #maxPayloadBytes}
*/
public static byte[] gunzipPayload(byte[] body) throws InvalidWebhookError {
if (body == null || body.length < 2 || body[0] != GZIP_MAGIC[0] || body[1] != GZIP_MAGIC[1]) {
return body == null ? new byte[0] : body;
}
long limit = maxPayloadBytes;
try (ByteArrayInputStream bin = new ByteArrayInputStream(body);
GZIPInputStream gz = new GZIPInputStream(bin);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
byte[] buf = new byte[4096];
int n;
while ((n = gz.read(buf)) != -1) {
if ((long) out.size() + n > limit) {
throw new InvalidWebhookError(
InvalidWebhookError.GZIP_FAILED + ": payload exceeds " + limit + " bytes");
}
out.write(buf, 0, n);
}
return out.toByteArray();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/getstream/models/ActionLogResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public class ActionLogResponse {
@JsonProperty("custom")
private Map<String, Object> custom;

@Nullable
@JsonProperty("agent_recommendation")
private AgentRecommendationResponse agentRecommendation;

@Nullable
@JsonProperty("review_queue_item")
private ReviewQueueItemResponse reviewQueueItem;
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/io/getstream/models/AgentFeedbackResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* ========================================================================
* WARNING: GENERATED CODE -- DO NOT EDIT!
* ========================================================================
*
* This file was auto-generated by GetStream internal OpenAPI
*
* Any modifications to this file will be lost upon regeneration.
* To make changes, please modify the source templates and regenerate.
*
* ========================================================================
*/
package io.getstream.models;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
import java.util.List;

/** One moderator correction of a Nora review */
@lombok.Data
@lombok.Builder
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
public class AgentFeedbackResponse {

@JsonProperty("agent_review_id")
private String agentReviewID;

@JsonProperty("content_excerpt")
private String contentExcerpt;

@JsonProperty("created_at")
private Date createdAt;

@JsonProperty("created_by")
private String createdBy;

@JsonProperty("entity_type")
private String entityType;

@JsonProperty("id")
private String id;

@JsonProperty("improvement")
private String improvement;

@JsonProperty("item_id")
private String itemID;

@JsonProperty("moderator_action")
private String moderatorAction;

@JsonProperty("nora_action")
private String noraAction;

@JsonProperty("reason")
private String reason;

@JsonProperty("updated_at")
private Date updatedAt;

@JsonProperty("labels")
private List<String> labels;
}
28 changes: 28 additions & 0 deletions src/main/java/io/getstream/models/AgentRecommendationPayload.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* ========================================================================
* WARNING: GENERATED CODE -- DO NOT EDIT!
* ========================================================================
*
* This file was auto-generated by GetStream internal OpenAPI
*
* Any modifications to this file will be lost upon regeneration.
* To make changes, please modify the source templates and regenerate.
*
* ========================================================================
*/
package io.getstream.models;

import com.fasterxml.jackson.annotation.JsonProperty;

@lombok.Data
@lombok.Builder
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
public class AgentRecommendationPayload {

@JsonProperty("reason")
private String reason;

@JsonProperty("recommended_action")
private String recommendedAction;
}
28 changes: 28 additions & 0 deletions src/main/java/io/getstream/models/AgentRecommendationResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* ========================================================================
* WARNING: GENERATED CODE -- DO NOT EDIT!
* ========================================================================
*
* This file was auto-generated by GetStream internal OpenAPI
*
* Any modifications to this file will be lost upon regeneration.
* To make changes, please modify the source templates and regenerate.
*
* ========================================================================
*/
package io.getstream.models;

import com.fasterxml.jackson.annotation.JsonProperty;

@lombok.Data
@lombok.Builder
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
public class AgentRecommendationResponse {

@JsonProperty("reason")
private String reason;

@JsonProperty("recommended_action")
private String recommendedAction;
}
40 changes: 40 additions & 0 deletions src/main/java/io/getstream/models/AgentReviewJudgmentResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* ========================================================================
* WARNING: GENERATED CODE -- DO NOT EDIT!
* ========================================================================
*
* This file was auto-generated by GetStream internal OpenAPI
*
* Any modifications to this file will be lost upon regeneration.
* To make changes, please modify the source templates and regenerate.
*
* ========================================================================
*/
package io.getstream.models;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import org.jetbrains.annotations.Nullable;

@lombok.Data
@lombok.Builder
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
public class AgentReviewJudgmentResponse {

@Nullable
@JsonProperty("explanation")
private String explanation;

@Nullable
@JsonProperty("label")
private String label;

@Nullable
@JsonProperty("verdict")
private String verdict;

@Nullable
@JsonProperty("evidence")
private List<String> evidence;
}
75 changes: 75 additions & 0 deletions src/main/java/io/getstream/models/AgentReviewResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* ========================================================================
* WARNING: GENERATED CODE -- DO NOT EDIT!
* ========================================================================
*
* This file was auto-generated by GetStream internal OpenAPI
*
* Any modifications to this file will be lost upon regeneration.
* To make changes, please modify the source templates and regenerate.
*
* ========================================================================
*/
package io.getstream.models;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.Nullable;

@lombok.Data
@lombok.Builder
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
public class AgentReviewResponse {

@JsonProperty("context_incomplete")
private Boolean contextIncomplete;

@JsonProperty("created_at")
private Date createdAt;

@JsonProperty("status")
private String status;

@Nullable
@JsonProperty("agent_session_id")
private String agentSessionID;

@Nullable
@JsonProperty("confidence")
private Double confidence;

@Nullable
@JsonProperty("flag_assessment")
private String flagAssessment;

@Nullable
@JsonProperty("model_route")
private String modelRoute;

@Nullable
@JsonProperty("reason")
private String reason;

@Nullable
@JsonProperty("recommended_action")
private String recommendedAction;

@Nullable
@JsonProperty("skip_reason")
private String skipReason;

@Nullable
@JsonProperty("summary")
private String summary;

@Nullable
@JsonProperty("judgments")
private List<AgentReviewJudgmentResponse> judgments;

@Nullable
@JsonProperty("usage")
private Map<String, Object> usage;
}
72 changes: 72 additions & 0 deletions src/main/java/io/getstream/models/AgentReviewSettingsPayload.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* ========================================================================
* WARNING: GENERATED CODE -- DO NOT EDIT!
* ========================================================================
*
* This file was auto-generated by GetStream internal OpenAPI
*
* Any modifications to this file will be lost upon regeneration.
* To make changes, please modify the source templates and regenerate.
*
* ========================================================================
*/
package io.getstream.models;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import org.jetbrains.annotations.Nullable;

/**
* Settings for the moderation agent reviewer, which reviews moderation outcomes and proposes or
* applies an action.
*/
@lombok.Data
@lombok.Builder
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
public class AgentReviewSettingsPayload {

@Nullable
@JsonProperty("agent_config_id")
private String agentConfigID;

@Nullable
@JsonProperty("auto_act_min_confidence")
private Double autoActMinConfidence;

@Nullable
@JsonProperty("context_days")
private Integer contextDays;

@Nullable
@JsonProperty("context_messages")
private Integer contextMessages;

@Nullable
@JsonProperty("enabled")
private Boolean enabled;

@Nullable
@JsonProperty("max_concurrency")
private Integer maxConcurrency;

@Nullable
@JsonProperty("mode")
private String mode;

@Nullable
@JsonProperty("review_images")
private Boolean reviewImages;

@Nullable
@JsonProperty("sample_rate")
private Double sampleRate;

@Nullable
@JsonProperty("scope")
private String scope;

@Nullable
@JsonProperty("rule_ids")
private List<String> ruleIds;
}
Loading
Loading