chore: Clean up various mini things

This commit is contained in:
Flix
2022-08-22 22:18:50 +02:00
parent a368caf2b0
commit 8b5368ff06
5 changed files with 22 additions and 16 deletions

View File

@@ -239,7 +239,7 @@ impl BaseClient {
}
#[cfg(feature = "e2e-encryption")]
async fn handle_unenecrypted_verification_event(
async fn handle_unencrypted_verification_event(
&self,
event: &AnySyncMessageLikeEvent,
room_id: &RoomId,
@@ -353,12 +353,12 @@ impl BaseClient {
ruma::events::room::message::MessageType::VerificationRequest(
_,
) => {
self.handle_unenecrypted_verification_event(e, room_id).await?;
self.handle_unencrypted_verification_event(e, room_id).await?;
}
_ => (),
},
_ if e.event_type().to_string().starts_with("m.key.verification") => {
self.handle_unenecrypted_verification_event(e, room_id).await?;
self.handle_unencrypted_verification_event(e, room_id).await?;
}
_ => (),
},

View File

@@ -258,31 +258,31 @@ impl MemoryStore {
MembershipState::Join => {
self.stripped_joined_user_ids
.entry(room.clone())
.or_insert_with(DashSet::new)
.or_default()
.insert(event.state_key.clone());
self.stripped_invited_user_ids
.entry(room.clone())
.or_insert_with(DashSet::new)
.or_default()
.remove(&event.state_key);
}
MembershipState::Invite => {
self.stripped_invited_user_ids
.entry(room.clone())
.or_insert_with(DashSet::new)
.or_default()
.insert(event.state_key.clone());
self.stripped_joined_user_ids
.entry(room.clone())
.or_insert_with(DashSet::new)
.or_default()
.remove(&event.state_key);
}
_ => {
self.stripped_joined_user_ids
.entry(room.clone())
.or_insert_with(DashSet::new)
.or_default()
.remove(&event.state_key);
self.stripped_invited_user_ids
.entry(room.clone())
.or_insert_with(DashSet::new)
.or_default()
.remove(&event.state_key);
}
}

View File

@@ -152,8 +152,8 @@ pub(crate) struct ClientInner {
/// flight per room.
#[cfg(feature = "e2e-encryption")]
pub(crate) group_session_locks: DashMap<OwnedRoomId, Arc<Mutex<()>>>,
#[cfg(feature = "e2e-encryption")]
/// Lock making sure we're only doing one key claim request at a time.
#[cfg(feature = "e2e-encryption")]
pub(crate) key_claim_lock: Mutex<()>,
pub(crate) members_request_locks: DashMap<OwnedRoomId, Arc<Mutex<()>>>,
pub(crate) typing_notice_times: DashMap<OwnedRoomId, Instant>,
@@ -256,8 +256,8 @@ impl Client {
/// * `transaction_id` - The id of the transaction, used to guard against
/// the same transaction being sent twice. This guarding currently isn't
/// implemented.
/// * `incoming_transaction` - The sync response converted from a
/// transaction received from the homeserver.
/// * `sync_response` - The sync response converted from a transaction
/// received from the homeserver.
///
/// [transaction]: https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid
#[cfg(feature = "appservice")]
@@ -590,6 +590,12 @@ impl Client {
/// // You can omit any or all arguments after the first.
/// });
///
/// // Registering a temporary event handler:
/// let handle = client.add_event_handler(|ev: SyncRoomMessageEvent| async move {
/// /* Event handler */
/// });
/// client.remove_event_handler(handle);
///
/// // Custom events work exactly the same way, you just need to declare
/// // the content struct and use the EventContent derive macro on it.
/// #[derive(Clone, Debug, Deserialize, Serialize, EventContent)]

View File

@@ -388,7 +388,7 @@ impl Client {
None => (HandlerKind::MessageLike, HandlerKind::message_like_redacted(redacted)),
};
let raw_event = &item.event.json();
let raw_event = item.event.json();
let encryption_info = item.encryption_info.as_ref();
// Event handlers for possibly-redacted timeline events

View File

@@ -108,7 +108,7 @@ impl Common {
///
/// Returns a [`Result`] containing an instance of [`Left`] if successful.
///
/// Only invited and joined rooms can be left
/// Only invited and joined rooms can be left.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/docs/sync_running.md"))]
pub(crate) async fn leave(&self) -> Result<Left> {
let request = leave_room::v3::Request::new(self.inner.room_id());
@@ -153,14 +153,14 @@ impl Common {
let option = TryStreamExt::try_next(&mut rx).await?;
Ok(option.expect("receive joined room result from event handler"))
Ok(option.expect("receive left room result from event handler"))
}
/// Join this room.
///
/// Returns a [`Result`] containing an instance of [`Joined`][room::Joined]
/// if successful.
/// Only invited and left rooms can be joined via this method
/// Only invited and left rooms can be joined via this method.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/docs/sync_running.md"))]
pub(crate) async fn join(&self) -> Result<Joined> {
self.client.join_room_by_id(self.room_id()).await