From a15e3d580124f561864c6a39f1e035eb1b3aab13 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 30 Jun 2025 22:00:57 -0400 Subject: Rename "channel" to "conversation" within the server. I've split this from the schema and API changes because, frankly, it's huge. Annoyingly so. There are no semantic changes in this, it's all symbol changes, but there are a _lot_ of them because the term "channel" leaks all over everything in a service whose primary role is managing messages sent to channels (now, conversations). I found a buggy test while working on this! It's not fixed in this commit, because it felt mean to hide a real change in the middle of this much chaff. --- src/message/app.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/message/app.rs') diff --git a/src/message/app.rs b/src/message/app.rs index 9792c8f..bdc2164 100644 --- a/src/message/app.rs +++ b/src/message/app.rs @@ -4,8 +4,8 @@ use sqlx::sqlite::SqlitePool; use super::{Body, Id, Message, repo::Provider as _}; use crate::{ - channel::{self, repo::Provider as _}, clock::DateTime, + conversation::{self, repo::Provider as _}, db::NotFound as _, event::{Broadcaster, Event, Sequence, repo::Provider as _}, name, @@ -24,23 +24,29 @@ impl<'a> Messages<'a> { pub async fn send( &self, - channel: &channel::Id, + conversation: &conversation::Id, sender: &User, sent_at: &DateTime, body: &Body, ) -> Result { - let to_not_found = || SendError::ChannelNotFound(channel.clone()); - let to_deleted = || SendError::ChannelDeleted(channel.clone()); + let to_not_found = || SendError::ConversationNotFound(conversation.clone()); + let to_deleted = || SendError::ConversationDeleted(conversation.clone()); let mut tx = self.db.begin().await?; - let channel = tx.channels().by_id(channel).await.not_found(to_not_found)?; + let conversation = tx + .conversations() + .by_id(conversation) + .await + .not_found(to_not_found)?; // Ordering: don't bother allocating a sequence number before we know the channel might // exist. let sent = tx.sequence().next(sent_at).await?; - let channel = channel.as_of(sent).ok_or_else(to_deleted)?; - - let message = tx.messages().create(&channel, sender, &sent, body).await?; + let conversation = conversation.as_of(sent).ok_or_else(to_deleted)?; + let message = tx + .messages() + .create(&conversation, sender, &sent, body) + .await?; tx.commit().await?; self.events @@ -128,19 +134,19 @@ impl<'a> Messages<'a> { #[derive(Debug, thiserror::Error)] pub enum SendError { - #[error("channel {0} not found")] - ChannelNotFound(channel::Id), - #[error("channel {0} deleted")] - ChannelDeleted(channel::Id), + #[error("conversation {0} not found")] + ConversationNotFound(conversation::Id), + #[error("conversation {0} deleted")] + ConversationDeleted(conversation::Id), #[error(transparent)] Database(#[from] sqlx::Error), #[error(transparent)] Name(#[from] name::Error), } -impl From for SendError { - fn from(error: channel::repo::LoadError) -> Self { - use channel::repo::LoadError; +impl From for SendError { + fn from(error: conversation::repo::LoadError) -> Self { + use conversation::repo::LoadError; match error { LoadError::Database(error) => error.into(), LoadError::Name(error) => error.into(), -- cgit v1.2.3