feat: add webhook permissions
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::{
|
||||
};
|
||||
use futures::StreamExt;
|
||||
use rand::seq::SliceRandom;
|
||||
use revolt_permissions::DEFAULT_WEBHOOK_PERMISSIONS;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
@@ -945,6 +946,23 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create username index.");
|
||||
};
|
||||
|
||||
if revision <= 25 {
|
||||
info!("Running migration [revision 25 / 11-06-2023]: Add permissions to webhooks.");
|
||||
|
||||
db.col::<Document>("webhooks")
|
||||
.update_many(
|
||||
doc! {},
|
||||
doc! {
|
||||
"$set": {
|
||||
"permissions": *DEFAULT_WEBHOOK_PERMISSIONS as i64
|
||||
}
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to update webhooks.");
|
||||
}
|
||||
|
||||
if revision <= 25 {
|
||||
|
||||
@@ -20,6 +20,9 @@ auto_derived_partial!(
|
||||
/// The channel this webhook belongs to
|
||||
pub channel_id: String,
|
||||
|
||||
/// The permissions of the webhook
|
||||
pub permissions: u64,
|
||||
|
||||
/// The private token for the webhook
|
||||
pub token: Option<String>,
|
||||
},
|
||||
|
||||
@@ -52,6 +52,7 @@ impl From<crate::Webhook> for Webhook {
|
||||
avatar: value.avatar.map(|file| file.into()),
|
||||
channel_id: value.channel_id,
|
||||
token: value.token,
|
||||
permissions: value.permissions
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +65,7 @@ impl From<crate::PartialWebhook> for PartialWebhook {
|
||||
avatar: value.avatar.map(|file| file.into()),
|
||||
channel_id: value.channel_id,
|
||||
token: value.token,
|
||||
permissions: value.permissions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user