forked from jmug/stoatchat
feat(core): include user and member on Message events
This commit is contained in:
@@ -73,7 +73,7 @@ pub async fn edit(
|
||||
return Err(create_error!(InvalidOperation));
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(db, user.as_author_for_system(), None, None, &channel, false)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
@@ -151,7 +151,7 @@ pub async fn edit(
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(db, user.as_author_for_system(), None, None, &channel, false)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
@@ -161,7 +161,7 @@ pub async fn edit(
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(db, user.as_author_for_system(), None, None, &channel, false)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
@@ -171,7 +171,7 @@ pub async fn edit(
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(db, user.as_author_for_system(), None, None, &channel, false)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
@@ -97,5 +97,5 @@ pub async fn edit(
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Json(message.into()))
|
||||
Ok(Json(message.into_model(None, None)))
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ pub async fn fetch(
|
||||
return Err(create_error!(NotFound));
|
||||
}
|
||||
|
||||
Ok(Json(message.into()))
|
||||
Ok(Json(message.into_model(None, None)))
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use revolt_database::{
|
||||
};
|
||||
use revolt_database::{Interactions, Message};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::PermissionQuery;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::serde::json::Json;
|
||||
@@ -75,18 +76,34 @@ pub async fn message_send(
|
||||
|
||||
// Create the message
|
||||
let author: v0::User = user.clone().into(db, Some(&user)).await;
|
||||
|
||||
// Make sure we have server member (edge case if server owner)
|
||||
query.are_we_a_member().await;
|
||||
|
||||
// Create model user / members
|
||||
let model_user = user
|
||||
.clone()
|
||||
.into_known_static(revolt_presence::is_online(&user.id).await);
|
||||
|
||||
let model_member: Option<v0::Member> = query
|
||||
.member_ref()
|
||||
.as_ref()
|
||||
.map(|member| member.clone().into_owned().into());
|
||||
|
||||
Ok(Json(
|
||||
Message::create_from_api(
|
||||
db,
|
||||
channel,
|
||||
data,
|
||||
v0::MessageAuthor::User(&author),
|
||||
Some(model_user.clone()),
|
||||
model_member.clone(),
|
||||
user.limits().await,
|
||||
idempotency,
|
||||
permissions.has_channel_permission(ChannelPermission::SendEmbeds),
|
||||
allow_mentions,
|
||||
)
|
||||
.await?
|
||||
.into(),
|
||||
.into_model(Some(model_user), model_member),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -59,12 +59,14 @@ pub async fn webhook_execute(
|
||||
channel,
|
||||
data,
|
||||
v0::MessageAuthor::Webhook(&webhook.into()),
|
||||
None,
|
||||
None,
|
||||
config().await.features.limits.default,
|
||||
idempotency,
|
||||
true,
|
||||
true,
|
||||
)
|
||||
.await?
|
||||
.into(),
|
||||
.into_model(None, None),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1072,6 +1072,13 @@ pub async fn webhook_execute_github(
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
message.attach_sendable_embed(db, sendable_embed).await?;
|
||||
message
|
||||
.send(db, MessageAuthor::Webhook(&webhook.into()), &channel, false)
|
||||
.send(
|
||||
db,
|
||||
MessageAuthor::Webhook(&webhook.into()),
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user