summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorojacobson <ojacobson@noreply.codeberg.org>2025-07-04 05:00:21 +0200
committerojacobson <ojacobson@noreply.codeberg.org>2025-07-04 05:00:21 +0200
commitc35be3ae29e77983f013c01260dda20208175f2b (patch)
treeabf0b9d993ef03a53903aae03f375b78473952da /src/boot
parent981cd3c0f4cf912c1d91ee5d9c39f5c1aa7afecf (diff)
parent9b38cb1a62ede4900fde4ba47a7b065db329e994 (diff)
Rename "channels" to "conversations."
The term "channel" for a conversational container has a long and storied history, but is mostly evocative of IRC and of other, ah, "nerd-centric" services. It does show up in more widespread contexts: Discord and Slack both refer to their primary conversational containers as "channels," for example. However, I think it's unnecessary jargon, and I'd like to do away with it. To that end, this change pervasively changes one term to the other wherever it appears, with the following exceptions: * A `channel` concept (unrelated to conversations) is also provided by an external library; we can't and shouldn't try to rename that. * The code to deal with the `pilcrow:channelData` and `pilcrow:lastActiveChannel` local storage properties is still present, to migrate existing data to new keys. It will be removed in a later change. This is a **breaking API change**. As we are not yet managing any API compatibility promises, this is formally not an issue, but it is something to be aware of practically. The major API changes are: * Paths beginning with `/api/channels` are now under `/api/conversations`, without other modifications. * Fields labelled with `channel…` terms are now labelled with `conversation…` terms. For example, a `message` `sent` event is now sent to a `conversation`, not a `channel`. This is also a **breaking UI change**. Specifically, any saved paths for `/ch/CHANNELID` will now lead to a 404. The corresponding paths are `/c/CONVERSATIONID`. While I've made an effort to migrate the location of stored data, I have not tried to provide adapters to fix this specific issue, because the disruption is short-lived and very easily addressed by opening a channel in the client UI. This change is obnoxiously large and difficult to review, for which I apologize. If this shows up in `git annotate`, please forgive me. These kinds of renamings are hard to carry out without a major disruption, especially when the concept ("channel" in this case) is used so pervasively throughout the system. I think it's worth making this change that pervasively so that we don't have an indefinitely-long tail of "well, it's a conversation in the docs, but the table is called `channel` for historical reasons" type issues. Merges conversations-not-channels into main.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/app.rs16
-rw-r--r--src/boot/handlers/boot/test.rs81
2 files changed, 49 insertions, 48 deletions
diff --git a/src/boot/app.rs b/src/boot/app.rs
index 89eec12..0ed5d1b 100644
--- a/src/boot/app.rs
+++ b/src/boot/app.rs
@@ -3,7 +3,7 @@ use sqlx::sqlite::SqlitePool;
use super::Snapshot;
use crate::{
- channel::{self, repo::Provider as _},
+ conversation::{self, repo::Provider as _},
event::{Event, Sequence, repo::Provider as _},
message::{self, repo::Provider as _},
name,
@@ -24,7 +24,7 @@ impl<'a> Boot<'a> {
let resume_point = tx.sequence().current().await?;
let users = tx.users().all(resume_point).await?;
- let channels = tx.channels().all(resume_point).await?;
+ let conversations = tx.conversations().all(resume_point).await?;
let messages = tx.messages().all(resume_point).await?;
tx.commit().await?;
@@ -36,9 +36,9 @@ impl<'a> Boot<'a> {
.filter(Sequence::up_to(resume_point))
.map(Event::from);
- let channel_events = channels
+ let conversation_events = conversations
.iter()
- .map(channel::History::events)
+ .map(conversation::History::events)
.kmerge_by(Sequence::merge)
.filter(Sequence::up_to(resume_point))
.map(Event::from);
@@ -51,7 +51,7 @@ impl<'a> Boot<'a> {
.map(Event::from);
let events = user_events
- .merge_by(channel_events, Sequence::merge)
+ .merge_by(conversation_events, Sequence::merge)
.merge_by(message_events, Sequence::merge)
.collect();
@@ -79,9 +79,9 @@ impl From<user::repo::LoadError> for Error {
}
}
-impl From<channel::repo::LoadError> for Error {
- fn from(error: channel::repo::LoadError) -> Self {
- use channel::repo::LoadError;
+impl From<conversation::repo::LoadError> for Error {
+ fn from(error: conversation::repo::LoadError) -> Self {
+ use conversation::repo::LoadError;
match error {
LoadError::Name(error) => error.into(),
LoadError::Database(error) => error.into(),
diff --git a/src/boot/handlers/boot/test.rs b/src/boot/handlers/boot/test.rs
index 1e590a7..c7c511a 100644
--- a/src/boot/handlers/boot/test.rs
+++ b/src/boot/handlers/boot/test.rs
@@ -37,9 +37,9 @@ async fn includes_users() {
}
#[tokio::test]
-async fn includes_channels() {
+async fn includes_conversations() {
let app = fixtures::scratch_app().await;
- let channel = fixtures::channel::create(&app, &fixtures::now()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
let viewer = fixtures::identity::fictitious();
let response = super::handler(State(app), viewer)
@@ -50,19 +50,19 @@ async fn includes_channels() {
.snapshot
.events
.into_iter()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::created)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::created)
.exactly_one()
- .expect("only one channel has been created");
- assert_eq!(channel, created.channel);
+ .expect("only one conversation has been created");
+ assert_eq!(conversation, created.conversation);
}
#[tokio::test]
async fn includes_messages() {
let app = fixtures::scratch_app().await;
let sender = fixtures::user::create(&app, &fixtures::now()).await;
- let channel = fixtures::channel::create(&app, &fixtures::now()).await;
- let message = fixtures::message::send(&app, &channel, &sender, &fixtures::now()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
+ let message = fixtures::message::send(&app, &conversation, &sender, &fixtures::now()).await;
let viewer = fixtures::identity::fictitious();
let response = super::handler(State(app), viewer)
@@ -84,9 +84,9 @@ async fn includes_messages() {
async fn includes_expired_messages() {
let app = fixtures::scratch_app().await;
let sender = fixtures::user::create(&app, &fixtures::ancient()).await;
- let channel = fixtures::channel::create(&app, &fixtures::ancient()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::ancient()).await;
let expired_message =
- fixtures::message::send(&app, &channel, &sender, &fixtures::ancient()).await;
+ fixtures::message::send(&app, &conversation, &sender, &fixtures::ancient()).await;
app.messages()
.expire(&fixtures::now())
@@ -126,8 +126,9 @@ async fn includes_expired_messages() {
async fn includes_deleted_messages() {
let app = fixtures::scratch_app().await;
let sender = fixtures::user::create(&app, &fixtures::now()).await;
- let channel = fixtures::channel::create(&app, &fixtures::now()).await;
- let deleted_message = fixtures::message::send(&app, &channel, &sender, &fixtures::now()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
+ let deleted_message =
+ fixtures::message::send(&app, &conversation, &sender, &fixtures::now()).await;
app.messages()
.delete(&sender, &deleted_message.id, &fixtures::now())
@@ -164,11 +165,11 @@ async fn includes_deleted_messages() {
}
#[tokio::test]
-async fn includes_expired_channels() {
+async fn includes_expired_conversations() {
let app = fixtures::scratch_app().await;
- let expired_channel = fixtures::channel::create(&app, &fixtures::ancient()).await;
+ let expired_conversation = fixtures::conversation::create(&app, &fixtures::ancient()).await;
- app.channels()
+ app.conversations()
.expire(&fixtures::now())
.await
.expect("expiry never fails");
@@ -183,34 +184,34 @@ async fn includes_expired_channels() {
.events
.iter()
.cloned()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::created)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::created)
.exactly_one()
- .expect("only one channel has been created");
- // We don't expect `expired_channel` to match the event exactly, as the name will have been
- // tombstoned and the channel given a `deleted_at` date.
- assert_eq!(expired_channel.id, created.channel.id);
+ .expect("only one conversation has been created");
+ // We don't expect `expired_conversation` to match the event exactly, as the name will
+ // have been tombstoned and the conversation given a `deleted_at` date.
+ assert_eq!(expired_conversation.id, created.conversation.id);
let deleted = response
.snapshot
.events
.into_iter()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::deleted)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::deleted)
.exactly_one()
- .expect("only one channel has expired");
- assert_eq!(expired_channel.id, deleted.id);
+ .expect("only one conversation has expired");
+ assert_eq!(expired_conversation.id, deleted.id);
}
#[tokio::test]
-async fn includes_deleted_channels() {
+async fn includes_deleted_conversations() {
let app = fixtures::scratch_app().await;
- let deleted_channel = fixtures::channel::create(&app, &fixtures::now()).await;
+ let deleted_conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
- app.channels()
- .delete(&deleted_channel.id, &fixtures::now())
+ app.conversations()
+ .delete(&deleted_conversation.id, &fixtures::now())
.await
- .expect("deleting a valid channel succeeds");
+ .expect("deleting a valid conversation succeeds");
let viewer = fixtures::identity::fictitious();
let response = super::handler(State(app), viewer)
@@ -222,21 +223,21 @@ async fn includes_deleted_channels() {
.events
.iter()
.cloned()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::created)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::created)
.exactly_one()
- .expect("only one channel has been created");
- // We don't expect `deleted_channel` to match the event exactly, as the name will have been
- // tombstoned and the channel given a `deleted_at` date.
- assert_eq!(deleted_channel.id, created.channel.id);
+ .expect("only one conversation has been created");
+ // We don't expect `deleted_conversation` to match the event exactly, as the name will
+ // have been tombstoned and the conversation given a `deleted_at` date.
+ assert_eq!(deleted_conversation.id, created.conversation.id);
let deleted = response
.snapshot
.events
.into_iter()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::deleted)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::deleted)
.exactly_one()
- .expect("only one channel has been deleted");
- assert_eq!(deleted_channel.id, deleted.id);
+ .expect("only one conversation has been deleted");
+ assert_eq!(deleted_conversation.id, deleted.id);
}