mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
Add PduId wrapper struct
Death to Vec<u8>
This commit is contained in:
parent
341f4213d0
commit
26322d5a95
15 changed files with 110 additions and 71 deletions
|
|
@ -37,6 +37,7 @@ use tokio::{
|
|||
};
|
||||
use tracing::{debug, error, warn, Span};
|
||||
|
||||
use super::rooms::timeline::PduId;
|
||||
use crate::{
|
||||
api::{appservice_server, server_server},
|
||||
services,
|
||||
|
|
@ -83,7 +84,7 @@ impl Destination {
|
|||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub(crate) enum SendingEventType {
|
||||
// pduid
|
||||
Pdu(Vec<u8>),
|
||||
Pdu(PduId),
|
||||
// pdu json
|
||||
Edu(Vec<u8>),
|
||||
}
|
||||
|
|
@ -565,7 +566,7 @@ impl Service {
|
|||
#[tracing::instrument(skip(self, pdu_id, user, pushkey))]
|
||||
pub(crate) fn send_push_pdu(
|
||||
&self,
|
||||
pdu_id: &[u8],
|
||||
pdu_id: &PduId,
|
||||
user: &UserId,
|
||||
pushkey: String,
|
||||
) -> Result<()> {
|
||||
|
|
@ -589,7 +590,7 @@ impl Service {
|
|||
pub(crate) fn send_pdu<I: Iterator<Item = OwnedServerName>>(
|
||||
&self,
|
||||
servers: I,
|
||||
pdu_id: &[u8],
|
||||
pdu_id: &PduId,
|
||||
) -> Result<()> {
|
||||
let requests = servers
|
||||
.into_iter()
|
||||
|
|
@ -644,7 +645,7 @@ impl Service {
|
|||
pub(crate) fn send_pdu_appservice(
|
||||
&self,
|
||||
appservice_id: String,
|
||||
pdu_id: Vec<u8>,
|
||||
pdu_id: PduId,
|
||||
) -> Result<()> {
|
||||
let destination = Destination::Appservice(appservice_id);
|
||||
let event_type = SendingEventType::Pdu(pdu_id);
|
||||
|
|
@ -758,8 +759,8 @@ async fn handle_appservice_event(
|
|||
&events
|
||||
.iter()
|
||||
.map(|e| match e {
|
||||
SendingEventType::Edu(b)
|
||||
| SendingEventType::Pdu(b) => &**b,
|
||||
SendingEventType::Edu(b) => &**b,
|
||||
SendingEventType::Pdu(b) => b.as_bytes(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
|
|
@ -905,8 +906,8 @@ async fn handle_federation_event(
|
|||
&events
|
||||
.iter()
|
||||
.map(|e| match e {
|
||||
SendingEventType::Edu(b)
|
||||
| SendingEventType::Pdu(b) => &**b,
|
||||
SendingEventType::Edu(b) => &**b,
|
||||
SendingEventType::Pdu(b) => b.as_bytes(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue