mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 21:47:02 +00:00
feat: add additional validation for github webhook
This commit is contained in:
@@ -15,6 +15,7 @@ use schemars::schema::SchemaObject;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
|
use validator::Validate;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
|
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
|
||||||
pub struct GithubUser {
|
pub struct GithubUser {
|
||||||
@@ -1061,6 +1062,10 @@ pub async fn webhook_execute_github(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sendable_embed
|
||||||
|
.validate()
|
||||||
|
.map_err(|error| Error::FailedValidation { error })?;
|
||||||
|
|
||||||
let message_id = Ulid::new().to_string();
|
let message_id = Ulid::new().to_string();
|
||||||
|
|
||||||
let embed = sendable_embed
|
let embed = sendable_embed
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ pub struct Reply {
|
|||||||
pub struct SendableEmbed {
|
pub struct SendableEmbed {
|
||||||
#[validate(length(min = 1, max = 128))]
|
#[validate(length(min = 1, max = 128))]
|
||||||
pub icon_url: Option<String>,
|
pub icon_url: Option<String>,
|
||||||
|
#[validate(length(min = 1, max = 256))]
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
#[validate(length(min = 1, max = 100))]
|
#[validate(length(min = 1, max = 100))]
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
|
|||||||
Reference in New Issue
Block a user