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/repo.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/message/repo.rs') diff --git a/src/message/repo.rs b/src/message/repo.rs index 159ce8e..68f6e4a 100644 --- a/src/message/repo.rs +++ b/src/message/repo.rs @@ -2,8 +2,8 @@ use sqlx::{SqliteConnection, Transaction, sqlite::Sqlite}; use super::{Body, History, Id, snapshot::Message}; use crate::{ - channel::{self, Channel}, clock::DateTime, + conversation::{self, Conversation}, event::{Instant, Sequence}, user::{self, User}, }; @@ -23,7 +23,7 @@ pub struct Messages<'t>(&'t mut SqliteConnection); impl Messages<'_> { pub async fn create( &mut self, - channel: &Channel, + conversation: &Conversation, sender: &User, sent: &Instant, body: &Body, @@ -37,14 +37,14 @@ impl Messages<'_> { values ($1, $2, $3, $4, $5, $6, $7) returning id as "id: Id", - conversation as "conversation: channel::Id", + conversation as "conversation: conversation::Id", sender as "sender: user::Id", sent_at as "sent_at: DateTime", sent_sequence as "sent_sequence: Sequence", body as "body: Body" "#, id, - channel.id, + conversation.id, sender.id, sent.at, sent.sequence, @@ -68,12 +68,15 @@ impl Messages<'_> { Ok(message) } - pub async fn live(&mut self, channel: &channel::History) -> Result, sqlx::Error> { - let channel_id = channel.id(); + pub async fn live( + &mut self, + conversation: &conversation::History, + ) -> Result, sqlx::Error> { + let conversation_id = conversation.id(); let messages = sqlx::query!( r#" select - message.conversation as "conversation: channel::Id", + message.conversation as "conversation: conversation::Id", message.sender as "sender: user::Id", id as "id: Id", message.body as "body: Body", @@ -87,7 +90,7 @@ impl Messages<'_> { where message.conversation = $1 and deleted.id is null "#, - channel_id, + conversation_id, ) .map(|row| History { message: Message { @@ -110,7 +113,7 @@ impl Messages<'_> { let messages = sqlx::query!( r#" select - message.conversation as "conversation: channel::Id", + message.conversation as "conversation: conversation::Id", message.sender as "sender: user::Id", message.id as "id: Id", message.body as "body: Body", @@ -147,7 +150,7 @@ impl Messages<'_> { let message = sqlx::query!( r#" select - message.conversation as "conversation: channel::Id", + message.conversation as "conversation: conversation::Id", message.sender as "sender: user::Id", id as "id: Id", message.body as "body: Body", @@ -200,7 +203,7 @@ impl Messages<'_> { // Small social responsibility hack here: when a message is deleted, its body is // retconned to have been the empty string. Someone reading the event stream - // afterwards, or looking at messages in the channel, cannot retrieve the + // afterwards, or looking at messages in the conversation, cannot retrieve the // "deleted" message by ignoring the deletion event. sqlx::query!( r#" @@ -252,7 +255,7 @@ impl Messages<'_> { r#" select id as "id: Id", - message.conversation as "conversation: channel::Id", + message.conversation as "conversation: conversation::Id", message.sender as "sender: user::Id", message.sent_at as "sent_at: DateTime", message.sent_sequence as "sent_sequence: Sequence", @@ -289,7 +292,7 @@ impl Messages<'_> { r#" select id as "id: Id", - message.conversation as "conversation: channel::Id", + message.conversation as "conversation: conversation::Id", message.sender as "sender: user::Id", message.sent_at as "sent_at: DateTime", message.sent_sequence as "sent_sequence: Sequence", -- cgit v1.2.3