mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 20:26:52 +00:00
fix: Make dedupe noisy, don't allow non-create event as create event
This commit is contained in:
1 parent
d1baaaab48
commit
6d606d9277
2 files changed
+14
-7
No files matched your search
@@ -133,7 +133,7 @@ impl super::Service {
|
||||
debug!(events = state_events.len(), "Processing state events");
|
||||
for (event_id, pdu) in state_events {
|
||||
let state_key = pdu.state_key().ok_or_else(|| {
|
||||
err!(Database("Found non-state pdu in state events: {event_id}"))
|
||||
err!(Request(BadJson("Found non-state pdu in state events: {event_id}")))
|
||||
})?;
|
||||
|
||||
let shortstatekey = self
|
||||
@@ -146,13 +146,14 @@ impl super::Service {
|
||||
| hash_map::Entry::Vacant(v) => {
|
||||
v.insert(pdu.event_id().to_owned());
|
||||
},
|
||||
| hash_map::Entry::Occupied(_) => {
|
||||
return Err!(Database(
|
||||
| hash_map::Entry::Occupied(existing) => {
|
||||
return Err!(Request(Forbidden(
|
||||
"State event's type and state_key combination exists multiple times \
|
||||
({event_id}): {}, {}",
|
||||
({event_id} + {}): ({}, \"{}\")",
|
||||
existing.get(),
|
||||
pdu.kind(),
|
||||
state_key
|
||||
));
|
||||
state_key,
|
||||
)));
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -165,7 +166,7 @@ impl super::Service {
|
||||
.await?;
|
||||
|
||||
if state.get(&create_shortstatekey).map(AsRef::as_ref) != Some(create_event.event_id()) {
|
||||
return Err!(Database("Incoming event refers to wrong create event."));
|
||||
return Err!(Request(Forbidden("Incoming event refers to wrong create event.")));
|
||||
}
|
||||
|
||||
Ok(Some(state))
|
||||
|
||||
@@ -57,6 +57,12 @@ impl super::Service {
|
||||
return Err!(Request(Forbidden("Event has been soft-failed")));
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
*create_event.kind(),
|
||||
StateEventType::RoomCreate.into(),
|
||||
"tried to upgrade a PDU with a create_event that is not a room create event"
|
||||
);
|
||||
|
||||
debug!(
|
||||
event_id = %incoming_pdu.event_id,
|
||||
"Upgrading PDU from outlier to timeline"
|
||||
|
||||
Reference in new issue
Block a user