service/sending: tiny refactors, NFC

This commit is contained in:
Lambda 2025-02-09 17:55:17 +00:00 committed by Charles Hall
parent d9c7fbbd82
commit 81c5f09919
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF

View file

@ -576,12 +576,17 @@ impl Service {
) -> Result<()> { ) -> Result<()> {
let destination = Destination::Push(user.to_owned(), pushkey); let destination = Destination::Push(user.to_owned(), pushkey);
let event_type = SendingEventType::Pdu(pdu_id.to_owned()); let event_type = SendingEventType::Pdu(pdu_id.to_owned());
let keys = self.db.queue_requests(&[(&destination, &event_type)])?; let key = self
.db
.queue_requests(&[(&destination, &event_type)])?
.into_iter()
.next()
.unwrap();
self.sender self.sender
.send(RequestData { .send(RequestData {
destination, destination,
event_type, event_type,
key: keys.into_iter().next().unwrap(), key,
requester_span: Span::current(), requester_span: Span::current(),
}) })
.unwrap(); .unwrap();
@ -630,12 +635,17 @@ impl Service {
) -> Result<()> { ) -> Result<()> {
let destination = Destination::Normal(server.to_owned()); let destination = Destination::Normal(server.to_owned());
let event_type = SendingEventType::Edu(serialized); let event_type = SendingEventType::Edu(serialized);
let keys = self.db.queue_requests(&[(&destination, &event_type)])?; let key = self
.db
.queue_requests(&[(&destination, &event_type)])?
.into_iter()
.next()
.unwrap();
self.sender self.sender
.send(RequestData { .send(RequestData {
destination, destination,
event_type, event_type,
key: keys.into_iter().next().unwrap(), key,
requester_span: Span::current(), requester_span: Span::current(),
}) })
.unwrap(); .unwrap();
@ -651,12 +661,17 @@ impl Service {
) -> Result<()> { ) -> Result<()> {
let destination = Destination::Appservice(appservice_id); let destination = Destination::Appservice(appservice_id);
let event_type = SendingEventType::Pdu(pdu_id); let event_type = SendingEventType::Pdu(pdu_id);
let keys = self.db.queue_requests(&[(&destination, &event_type)])?; let key = self
.db
.queue_requests(&[(&destination, &event_type)])?
.into_iter()
.next()
.unwrap();
self.sender self.sender
.send(RequestData { .send(RequestData {
destination, destination,
event_type, event_type,
key: keys.into_iter().next().unwrap(), key,
requester_span: Span::current(), requester_span: Span::current(),
}) })
.unwrap(); .unwrap();