diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-08-26 03:17:02 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-08-26 18:05:00 -0400 |
| commit | 1e0493f079d011df56fe2ec93c44a0fea38f0531 (patch) | |
| tree | 0936a24c2fd2078249f21d06a80cbba984c79e74 /src/conversation | |
| parent | ca4ac1d0f12532c38d4041aba6ae50ae4093ae13 (diff) | |
Store `Message` instances using their events.
I found a test bug! The tests for deleting previously-deleted or previously-expired tests were using the wrong user to try to delete those messages. The tests happened to pass anyways because the message authorship check was done after the message lifecycle check. They would have no longer passed; the tests are fixed to use the sender, instead.
Diffstat (limited to 'src/conversation')
| -rw-r--r-- | src/conversation/app.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/conversation/app.rs b/src/conversation/app.rs index 30baf77..5e07292 100644 --- a/src/conversation/app.rs +++ b/src/conversation/app.rs @@ -86,18 +86,21 @@ impl<'a> Conversations<'a> { .not_found(|| DeleteError::NotFound(conversation.clone()))?; let messages = tx.messages().live(&conversation).await?; + let deleted_at = tx.sequence().next(deleted_at).await?; + let has_messages = messages .iter() - .map(message::History::as_snapshot) + .map(|message| message.as_of(deleted_at)) .any(|message| message.is_some()); if has_messages { return Err(DeleteError::NotEmpty(conversation.id().clone())); } - let deleted = tx.sequence().next(deleted_at).await?; - let conversation = conversation.delete(deleted)?; + let conversation = conversation.delete(deleted_at)?; - let events = conversation.events().filter(Sequence::start_from(deleted)); + let events = conversation + .events() + .filter(Sequence::start_from(deleted_at)); tx.conversations().record_events(events.clone()).await?; tx.commit().await?; |
