Check user is host for host-broadcasted project messages

This commit is contained in:
Max Brunsfeld 2024-01-08 12:04:59 -08:00
parent a3bc48261e
commit 18b31f1552
4 changed files with 51 additions and 78 deletions

View file

@ -60,8 +60,10 @@ macro_rules! request_messages {
#[macro_export]
macro_rules! entity_messages {
($id_field:ident, $($name:ident),* $(,)?) => {
({$id_field:ident, $entity_type:ty}, $($name:ident),* $(,)?) => {
$(impl EntityMessage for $name {
type Entity = $entity_type;
fn remote_entity_id(&self) -> u64 {
self.$id_field
}

View file

@ -31,6 +31,7 @@ pub trait EnvelopedMessage: Clone + Debug + Serialize + Sized + Send + Sync + 's
}
pub trait EntityMessage: EnvelopedMessage {
type Entity;
fn remote_entity_id(&self) -> u64;
}
@ -369,7 +370,7 @@ request_messages!(
);
entity_messages!(
project_id,
{project_id, ShareProject},
AddProjectCollaborator,
ApplyCodeAction,
ApplyCompletionAdditionalEdits,
@ -422,7 +423,7 @@ entity_messages!(
);
entity_messages!(
channel_id,
{channel_id, Channel},
ChannelMessageSent,
RemoveChannelMessage,
UpdateChannelBuffer,