improvement: upgrade ruma and implement blurhashes
This commit is contained in:
parent
0fcefa4125
commit
f5273f7eb1
22 changed files with 98 additions and 30 deletions
|
@ -283,6 +283,7 @@ pub async fn register_route(
|
|||
avatar_url: None,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: None,
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
|
@ -446,6 +447,7 @@ pub async fn register_route(
|
|||
avatar_url: None,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: None,
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
|
@ -466,6 +468,7 @@ pub async fn register_route(
|
|||
avatar_url: None,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: None,
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
|
@ -578,7 +581,7 @@ pub async fn change_password_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(change_password::Response.into())
|
||||
Ok(change_password::Response {}.into())
|
||||
}
|
||||
|
||||
/// # `GET _matrix/client/r0/account/whoami`
|
||||
|
@ -664,6 +667,7 @@ pub async fn deactivate_route(
|
|||
avatar_url: None,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: None,
|
||||
};
|
||||
|
||||
let mutex = Arc::clone(
|
||||
|
|
|
@ -46,7 +46,7 @@ pub async fn update_backup_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(update_backup::Response.into())
|
||||
Ok(update_backup::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -119,7 +119,7 @@ pub async fn delete_backup_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(delete_backup::Response.into())
|
||||
Ok(delete_backup::Response {}.into())
|
||||
}
|
||||
|
||||
/// Add the received backup keys to the database.
|
||||
|
|
|
@ -45,7 +45,7 @@ pub async fn set_global_account_data_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_global_account_data::Response.into())
|
||||
Ok(set_global_account_data::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -80,7 +80,7 @@ pub async fn set_room_account_data_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_room_account_data::Response.into())
|
||||
Ok(set_room_account_data::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
|
@ -73,7 +73,7 @@ pub async fn update_device_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(update_device::Response.into())
|
||||
Ok(update_device::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -125,7 +125,7 @@ pub async fn delete_device_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(delete_device::Response.into())
|
||||
Ok(delete_device::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -179,5 +179,5 @@ pub async fn delete_devices_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(delete_devices::Response.into())
|
||||
Ok(delete_devices::Response {}.into())
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ pub async fn set_room_visibility_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_room_visibility::Response.into())
|
||||
Ok(set_room_visibility::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
|
@ -163,7 +163,7 @@ pub async fn upload_signing_keys_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(upload_signing_keys::Response.into())
|
||||
Ok(upload_signing_keys::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -224,7 +224,7 @@ pub async fn upload_signatures_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(upload_signatures::Response.into())
|
||||
Ok(upload_signatures::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
|
@ -165,7 +165,7 @@ pub async fn invite_user_route(
|
|||
if let invite_user::IncomingInvitationRecipient::UserId { user_id } = &body.recipient {
|
||||
invite_helper(sender_user, user_id, &body.room_id, &db, false).await?;
|
||||
db.flush().await?;
|
||||
Ok(invite_user::Response.into())
|
||||
Ok(invite_user::Response {}.into())
|
||||
} else {
|
||||
Err(Error::BadRequest(ErrorKind::NotFound, "User not found."))
|
||||
}
|
||||
|
@ -261,6 +261,7 @@ pub async fn ban_user_route(
|
|||
avatar_url: db.users.avatar_url(&body.user_id)?,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: db.users.blurhash(&body.user_id)?,
|
||||
}),
|
||||
|event| {
|
||||
let mut event = serde_json::from_value::<Raw<member::MemberEventContent>>(
|
||||
|
@ -556,6 +557,7 @@ async fn join_room_by_id_helper(
|
|||
avatar_url: db.users.avatar_url(&sender_user)?,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: db.users.blurhash(&sender_user)?,
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
);
|
||||
|
@ -685,6 +687,7 @@ async fn join_room_by_id_helper(
|
|||
avatar_url: db.users.avatar_url(&sender_user)?,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: db.users.blurhash(&sender_user)?,
|
||||
};
|
||||
|
||||
db.rooms.build_and_append_pdu(
|
||||
|
@ -833,6 +836,7 @@ pub async fn invite_helper<'a>(
|
|||
is_direct: Some(is_direct),
|
||||
membership: MembershipState::Invite,
|
||||
third_party_invite: None,
|
||||
blurhash: db.users.blurhash(&sender_user)?,
|
||||
})
|
||||
.expect("member event is valid value");
|
||||
|
||||
|
@ -1008,6 +1012,7 @@ pub async fn invite_helper<'a>(
|
|||
avatar_url: db.users.avatar_url(&user_id)?,
|
||||
is_direct: Some(is_direct),
|
||||
third_party_invite: None,
|
||||
blurhash: db.users.blurhash(&sender_user)?,
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
|
|
|
@ -75,5 +75,5 @@ pub const SESSION_ID_LENGTH: usize = 256;
|
|||
#[options("/<_..>")]
|
||||
#[tracing::instrument]
|
||||
pub async fn options_route() -> ConduitResult<send_event_to_device::Response> {
|
||||
Ok(send_event_to_device::Response.into())
|
||||
Ok(send_event_to_device::Response {}.into())
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ pub async fn set_presence_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_presence::Response.into())
|
||||
Ok(set_presence::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
|
@ -108,7 +108,7 @@ pub async fn set_displayname_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_display_name::Response.into())
|
||||
Ok(set_display_name::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -140,6 +140,8 @@ pub async fn set_avatar_url_route(
|
|||
db.users
|
||||
.set_avatar_url(&sender_user, body.avatar_url.clone())?;
|
||||
|
||||
db.users.set_blurhash(&sender_user, body.blurhash.clone())?;
|
||||
|
||||
// Send a new membership event and presence update into all joined rooms
|
||||
for (pdu_builder, room_id) in db
|
||||
.rooms
|
||||
|
@ -220,7 +222,7 @@ pub async fn set_avatar_url_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_avatar_url::Response.into())
|
||||
Ok(set_avatar_url::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -234,6 +236,7 @@ pub async fn get_avatar_url_route(
|
|||
) -> ConduitResult<get_avatar_url::Response> {
|
||||
Ok(get_avatar_url::Response {
|
||||
avatar_url: db.users.avatar_url(&body.user_id)?,
|
||||
blurhash: db.users.blurhash(&body.user_id)?,
|
||||
}
|
||||
.into())
|
||||
}
|
||||
|
@ -257,6 +260,7 @@ pub async fn get_profile_route(
|
|||
|
||||
Ok(get_profile::Response {
|
||||
avatar_url: db.users.avatar_url(&body.user_id)?,
|
||||
blurhash: db.users.blurhash(&body.user_id)?,
|
||||
displayname: db.users.displayname(&body.user_id)?,
|
||||
}
|
||||
.into())
|
||||
|
|
|
@ -194,7 +194,7 @@ pub async fn set_pushrule_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_pushrule::Response.into())
|
||||
Ok(set_pushrule::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -327,7 +327,7 @@ pub async fn set_pushrule_actions_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_pushrule_actions::Response.into())
|
||||
Ok(set_pushrule_actions::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -467,7 +467,7 @@ pub async fn set_pushrule_enabled_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_pushrule_enabled::Response.into())
|
||||
Ok(set_pushrule_enabled::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -536,7 +536,7 @@ pub async fn delete_pushrule_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(delete_pushrule::Response.into())
|
||||
Ok(delete_pushrule::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
|
@ -77,7 +77,7 @@ pub async fn set_read_marker_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(set_read_marker::Response.into())
|
||||
Ok(set_read_marker::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -130,5 +130,5 @@ pub async fn create_receipt_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(create_receipt::Response.into())
|
||||
Ok(create_receipt::Response {}.into())
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ pub async fn create_room_route(
|
|||
avatar_url: db.users.avatar_url(&sender_user)?,
|
||||
is_direct: Some(body.is_direct),
|
||||
third_party_invite: None,
|
||||
blurhash: db.users.blurhash(&sender_user)?,
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
|
@ -444,6 +445,7 @@ pub async fn upgrade_room_route(
|
|||
avatar_url: db.users.avatar_url(&sender_user)?,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
blurhash: db.users.blurhash(&sender_user)?,
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
|
|
|
@ -753,6 +753,7 @@ async fn sync_helper(
|
|||
leave: left_rooms,
|
||||
join: joined_rooms,
|
||||
invite: invited_rooms,
|
||||
knock: BTreeMap::new(), // TODO
|
||||
},
|
||||
presence: sync_events::Presence {
|
||||
events: presence_updates
|
||||
|
|
|
@ -42,7 +42,7 @@ pub async fn update_tag_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(create_tag::Response.into())
|
||||
Ok(create_tag::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
@ -76,7 +76,7 @@ pub async fn delete_tag_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(delete_tag::Response.into())
|
||||
Ok(delete_tag::Response {}.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
|
@ -69,5 +69,5 @@ pub async fn send_event_to_device_route(
|
|||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(send_event_to_device::Response.into())
|
||||
Ok(send_event_to_device::Response {}.into())
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@ pub fn create_typing_event_route(
|
|||
.typing_remove(&sender_user, &body.room_id, &db.globals)?;
|
||||
}
|
||||
|
||||
Ok(create_typing_event::Response.into())
|
||||
Ok(create_typing_event::Response {}.into())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue