proto: Remove GetPrivateUserInfo
message (#36265)
This PR removes the `GetPrivateUserInfo` RPC message. We're no longer using the message after https://github.com/zed-industries/zed/pull/36255. Release Notes: - N/A
This commit is contained in:
parent
e452aba9da
commit
bd1fda6782
5 changed files with 21 additions and 86 deletions
|
@ -1,16 +1,12 @@
|
||||||
use crate::{Client, Connection, Credentials, EstablishConnectionError, UserStore};
|
use crate::{Client, Connection, Credentials, EstablishConnectionError, UserStore};
|
||||||
use anyhow::{Context as _, Result, anyhow};
|
use anyhow::{Context as _, Result, anyhow};
|
||||||
use chrono::Duration;
|
|
||||||
use cloud_api_client::{AuthenticatedUser, GetAuthenticatedUserResponse, PlanInfo};
|
use cloud_api_client::{AuthenticatedUser, GetAuthenticatedUserResponse, PlanInfo};
|
||||||
use cloud_llm_client::{CurrentUsage, Plan, UsageData, UsageLimit};
|
use cloud_llm_client::{CurrentUsage, Plan, UsageData, UsageLimit};
|
||||||
use futures::{StreamExt, stream::BoxStream};
|
use futures::{StreamExt, stream::BoxStream};
|
||||||
use gpui::{AppContext as _, BackgroundExecutor, Entity, TestAppContext};
|
use gpui::{AppContext as _, BackgroundExecutor, Entity, TestAppContext};
|
||||||
use http_client::{AsyncBody, Method, Request, http};
|
use http_client::{AsyncBody, Method, Request, http};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use rpc::{
|
use rpc::{ConnectionId, Peer, Receipt, TypedEnvelope, proto};
|
||||||
ConnectionId, Peer, Receipt, TypedEnvelope,
|
|
||||||
proto::{self, GetPrivateUserInfo, GetPrivateUserInfoResponse},
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct FakeServer {
|
pub struct FakeServer {
|
||||||
|
@ -187,50 +183,27 @@ impl FakeServer {
|
||||||
pub async fn receive<M: proto::EnvelopedMessage>(&self) -> Result<TypedEnvelope<M>> {
|
pub async fn receive<M: proto::EnvelopedMessage>(&self) -> Result<TypedEnvelope<M>> {
|
||||||
self.executor.start_waiting();
|
self.executor.start_waiting();
|
||||||
|
|
||||||
loop {
|
let message = self
|
||||||
let message = self
|
.state
|
||||||
.state
|
.lock()
|
||||||
.lock()
|
.incoming
|
||||||
.incoming
|
.as_mut()
|
||||||
.as_mut()
|
.expect("not connected")
|
||||||
.expect("not connected")
|
.next()
|
||||||
.next()
|
.await
|
||||||
.await
|
.context("other half hung up")?;
|
||||||
.context("other half hung up")?;
|
self.executor.finish_waiting();
|
||||||
self.executor.finish_waiting();
|
let type_name = message.payload_type_name();
|
||||||
let type_name = message.payload_type_name();
|
let message = message.into_any();
|
||||||
let message = message.into_any();
|
|
||||||
|
|
||||||
if message.is::<TypedEnvelope<M>>() {
|
if message.is::<TypedEnvelope<M>>() {
|
||||||
return Ok(*message.downcast().unwrap());
|
return Ok(*message.downcast().unwrap());
|
||||||
}
|
|
||||||
|
|
||||||
let accepted_tos_at = chrono::Utc::now()
|
|
||||||
.checked_sub_signed(Duration::hours(5))
|
|
||||||
.expect("failed to build accepted_tos_at")
|
|
||||||
.timestamp() as u64;
|
|
||||||
|
|
||||||
if message.is::<TypedEnvelope<GetPrivateUserInfo>>() {
|
|
||||||
self.respond(
|
|
||||||
message
|
|
||||||
.downcast::<TypedEnvelope<GetPrivateUserInfo>>()
|
|
||||||
.unwrap()
|
|
||||||
.receipt(),
|
|
||||||
GetPrivateUserInfoResponse {
|
|
||||||
metrics_id: "the-metrics-id".into(),
|
|
||||||
staff: false,
|
|
||||||
flags: Default::default(),
|
|
||||||
accepted_tos_at: Some(accepted_tos_at),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
panic!(
|
|
||||||
"fake server received unexpected message type: {:?}",
|
|
||||||
type_name
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic!(
|
||||||
|
"fake server received unexpected message type: {:?}",
|
||||||
|
type_name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn respond<T: proto::RequestMessage>(&self, receipt: Receipt<T>, response: T::Response) {
|
pub fn respond<T: proto::RequestMessage>(&self, receipt: Receipt<T>, response: T::Response) {
|
||||||
|
|
|
@ -462,7 +462,6 @@ impl Server {
|
||||||
.add_request_handler(follow)
|
.add_request_handler(follow)
|
||||||
.add_message_handler(unfollow)
|
.add_message_handler(unfollow)
|
||||||
.add_message_handler(update_followers)
|
.add_message_handler(update_followers)
|
||||||
.add_request_handler(get_private_user_info)
|
|
||||||
.add_request_handler(accept_terms_of_service)
|
.add_request_handler(accept_terms_of_service)
|
||||||
.add_message_handler(acknowledge_channel_message)
|
.add_message_handler(acknowledge_channel_message)
|
||||||
.add_message_handler(acknowledge_buffer_version)
|
.add_message_handler(acknowledge_buffer_version)
|
||||||
|
@ -4209,30 +4208,6 @@ async fn mark_notification_as_read(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current users information
|
|
||||||
async fn get_private_user_info(
|
|
||||||
_request: proto::GetPrivateUserInfo,
|
|
||||||
response: Response<proto::GetPrivateUserInfo>,
|
|
||||||
session: MessageContext,
|
|
||||||
) -> Result<()> {
|
|
||||||
let db = session.db().await;
|
|
||||||
|
|
||||||
let metrics_id = db.get_user_metrics_id(session.user_id()).await?;
|
|
||||||
let user = db
|
|
||||||
.get_user_by_id(session.user_id())
|
|
||||||
.await?
|
|
||||||
.context("user not found")?;
|
|
||||||
let flags = db.get_user_flags(session.user_id()).await?;
|
|
||||||
|
|
||||||
response.send(proto::GetPrivateUserInfoResponse {
|
|
||||||
metrics_id,
|
|
||||||
staff: user.admin,
|
|
||||||
flags,
|
|
||||||
accepted_tos_at: user.accepted_tos_at.map(|t| t.and_utc().timestamp() as u64),
|
|
||||||
})?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Accept the terms of service (tos) on behalf of the current user
|
/// Accept the terms of service (tos) on behalf of the current user
|
||||||
async fn accept_terms_of_service(
|
async fn accept_terms_of_service(
|
||||||
_request: proto::AcceptTermsOfService,
|
_request: proto::AcceptTermsOfService,
|
||||||
|
|
|
@ -6,15 +6,6 @@ message UpdateInviteInfo {
|
||||||
uint32 count = 2;
|
uint32 count = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetPrivateUserInfo {}
|
|
||||||
|
|
||||||
message GetPrivateUserInfoResponse {
|
|
||||||
string metrics_id = 1;
|
|
||||||
bool staff = 2;
|
|
||||||
repeated string flags = 3;
|
|
||||||
optional uint64 accepted_tos_at = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Plan {
|
enum Plan {
|
||||||
Free = 0;
|
Free = 0;
|
||||||
ZedPro = 1;
|
ZedPro = 1;
|
||||||
|
|
|
@ -135,8 +135,6 @@ message Envelope {
|
||||||
FollowResponse follow_response = 99;
|
FollowResponse follow_response = 99;
|
||||||
UpdateFollowers update_followers = 100;
|
UpdateFollowers update_followers = 100;
|
||||||
Unfollow unfollow = 101;
|
Unfollow unfollow = 101;
|
||||||
GetPrivateUserInfo get_private_user_info = 102;
|
|
||||||
GetPrivateUserInfoResponse get_private_user_info_response = 103;
|
|
||||||
UpdateUserPlan update_user_plan = 234;
|
UpdateUserPlan update_user_plan = 234;
|
||||||
UpdateDiffBases update_diff_bases = 104;
|
UpdateDiffBases update_diff_bases = 104;
|
||||||
AcceptTermsOfService accept_terms_of_service = 239;
|
AcceptTermsOfService accept_terms_of_service = 239;
|
||||||
|
@ -402,6 +400,7 @@ message Envelope {
|
||||||
}
|
}
|
||||||
|
|
||||||
reserved 87 to 88;
|
reserved 87 to 88;
|
||||||
|
reserved 102 to 103;
|
||||||
reserved 158 to 161;
|
reserved 158 to 161;
|
||||||
reserved 164;
|
reserved 164;
|
||||||
reserved 166 to 169;
|
reserved 166 to 169;
|
||||||
|
|
|
@ -105,8 +105,6 @@ messages!(
|
||||||
(GetPathMetadataResponse, Background),
|
(GetPathMetadataResponse, Background),
|
||||||
(GetPermalinkToLine, Foreground),
|
(GetPermalinkToLine, Foreground),
|
||||||
(GetPermalinkToLineResponse, Foreground),
|
(GetPermalinkToLineResponse, Foreground),
|
||||||
(GetPrivateUserInfo, Foreground),
|
|
||||||
(GetPrivateUserInfoResponse, Foreground),
|
|
||||||
(GetProjectSymbols, Background),
|
(GetProjectSymbols, Background),
|
||||||
(GetProjectSymbolsResponse, Background),
|
(GetProjectSymbolsResponse, Background),
|
||||||
(GetReferences, Background),
|
(GetReferences, Background),
|
||||||
|
@ -352,7 +350,6 @@ request_messages!(
|
||||||
(GetDocumentSymbols, GetDocumentSymbolsResponse),
|
(GetDocumentSymbols, GetDocumentSymbolsResponse),
|
||||||
(GetHover, GetHoverResponse),
|
(GetHover, GetHoverResponse),
|
||||||
(GetNotifications, GetNotificationsResponse),
|
(GetNotifications, GetNotificationsResponse),
|
||||||
(GetPrivateUserInfo, GetPrivateUserInfoResponse),
|
|
||||||
(GetProjectSymbols, GetProjectSymbolsResponse),
|
(GetProjectSymbols, GetProjectSymbolsResponse),
|
||||||
(GetReferences, GetReferencesResponse),
|
(GetReferences, GetReferencesResponse),
|
||||||
(GetSignatureHelp, GetSignatureHelpResponse),
|
(GetSignatureHelp, GetSignatureHelpResponse),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue