@ -11,7 +11,8 @@ use ruma::{
federation ::{
federation ::{
directory ::{ get_public_rooms , get_public_rooms_filtered } ,
directory ::{ get_public_rooms , get_public_rooms_filtered } ,
discovery ::{
discovery ::{
get_server_keys , get_server_version ::v1 as get_server_version , ServerKey , VerifyKey ,
get_server_keys , get_server_version ::v1 as get_server_version , ServerSigningKeys ,
VerifyKey ,
} ,
} ,
event ::get_missing_events ,
event ::get_missing_events ,
query ::get_profile_information ,
query ::get_profile_information ,
@ -20,11 +21,11 @@ use ruma::{
OutgoingRequest ,
OutgoingRequest ,
} ,
} ,
directory ::{ IncomingFilter , IncomingRoomNetwork } ,
directory ::{ IncomingFilter , IncomingRoomNetwork } ,
EventId , RoomId , ServerName , UserId,
EventId , RoomId , ServerName , ServerSigningKeyId, UserId,
} ;
} ;
use std ::{
use std ::{
collections ::BTreeMap ,
collections ::BTreeMap ,
convert ::{ TryFrom , TryInto } ,
convert ::TryFrom ,
fmt ::Debug ,
fmt ::Debug ,
sync ::Arc ,
sync ::Arc ,
time ::{ Duration , SystemTime } ,
time ::{ Duration , SystemTime } ,
@ -243,16 +244,17 @@ pub fn get_server_keys(db: State<'_, Database>) -> Json<String> {
let mut verify_keys = BTreeMap ::new ( ) ;
let mut verify_keys = BTreeMap ::new ( ) ;
verify_keys . insert (
verify_keys . insert (
format! ( "ed25519:{}" , db . globals . keypair ( ) . version ( ) )
ServerSigningKeyId ::try_from (
. try_into ( )
format! ( "ed25519:{}" , db . globals . keypair ( ) . version ( ) ) . as_str ( ) ,
. expect ( "DB stores valid ServerKeyId's" ) ,
)
. expect ( "found invalid server signing keys in DB" ) ,
VerifyKey {
VerifyKey {
key : base64 ::encode_config ( db . globals . keypair ( ) . public_key ( ) , base64 ::STANDARD_NO_PAD ) ,
key : base64 ::encode_config ( db . globals . keypair ( ) . public_key ( ) , base64 ::STANDARD_NO_PAD ) ,
} ,
} ,
) ;
) ;
let mut response = serde_json ::from_slice (
let mut response = serde_json ::from_slice (
http ::Response ::try_from ( get_server_keys ::v2 ::Response {
http ::Response ::try_from ( get_server_keys ::v2 ::Response {
server_key : Server Key {
server_key : Server Signing Keys {
server_name : db . globals . server_name ( ) . to_owned ( ) ,
server_name : db . globals . server_name ( ) . to_owned ( ) ,
verify_keys ,
verify_keys ,
old_verify_keys : BTreeMap ::new ( ) ,
old_verify_keys : BTreeMap ::new ( ) ,
@ -430,7 +432,7 @@ pub async fn send_transaction_message_route<'a>(
// would return a M_BAD_JSON error.
// would return a M_BAD_JSON error.
let mut resolved_map = BTreeMap ::new ( ) ;
let mut resolved_map = BTreeMap ::new ( ) ;
for pdu in & body . pdus {
for pdu in & body . pdus {
// Ruma/PduEvent/StateEvent sati fies - 1. Is a valid event, otherwise it is dropped.
// Ruma/PduEvent/StateEvent sati s fies - 1. Is a valid event, otherwise it is dropped.
// state-res checks signatures - 2. Passes signature checks, otherwise event is dropped.
// state-res checks signatures - 2. Passes signature checks, otherwise event is dropped.
@ -450,7 +452,7 @@ pub async fn send_transaction_message_route<'a>(
continue ;
continue ;
}
}
// If it is not a state event, we can skip state-res
// If it is not a state event, we can skip state-res ... maybe
if value . get ( "state_key" ) . is_none ( ) {
if value . get ( "state_key" ) . is_none ( ) {
if ! db . rooms . is_joined ( & pdu . sender , room_id ) ? {
if ! db . rooms . is_joined ( & pdu . sender , room_id ) ? {
warn ! ( "Sender is not joined {}" , pdu . kind ) ;
warn ! ( "Sender is not joined {}" , pdu . kind ) ;
@ -679,7 +681,9 @@ pub fn get_profile_information_route<'a>(
let mut displayname = None ;
let mut displayname = None ;
let mut avatar_url = None ;
let mut avatar_url = None ;
match body . field {
match & body . field {
// TODO: what to do with custom
Some ( ProfileField ::_Custom ( _s ) ) = > { }
Some ( ProfileField ::DisplayName ) = > displayname = db . users . displayname ( & body . user_id ) ? ,
Some ( ProfileField ::DisplayName ) = > displayname = db . users . displayname ( & body . user_id ) ? ,
Some ( ProfileField ::AvatarUrl ) = > avatar_url = db . users . avatar_url ( & body . user_id ) ? ,
Some ( ProfileField ::AvatarUrl ) = > avatar_url = db . users . avatar_url ( & body . user_id ) ? ,
None = > {
None = > {