mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
avoid leaking the token in events
This commit is contained in:
@@ -10,7 +10,11 @@ impl Webhook {
|
||||
pub async fn create(&self, db: &Database) -> Result<()> {
|
||||
db.insert_webhook(self).await?;
|
||||
|
||||
EventV1::WebhookCreate(self.clone())
|
||||
// Avoid leaking the token to people who receive the event
|
||||
let mut webhook = self.clone();
|
||||
webhook.token = None;
|
||||
|
||||
EventV1::WebhookCreate(webhook)
|
||||
.p(self.channel.clone()).await;
|
||||
|
||||
Ok(())
|
||||
@@ -28,7 +32,7 @@ impl Webhook {
|
||||
pub async fn update(
|
||||
&mut self,
|
||||
db: &Database,
|
||||
partial: PartialWebhook,
|
||||
mut partial: PartialWebhook,
|
||||
remove: Vec<FieldsWebhook>
|
||||
) -> Result<()> {
|
||||
for field in &remove {
|
||||
@@ -39,6 +43,8 @@ impl Webhook {
|
||||
|
||||
db.update_webook(&self.id, &partial, &remove).await?;
|
||||
|
||||
partial.token = None; // Avoid leaking the token to people who receive the event
|
||||
|
||||
EventV1::WebhookUpdate {
|
||||
id: self.id.clone(),
|
||||
data: partial,
|
||||
|
||||
Reference in New Issue
Block a user