mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-26 18:37:35 +00:00
fix: Address review comments
This commit is contained in:
1 parent
6b532eb7d0
commit
62de19970e
13 files changed
+69
-48
No files matched your search
@@ -380,5 +380,6 @@ pub(crate) async fn is_ignored_invite(
|
||||
services
|
||||
.users
|
||||
.invite_filter_level(&sender_user, recipient_user)
|
||||
.await == FilterLevel::Ignore
|
||||
.await
|
||||
== FilterLevel::Ignore
|
||||
}
|
||||
@@ -305,8 +305,8 @@ pub(crate) async fn upgrade_room_route(
|
||||
return Err!(Request(Forbidden("Upgrading the admin room this way is not allowed.")));
|
||||
}
|
||||
|
||||
// 1. Check that the user has permission to send m.room.tombstone events in the
|
||||
// room.
|
||||
// 1. Check that the user has permission to send m.room.tombstone events in
|
||||
// the room.
|
||||
let old_room_state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
|
||||
|
||||
// Check tombstone permission by attempting to create (but not send) the
|
||||
@@ -556,8 +556,8 @@ pub(crate) async fn upgrade_room_route(
|
||||
)?;
|
||||
}
|
||||
|
||||
// 5. Send a `m.room.tombstone` event to the old room to indicate that it is not
|
||||
// intended to be used any further.
|
||||
// 5. Send a `m.room.tombstone` event to the old room to indicate that it is
|
||||
// not intended to be used any further.
|
||||
debug!(target=?body.room_id, "Sending tombstone to old room");
|
||||
services
|
||||
.rooms
|
||||
@@ -598,7 +598,8 @@ pub(crate) async fn upgrade_room_route(
|
||||
power_levels.events_default = new_level;
|
||||
power_levels.invite = new_level;
|
||||
|
||||
// 6. Modify the power levels in the old room to prevent sending of events and
|
||||
// 6. Modify the power levels in the old room to prevent sending of events
|
||||
// and
|
||||
// inviting new users
|
||||
// Spec dictates that this is allowed to fail.
|
||||
debug!(target=?body.room_id, ?new_level, "Raising power level in old room to lock it");
|
||||
|
||||
@@ -74,8 +74,8 @@ pub(super) async fn load_left_room(
|
||||
|
||||
// return early if:
|
||||
// - this is an initial sync and the room filter doesn't include leaves, or
|
||||
// - this is an incremental sync, and we've already synced the leave, and the
|
||||
// room filter doesn't include leaves
|
||||
// - this is an incremental sync, and we've already synced the leave, and
|
||||
// the room filter doesn't include leaves
|
||||
if last_sync_end_count.is_none_or(|last_sync_end_count| last_sync_end_count >= left_count)
|
||||
&& !filter.room.include_leave
|
||||
{
|
||||
|
||||
@@ -726,7 +726,8 @@ async fn stripped_state_event(
|
||||
.get_field::<StateEventType>("type")
|
||||
.ok()
|
||||
.flatten()
|
||||
.as_ref() == Some(event_type)
|
||||
.as_ref()
|
||||
== Some(event_type)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+20
-13
@@ -143,6 +143,7 @@ async fn acquire_keys_as_notary(
|
||||
mut queries: BTreeMap<OwnedServerSigningKeyId, QueryCriteria>,
|
||||
start: MilliSecondsSinceUnixEpoch,
|
||||
) -> Vec<Raw<ServerSigningKeys>> {
|
||||
let fetch_all = queries.is_empty();
|
||||
let mut results = Vec::with_capacity(queries.len().max(1));
|
||||
let mut keymap = HashMap::with_capacity(queries.len().max(1));
|
||||
|
||||
@@ -155,12 +156,11 @@ async fn acquire_keys_as_notary(
|
||||
let index = results.len();
|
||||
results.push(ssk);
|
||||
for key_id in res.verify_keys.keys().chain(res.old_verify_keys.keys()) {
|
||||
if queries.is_empty()
|
||||
|| queries
|
||||
.get(key_id)
|
||||
.and_then(|c| c.minimum_valid_until_ts)
|
||||
.is_none_or(|m| res.valid_until_ts >= m)
|
||||
{
|
||||
if fetch_all
|
||||
|| queries.get(key_id).is_some_and(|c| {
|
||||
c.minimum_valid_until_ts
|
||||
.is_none_or(|m| res.valid_until_ts >= m)
|
||||
}) {
|
||||
queries.remove(key_id);
|
||||
keymap.insert(key_id.to_owned(), index);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ async fn acquire_keys_as_notary(
|
||||
debug!("Not asking remote for keys (already asked recently)");
|
||||
}
|
||||
debug!(keys=?keymap.keys(), "Live verify keys");
|
||||
if queries.is_empty() && keymap.is_empty() {
|
||||
if fetch_all && keymap.is_empty() {
|
||||
// If the server asked for all keys, AND we didn't get anything from the
|
||||
// origin, just fetch any fresh responses we have.
|
||||
server_keys
|
||||
@@ -228,14 +228,20 @@ async fn acquire_keys_as_notary(
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if let Some(old_verify_key) = ssk.old_verify_keys.get(&key_id) {
|
||||
if old_verify_key.expired_ts < minimum_valid_until_ts {
|
||||
debug!(
|
||||
%key_id,
|
||||
expired_ts=?old_verify_key.expired_ts,
|
||||
?minimum_valid_until_ts,
|
||||
"Stored old verify key does not satisfy query criteria"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
debug!(%key_id, ?ssk, "Found key locally");
|
||||
let rep_key_ids = ssk
|
||||
.verify_keys
|
||||
.keys()
|
||||
.chain(ssk.old_verify_keys.keys())
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
let rep_key_ids = ssk.verify_keys.keys().cloned().collect::<Vec<_>>();
|
||||
let Ok(signed_ssk) = sign_ssk(&server_keys, ssk.clone(), &remote, &my_name)
|
||||
.await
|
||||
.inspect_err(
|
||||
@@ -247,6 +253,7 @@ async fn acquire_keys_as_notary(
|
||||
|
||||
let idx = results.len();
|
||||
results.push(signed_ssk);
|
||||
keymap.insert(key_id, idx);
|
||||
for key_id in rep_key_ids {
|
||||
keymap.insert(key_id, idx);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user