From 8d412732dc094ead3c5cf86c005d187f9624fc65 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 1 Jul 2025 14:24:36 -0400 Subject: Replace `channel` with `conversation` throughout the API. This is a **breaking change** for essentially all clients. Thankfully, there's presently just the one, so we don't need to go to much effort to accommoate that; the client is modified in this commit to adapt, users can reload their client, and life will go on. --- src/event/mod.rs | 6 +++--- src/message/repo.rs | 12 ++++++------ src/message/snapshot.rs | 2 +- src/routes.rs | 6 +++--- src/test/fixtures/event/mod.rs | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/event/mod.rs b/src/event/mod.rs index 801bcb9..f41dc9c 100644 --- a/src/event/mod.rs +++ b/src/event/mod.rs @@ -20,7 +20,7 @@ pub use self::{ #[serde(tag = "type", rename_all = "snake_case")] pub enum Event { User(user::Event), - Channel(conversation::Event), + Conversation(conversation::Event), Message(message::Event), } @@ -38,7 +38,7 @@ impl Sequenced for Event { fn instant(&self) -> Instant { match self { Self::User(event) => event.instant(), - Self::Channel(event) => event.instant(), + Self::Conversation(event) => event.instant(), Self::Message(event) => event.instant(), } } @@ -52,7 +52,7 @@ impl From for Event { impl From for Event { fn from(event: conversation::Event) -> Self { - Self::Channel(event) + Self::Conversation(event) } } diff --git a/src/message/repo.rs b/src/message/repo.rs index 68f6e4a..9b65a67 100644 --- a/src/message/repo.rs +++ b/src/message/repo.rs @@ -54,7 +54,7 @@ impl Messages<'_> { .map(|row| History { message: Message { sent: Instant::new(row.sent_at, row.sent_sequence), - channel: row.conversation, + conversation: row.conversation, sender: row.sender, id: row.id, body: row.body.unwrap_or_default(), @@ -95,7 +95,7 @@ impl Messages<'_> { .map(|row| History { message: Message { sent: Instant::new(row.sent_at, row.sent_sequence), - channel: row.conversation, + conversation: row.conversation, sender: row.sender, id: row.id, body: row.body.unwrap_or_default(), @@ -132,7 +132,7 @@ impl Messages<'_> { .map(|row| History { message: Message { sent: Instant::new(row.sent_at, row.sent_sequence), - channel: row.conversation, + conversation: row.conversation, sender: row.sender, id: row.id, body: row.body.unwrap_or_default(), @@ -168,7 +168,7 @@ impl Messages<'_> { .map(|row| History { message: Message { sent: Instant::new(row.sent_at, row.sent_sequence), - channel: row.conversation, + conversation: row.conversation, sender: row.sender, id: row.id, body: row.body.unwrap_or_default(), @@ -274,7 +274,7 @@ impl Messages<'_> { message: Message { sent: Instant::new(row.sent_at, row.sent_sequence), id: row.id, - channel: row.conversation, + conversation: row.conversation, sender: row.sender, body: row.body.unwrap_or_default(), deleted_at: row.deleted_at, @@ -309,7 +309,7 @@ impl Messages<'_> { .map(|row| History { message: Message { sent: Instant::new(row.sent_at, row.sent_sequence), - channel: row.conversation, + conversation: row.conversation, sender: row.sender, id: row.id, body: row.body.unwrap_or_default(), diff --git a/src/message/snapshot.rs b/src/message/snapshot.rs index 0e6e9ae..12d4daa 100644 --- a/src/message/snapshot.rs +++ b/src/message/snapshot.rs @@ -8,7 +8,7 @@ use crate::{clock::DateTime, conversation, event::Instant, user}; pub struct Message { #[serde(flatten)] pub sent: Instant, - pub channel: conversation::Id, + pub conversation: conversation::Id, pub sender: user::Id, pub id: Id, pub body: Body, diff --git a/src/routes.rs b/src/routes.rs index ca4c60c..e38f744 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -29,13 +29,13 @@ pub fn routes(app: &App) -> Router { .route("/api/auth/login", post(user::handlers::login)) .route("/api/auth/logout", post(user::handlers::logout)) .route("/api/boot", get(boot::handlers::boot)) - .route("/api/channels", post(conversation::handlers::create)) + .route("/api/conversations", post(conversation::handlers::create)) .route( - "/api/channels/{channel}", + "/api/conversations/{conversation}", post(conversation::handlers::send), ) .route( - "/api/channels/{channel}", + "/api/conversations/{conversation}", delete(conversation::handlers::delete), ) .route("/api/events", get(event::handlers::stream)) diff --git a/src/test/fixtures/event/mod.rs b/src/test/fixtures/event/mod.rs index 69c79d8..08b17e7 100644 --- a/src/test/fixtures/event/mod.rs +++ b/src/test/fixtures/event/mod.rs @@ -4,7 +4,7 @@ pub mod stream; pub fn conversation(event: Event) -> Option { match event { - Event::Channel(channel) => Some(channel), + Event::Conversation(conversation) => Some(conversation), _ => None, } } -- cgit v1.2.3