fix: respect Permission::SendEmbeds when editing a message

This commit is contained in:
arslee07
2023-09-04 16:56:40 +09:00
committed by Paul Makles
parent 1a96bf5a4b
commit c5494aa1ca

View File

@@ -78,6 +78,11 @@ pub async fn req(
// 3. Replace if we are given new embeds // 3. Replace if we are given new embeds
if let Some(embeds) = edit.embeds { if let Some(embeds) = edit.embeds {
// Ensure we have permissions to send embeds
permissions
.throw_permission_and_view_channel(db, Permission::SendEmbeds)
.await?;
new_embeds.clear(); new_embeds.clear();
for embed in embeds { for embed in embeds {
@@ -89,14 +94,19 @@ pub async fn req(
message.update(db, partial).await?; message.update(db, partial).await?;
// Queue up a task for processing embeds // Queue up a task for processing embeds if the we have sufficient permissions
if let Some(content) = edit.content { if permissions
revolt_quark::tasks::process_embeds::queue( .has_permission(&db, Permission::SendEmbeds)
message.channel.to_string(), .await?
message.id.to_string(), {
content, if let Some(content) = edit.content {
) revolt_quark::tasks::process_embeds::queue(
.await; message.channel.to_string(),
message.id.to_string(),
content,
)
.await;
}
} }
Ok(Json(message)) Ok(Json(message))