Add notifications for accepted contact requests
Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
a5fd664b00
commit
3bc9b8ec85
18 changed files with 301 additions and 253 deletions
|
@ -420,7 +420,7 @@ impl Server {
|
|||
async fn update_user_contacts(self: &Arc<Server>, user_id: UserId) -> Result<()> {
|
||||
let contacts = self.app_state.db.get_contacts(user_id).await?;
|
||||
let store = self.store().await;
|
||||
let updated_contact = store.contact_for_user(user_id);
|
||||
let updated_contact = store.contact_for_user(user_id, false);
|
||||
for contact in contacts {
|
||||
if let db::Contact::Accepted {
|
||||
user_id: contact_user_id,
|
||||
|
@ -1049,7 +1049,9 @@ impl Server {
|
|||
// Update responder with new contact
|
||||
let mut update = proto::UpdateContacts::default();
|
||||
if accept {
|
||||
update.contacts.push(store.contact_for_user(requester_id));
|
||||
update
|
||||
.contacts
|
||||
.push(store.contact_for_user(requester_id, false));
|
||||
}
|
||||
update
|
||||
.remove_incoming_requests
|
||||
|
@ -1061,7 +1063,9 @@ impl Server {
|
|||
// Update requester with new contact
|
||||
let mut update = proto::UpdateContacts::default();
|
||||
if accept {
|
||||
update.contacts.push(store.contact_for_user(responder_id));
|
||||
update
|
||||
.contacts
|
||||
.push(store.contact_for_user(responder_id, true));
|
||||
}
|
||||
update
|
||||
.remove_outgoing_requests
|
||||
|
|
|
@ -225,8 +225,13 @@ impl Store {
|
|||
|
||||
for contact in contacts {
|
||||
match contact {
|
||||
db::Contact::Accepted { user_id, .. } => {
|
||||
update.contacts.push(self.contact_for_user(user_id));
|
||||
db::Contact::Accepted {
|
||||
user_id,
|
||||
should_notify,
|
||||
} => {
|
||||
update
|
||||
.contacts
|
||||
.push(self.contact_for_user(user_id, should_notify));
|
||||
}
|
||||
db::Contact::Outgoing { user_id } => {
|
||||
update.outgoing_requests.push(user_id.to_proto())
|
||||
|
@ -246,11 +251,12 @@ impl Store {
|
|||
update
|
||||
}
|
||||
|
||||
pub fn contact_for_user(&self, user_id: UserId) -> proto::Contact {
|
||||
pub fn contact_for_user(&self, user_id: UserId, should_notify: bool) -> proto::Contact {
|
||||
proto::Contact {
|
||||
user_id: user_id.to_proto(),
|
||||
projects: self.project_metadata_for_user(user_id),
|
||||
online: self.is_user_online(user_id),
|
||||
should_notify,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue