Don't update contacts when a project is first registered

Until the host has sent an UpdateProject message to populate the project's
metadata, there is no reason to update contacts.
This commit is contained in:
Max Brunsfeld 2022-06-02 17:41:21 -07:00
parent f7e7a7c6a7
commit db97dcd76f

View file

@ -476,15 +476,15 @@ impl Server {
request: TypedEnvelope<proto::RegisterProject>, request: TypedEnvelope<proto::RegisterProject>,
response: Response<proto::RegisterProject>, response: Response<proto::RegisterProject>,
) -> Result<()> { ) -> Result<()> {
let user_id;
let project_id; let project_id;
{ {
let mut state = self.store_mut().await; let mut state = self.store_mut().await;
user_id = state.user_id_for_connection(request.sender_id)?; let user_id = state.user_id_for_connection(request.sender_id)?;
project_id = state.register_project(request.sender_id, user_id); project_id = state.register_project(request.sender_id, user_id);
}; };
response.send(proto::RegisterProjectResponse { project_id })?; response.send(proto::RegisterProjectResponse { project_id })?;
self.update_user_contacts(user_id).await?;
Ok(()) Ok(())
} }
@ -528,8 +528,13 @@ impl Server {
} }
} }
// Send out the `UpdateContacts` message before responding to the unregister
// request. This way, when the project's host can keep track of the project's
// remote id until after they've received the `UpdateContacts` message for
// themself.
self.update_user_contacts(user_id).await?; self.update_user_contacts(user_id).await?;
response.send(proto::Ack {})?; response.send(proto::Ack {})?;
Ok(()) Ok(())
} }