Skip to content

Commit

Permalink
fix(webserver): forbid empty content message update (#3390)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwpaper authored and wsxiaoys committed Nov 8, 2024
1 parent 0b2a7d2 commit 5cdd130
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ee/tabby-schema/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@ impl Mutation {
input: thread::UpdateMessageInput,
) -> Result<bool> {
let user = check_user(ctx).await?;
input.validate()?;

let svc = ctx.locator.thread();
let Some(thread) = svc.get(&input.thread_id).await? else {
return Err(CoreError::NotFound("Thread not found"));
Expand Down
4 changes: 3 additions & 1 deletion ee/tabby-schema/src/schema/thread/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use tabby_common::api::{
code::{CodeSearchDocument, CodeSearchHit, CodeSearchScores},
doc::{DocSearchDocument, DocSearchHit},
};
use validator::Validate;

use crate::{juniper::relay::NodeType, Context};

Expand Down Expand Up @@ -44,11 +45,12 @@ impl NodeType for Message {
}
}

#[derive(GraphQLInputObject, Clone)]
#[derive(GraphQLInputObject, Clone, Validate)]
#[graphql(context = Context)]
pub struct UpdateMessageInput {
pub id: ID,
pub thread_id: ID,
#[validate(length(min = 1, code = "content", message = "content can not be empty"))]
pub content: String,
}

Expand Down

0 comments on commit 5cdd130

Please sign in to comment.