Add the ability to notify when a user accepts a contact request

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-05-11 18:51:40 +02:00
parent 933a1f2cd6
commit a5fd664b00
3 changed files with 316 additions and 150 deletions

View file

@ -217,23 +217,30 @@ impl Store {
.is_empty()
}
pub fn build_initial_contacts_update(&self, contacts: db::Contacts) -> proto::UpdateContacts {
pub fn build_initial_contacts_update(
&self,
contacts: Vec<db::Contact>,
) -> proto::UpdateContacts {
let mut update = proto::UpdateContacts::default();
for user_id in contacts.current {
update.contacts.push(self.contact_for_user(user_id));
}
for request in contacts.incoming_requests {
update
.incoming_requests
.push(proto::IncomingContactRequest {
requester_id: request.requester_id.to_proto(),
should_notify: request.should_notify,
})
}
for requested_user_id in contacts.outgoing_requests {
update.outgoing_requests.push(requested_user_id.to_proto())
for contact in contacts {
match contact {
db::Contact::Accepted { user_id, .. } => {
update.contacts.push(self.contact_for_user(user_id));
}
db::Contact::Outgoing { user_id } => {
update.outgoing_requests.push(user_id.to_proto())
}
db::Contact::Incoming {
user_id,
should_notify,
} => update
.incoming_requests
.push(proto::IncomingContactRequest {
requester_id: user_id.to_proto(),
should_notify,
}),
}
}
update