1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-06-27 16:35:59 +00:00

refactor: set send_request matrix versions in a single constant

This commit is contained in:
Matthias Ahouansou 2025-03-08 13:19:45 +00:00
parent 42d8e88c74
commit 4dc15a4605
No known key found for this signature in database
4 changed files with 11 additions and 12 deletions

View file

@ -1,8 +1,6 @@
use crate::{services, utils, Error, Result}; use crate::{services, utils, Error, Result, MATRIX_VERSIONS};
use bytes::BytesMut; use bytes::BytesMut;
use ruma::api::{ use ruma::api::{appservice::Registration, IncomingResponse, OutgoingRequest, SendAccessToken};
appservice::Registration, IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
};
use std::{fmt::Debug, mem, time::Duration}; use std::{fmt::Debug, mem, time::Duration};
use tracing::warn; use tracing::warn;
@ -30,7 +28,7 @@ where
.try_into_http_request::<BytesMut>( .try_into_http_request::<BytesMut>(
&destination, &destination,
SendAccessToken::IfRequired(hs_token), SendAccessToken::IfRequired(hs_token),
&[MatrixVersion::V1_0], MATRIX_VERSIONS,
) )
.unwrap() .unwrap()
.map(|body| body.freeze()); .map(|body| body.freeze());

View file

@ -7,7 +7,7 @@ use crate::{
media::FileMeta, media::FileMeta,
pdu::{gen_event_id_canonical_json, PduBuilder}, pdu::{gen_event_id_canonical_json, PduBuilder},
}, },
services, utils, Error, PduEvent, Result, Ruma, services, utils, Error, PduEvent, Result, Ruma, MATRIX_VERSIONS,
}; };
use axum::{response::IntoResponse, Json}; use axum::{response::IntoResponse, Json};
use axum_extra::headers::{CacheControl, Header}; use axum_extra::headers::{CacheControl, Header};
@ -44,8 +44,7 @@ use ruma::{
send_transaction_message, send_transaction_message,
}, },
}, },
EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest, OutgoingResponse, EndpointError, IncomingResponse, OutgoingRequest, OutgoingResponse, SendAccessToken,
SendAccessToken,
}, },
directory::{Filter, RoomNetwork}, directory::{Filter, RoomNetwork},
events::{ events::{
@ -215,7 +214,7 @@ where
.try_into_http_request::<Vec<u8>>( .try_into_http_request::<Vec<u8>>(
&actual_destination_str, &actual_destination_str,
SendAccessToken::IfRequired(""), SendAccessToken::IfRequired(""),
&[MatrixVersion::V1_11], MATRIX_VERSIONS,
) )
.map_err(|e| { .map_err(|e| {
warn!( warn!(

View file

@ -13,10 +13,12 @@ use std::sync::RwLock;
pub use api::ruma_wrapper::{Ruma, RumaResponse}; pub use api::ruma_wrapper::{Ruma, RumaResponse};
pub use config::Config; pub use config::Config;
pub use database::KeyValueDatabase; pub use database::KeyValueDatabase;
use ruma::api::MatrixVersion;
pub use service::{pdu::PduEvent, Services}; pub use service::{pdu::PduEvent, Services};
pub use utils::error::{Error, Result}; pub use utils::error::{Error, Result};
pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None); pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None);
pub const MATRIX_VERSIONS: &[MatrixVersion] = &[MatrixVersion::V1_13];
pub fn services() -> &'static Services { pub fn services() -> &'static Services {
SERVICES SERVICES

View file

@ -2,7 +2,7 @@ mod data;
pub use data::Data; pub use data::Data;
use ruma::{events::AnySyncTimelineEvent, push::PushConditionPowerLevelsCtx}; use ruma::{events::AnySyncTimelineEvent, push::PushConditionPowerLevelsCtx};
use crate::{services, Error, PduEvent, Result}; use crate::{services, Error, PduEvent, Result, MATRIX_VERSIONS};
use bytes::BytesMut; use bytes::BytesMut;
use ruma::{ use ruma::{
api::{ api::{
@ -11,7 +11,7 @@ use ruma::{
self, self,
v1::{Device, Notification, NotificationCounts, NotificationPriority}, v1::{Device, Notification, NotificationCounts, NotificationPriority},
}, },
IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken, IncomingResponse, OutgoingRequest, SendAccessToken,
}, },
events::{room::power_levels::RoomPowerLevelsEventContent, StateEventType, TimelineEventType}, events::{room::power_levels::RoomPowerLevelsEventContent, StateEventType, TimelineEventType},
push::{Action, PushConditionRoomCtx, PushFormat, Ruleset, Tweak}, push::{Action, PushConditionRoomCtx, PushFormat, Ruleset, Tweak},
@ -58,7 +58,7 @@ impl Service {
.try_into_http_request::<BytesMut>( .try_into_http_request::<BytesMut>(
&destination, &destination,
SendAccessToken::IfRequired(""), SendAccessToken::IfRequired(""),
&[MatrixVersion::V1_0], MATRIX_VERSIONS,
) )
.map_err(|e| { .map_err(|e| {
warn!("Failed to find destination {}: {}", destination, e); warn!("Failed to find destination {}: {}", destination, e);