Skip to content

A platform for community discussion. Free, open, simple.

DEV: `/channel` -> `/c` chat route rename (#19782)

Roman Rizzid07b472b79af
diff --git a/.byebug_history b/.byebug_history
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/plugins/chat/app/models/chat_channel.rb b/plugins/chat/app/models/chat_channel.rb
index 389a16a4c12..6edd8e52f24 100644
--- a/plugins/chat/app/models/chat_channel.rb
+++ b/plugins/chat/app/models/chat_channel.rb
@@ -76,11 +76,11 @@ class ChatChannel < ActiveRecord::Base
end
def url
- "#{Discourse.base_url}/chat/channel/#{self.id}/#{self.slug || "-"}"
+ "#{Discourse.base_url}/chat/c/#{self.slug || "-"}/#{self.id}"
end
def relative_url
- "#{Discourse.base_path}/chat/channel/#{self.id}/#{self.slug || "-"}"
+ "#{Discourse.base_path}/chat/c/#{self.slug || "-"}/#{self.id}"
end
def self.ensure_consistency!
diff --git a/plugins/chat/assets/javascripts/discourse/chat-route-map.js b/plugins/chat/assets/javascripts/discourse/chat-route-map.js
index 582253f65b5..2ffee549611 100644
--- a/plugins/chat/assets/javascripts/discourse/chat-route-map.js
+++ b/plugins/chat/assets/javascripts/discourse/chat-route-map.js
@@ -1,8 +1,13 @@
export default function () {
this.route("chat", { path: "/chat" }, function () {
+ // TODO(roman): Remove after the 3.1 release
+ this.route("channel-legacy", {
+ path: "/channel/:channelId/:channelTitle",
+ });
+
this.route(
"channel",
- { path: "/channel/:channelId/:channelTitle" },
+ { path: "/c/:channelTitle/:channelId/" },
function () {
this.route("info", { path: "/info" }, function () {
this.route("about", { path: "/about" });
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-about-view.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-about-view.hbs
index 05ebec3b06e..5747a77885c 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-about-view.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-about-view.hbs
@@ -24,10 +24,7 @@
<DButton
@class="edit-name-btn btn-flat"
@label="chat.channel_settings.edit"
- @action={{if
- this.onEditChatChannelName
- this.onEditChatChannelName
- }}
+ @action={{if this.onEditChatChannelName this.onEditChatChannelName}}
/>
</div>
{{/if}}
@@ -90,4 +87,4 @@
leaveIcon="sign-out-alt"
}}
/>
-</div>
+</div>
\ No newline at end of file
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs
index d36800259ee..a7c4b39bb4f 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs
@@ -11,7 +11,7 @@
<div class="chat-channel-card__header">
<LinkTo
@route="chat.channel"
- @models={{array @channel.id (slugify-channel @channel)}}
+ @models={{@channel.routeModels}}
class="chat-channel-card__name-container"
>
<span class="chat-channel-card__name">
@@ -26,7 +26,7 @@
{{#if @channel.currentUserMembership.muted}}
<LinkTo
@route="chat.channel.info.settings"
- @models={{array @channel.id (slugify-channel @channel)}}
+ @models={{@channel.routeModels}}
class="chat-channel-card__tag -muted"
tabindex="-1"
>
@@ -36,7 +36,7 @@
<LinkTo
@route="chat.channel.info.settings"
- @models={{array @channel.id (slugify-channel @channel)}}
+ @models={{@channel.routeModels}}
class="chat-channel-card__setting"
tabindex="-1"
>
@@ -79,7 +79,7 @@
{{#if (gt @channel.membershipsCount 0)}}
<LinkTo
@route="chat.channel.info.members"
- @models={{array @channel.id (slugify-channel @channel)}}
+ @models={{@channel.routeModels}}
class="chat-channel-card__members"
tabindex="-1"
>
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.hbs
index a6562b1b5b7..3d1e442ae8d 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.hbs
@@ -1,6 +1,6 @@
<LinkTo
@route="chat.channel"
- @models={{array @channel.id (or @channel.slug "-")}}
+ @models={{@channel.routeModels}}
class={{concat-class
"chat-channel-row"
(if @channel.focused "focused")
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-status.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-status.hbs
index 5bfb42db968..149d1e97606 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-status.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-status.hbs
@@ -5,4 +5,4 @@
<ChatChannelArchiveStatus @channel={{this.channel}} />
</div>
-{{/if}}
+{{/if}}
\ No newline at end of file
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs
index 7d5b8411b59..75626a8ce9a 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs
@@ -47,10 +47,7 @@
{{#if this.chatStateManager.isDrawerExpanded}}
<LinkTo
@route={{this.infoTabRoute}}
- @models={{array
- this.chat.activeChannel.id
- (slugify-channel this.chat.activeChannel)
- }}
+ @models={{this.chat.activeChannel.routeModels}}
class="chat-drawer-header__title"
>
<div class="chat-drawer-header__top-line">
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.js b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.js
index df5fb52819e..04c0b39e5e3 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.js
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.js
@@ -306,7 +306,7 @@ export default Component.extend({
return "/chat/draft-channel";
case CHAT_VIEW:
if (channel) {
- return `/chat/channel/${channel.id}/${channel.slug || "-"}`;
+ return `/chat/c/${channel.slug || "-"}/${channel.id}`;
} else {
return "/chat";
}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs
index bf9154bc6b6..a6a17db58fb 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs
@@ -16,7 +16,7 @@
<LinkTo
@route={{this.infoTabRoute}}
- @models={{array this.chatChannel.id (slugify-channel this.chatChannel)}}
+ @models={{this.chatChannel.routeModels}}
class="chat-channel-title-wrapper"
>
<ChatChannelTitle @channel={{this.chatChannel}} />
@@ -152,4 +152,4 @@
{{else}}
<ChatChannelPreviewCard @channel={{this.chatChannel}} />
{{/if}}
-{{/if}}
+{{/if}}
\ No newline at end of file
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.js b/plugins/chat/assets/javascripts/discourse/components/chat-message.js
index 13e46c27f82..4d504c2e2cc 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-message.js
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.js
@@ -786,7 +786,7 @@ export default Component.extend({
const { protocol, host } = window.location;
let url = getURL(
- `/chat/channel/${this.details.chat_channel_id}/-?messageId=${this.message.id}`
+ `/chat/c/-/${this.details.chat_channel_id}?messageId=${this.message.id}`
);
url = url.indexOf("/") === 0 ? protocol + "//" + host + url : url;
clipboardCopy(url);
diff --git a/plugins/chat/assets/javascripts/discourse/components/reviewable-chat-message.hbs b/plugins/chat/assets/javascripts/discourse/components/reviewable-chat-message.hbs
index b3f653bbe0d..004e907d703 100644
--- a/plugins/chat/assets/javascripts/discourse/components/reviewable-chat-message.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/reviewable-chat-message.hbs
@@ -1,7 +1,7 @@
<div class="flagged-post-header">
<LinkTo
@route="chat.channel"
- @models={{array this.chatChannel.id this.chatChannel.title}}
+ @models={{this.chatChannel.routeModels}}
@query={{hash [email protected]_id}}
>
<ChatChannelTitle @channel={{this.chatChannel}} />
diff --git a/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.js b/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.js
index 6226d541ed1..58fc361097d 100644
--- a/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.js
+++ b/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.js
@@ -15,7 +15,7 @@ registerUnbound("format-chat-date", function (message, details, mode) {
if (details) {
url = getURL(
- `/chat/channel/${details.chat_channel_id}/-?messageId=${message.id}`
+ `/chat/c/-/${details.chat_channel_id}?messageId=${message.id}`
);
}
diff --git a/plugins/chat/assets/javascripts/discourse/helpers/slugify-channel.js b/plugins/chat/assets/javascripts/discourse/helpers/slugify-channel.js
deleted file mode 100644
index adcbee709f7..00000000000
--- a/plugins/chat/assets/javascripts/discourse/helpers/slugify-channel.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
-import Helper from "@ember/component/helper";
-
-export default class SlugifyChannel extends Helper {
- compute(inputs) {
- return slugifyChannel(inputs[0]);
- }
-}
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
index 547632c6c77..1cb408dbaba 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
@@ -1,5 +1,4 @@
import { htmlSafe } from "@ember/template";
-import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
import { withPluginApi } from "discourse/lib/plugin-api";
import I18n from "I18n";
import { bind } from "discourse-common/utils/decorators";
@@ -32,7 +31,7 @@ export default {
}
get name() {
- return dasherize(slugifyChannel(this.channel));
+ return dasherize(this.channel.slugifiedTitle);
}
@computed("chatService.activeChannel")
@@ -57,7 +56,7 @@ export default {
}
get models() {
- return [this.channel.id, slugifyChannel(this.channel)];
+ return this.channel.routeModels;
}
get text() {
@@ -195,7 +194,7 @@ export default {
}
get name() {
- return slugifyChannel(this.channel);
+ return this.channel.slugifiedTitle;
}
@computed("chatService.activeChannel")
@@ -220,7 +219,7 @@ export default {
}
get models() {
- return [this.channel.id, slugifyChannel(this.channel)];
+ return this.channel.routeModels;
}
get title() {
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-user-menu.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-user-menu.js
index 62758b9b0c5..484d511dade 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-user-menu.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-user-menu.js
@@ -24,11 +24,9 @@ export default {
title: this.notification.data.chat_channel_title,
slug: this.notification.data.chat_channel_slug,
});
- return `/chat/channel/${
+ return `/chat/c/${slug || "-"}/${
this.notification.data.chat_channel_id
- }/${slug || "-"}?messageId=${
- this.notification.data.chat_message_id
- }`;
+ }?messageId=${this.notification.data.chat_message_id}`;
}
get linkTitle() {
@@ -61,11 +59,9 @@ export default {
title: this.notification.data.chat_channel_title,
slug: this.notification.data.chat_channel_slug,
});
- return `/chat/channel/${
+ return `/chat/c/${slug || "-"}/${
this.notification.data.chat_channel_id
- }/${slug || "-"}?messageId=${
- this.notification.data.chat_message_id
- }`;
+ }?messageId=${this.notification.data.chat_message_id}`;
}
get linkTitle() {
diff --git a/plugins/chat/assets/javascripts/discourse/lib/slugify-channel.js b/plugins/chat/assets/javascripts/discourse/lib/slugify-channel.js
index f7a2734879e..492a25a9ae5 100644
--- a/plugins/chat/assets/javascripts/discourse/lib/slugify-channel.js
+++ b/plugins/chat/assets/javascripts/discourse/lib/slugify-channel.js
@@ -4,6 +4,11 @@ export default function slugifyChannel(channel) {
if (channel.slug) {
return channel.slug;
}
+
+ if (!channel.escapedTitle && !channel.title) {
+ return "-";
+ }
+
const slug = slugify(channel.escapedTitle || channel.title);
const resolvedSlug = (
slug.length
diff --git a/plugins/chat/assets/javascripts/discourse/models/chat-channel.js b/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
index 182b01a1ec3..04a4e97a52d 100644
--- a/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
+++ b/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
@@ -5,6 +5,7 @@ import UserChatChannelMembership from "discourse/plugins/chat/discourse/models/u
import { ajax } from "discourse/lib/ajax";
import { escapeExpression } from "discourse/lib/utilities";
import { tracked } from "@glimmer/tracking";
+import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
export const CHATABLE_TYPES = {
directMessageChannel: "DirectMessage",
@@ -73,6 +74,14 @@ export default class ChatChannel extends RestModel {
return escapeExpression(this.description);
}
+ get slugifiedTitle() {
+ return this.slug || slugifyChannel(this);
+ }
+
+ get routeModels() {
+ return [this.slugifiedTitle, this.id];
+ }
+
get isDirectMessageChannel() {
return this.chatable_type === CHATABLE_TYPES.directMessageChannel;
}
diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-legacy.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-legacy.js
new file mode 100644
index 00000000000..29c5104d189
--- /dev/null
+++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-legacy.js
@@ -0,0 +1,16 @@
+import DiscourseRoute from "discourse/routes/discourse";
+import { inject as service } from "@ember/service";
+
+export default class ChatChannelLegacyRoute extends DiscourseRoute {
+ @service router;
+
+ redirect() {
+ const { channelTitle, channelId, messageId } = this.paramsFor(
+ this.routeName
+ );
+
+ this.router.replaceWith("chat.channel", channelTitle, channelId, {
+ queryParams: { messageId },
+ });
+ }
+}
diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js
index 152348e1f99..26a547e4bd0 100644
--- a/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js
+++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js
@@ -1,6 +1,5 @@
import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
-import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
import { action } from "@ember/object";
import { schedule } from "@ember/runloop";
@@ -17,9 +16,8 @@ export default class ChatChannelRoute extends DiscourseRoute {
this.chat.setActiveChannel(model);
const { channelTitle, messageId } = this.paramsFor(this.routeName);
- const slug = slugifyChannel(model);
- if (channelTitle !== slug) {
- this.router.replaceWith("chat.channel.index", model.id, slug, {
+ if (channelTitle !== model.slugifiedTitle) {
+ this.router.replaceWith("chat.channel.index", ...model.routeModels, {
queryParams: { messageId },
});
}
diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-message.js b/plugins/chat/assets/javascripts/discourse/routes/chat-message.js
index c96d913c092..810822e1897 100644
--- a/plugins/chat/assets/javascripts/discourse/routes/chat-message.js
+++ b/plugins/chat/assets/javascripts/discourse/routes/chat-message.js
@@ -11,8 +11,8 @@ export default class ChatMessageRoute extends DiscourseRoute {
.then((response) => {
this.transitionTo(
"chat.channel",
- response.chat_channel_id,
response.chat_channel_title,
+ response.chat_channel_id,
{
queryParams: { messageId: params.messageId },
}
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js
index 686c552515b..396f16cf400 100644
--- a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js
+++ b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js
@@ -57,7 +57,7 @@ export default class ChatNotificationManager extends Service {
@bind
_pageChanged(path) {
- this.set("_inChat", path.startsWith("/chat/channel/"));
+ this.set("_inChat", path.startsWith("/chat/c/"));
if (this._inChat) {
this._chatPresenceChannel.enter({ onlyWhileActive: false });
this._corePresenceChannel.leave();
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat.js b/plugins/chat/assets/javascripts/discourse/services/chat.js
index 931f480e438..4d6ad20f44e 100644
--- a/plugins/chat/assets/javascripts/discourse/services/chat.js
+++ b/plugins/chat/assets/javascripts/discourse/services/chat.js
@@ -1,4 +1,3 @@
-import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
import deprecated from "discourse-common/lib/deprecated";
import userSearch from "discourse/lib/user-search";
import { popupAjaxError } from "discourse/lib/ajax-error";
@@ -297,8 +296,8 @@ export default class Chat extends Service {
return this.router.transitionTo(
"chat.channel",
+ channel.slugifiedTitle,
channel.id,
- slugifyChannel(channel),
{ queryParams }
);
} else {
diff --git a/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info-about.hbs b/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info-about.hbs
index e7c3b8d6a47..83de81608a8 100644
--- a/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info-about.hbs
+++ b/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info-about.hbs
@@ -2,4 +2,4 @@
@channel={{this.model}}
@onEditChatChannelName={{action "onEditChatChannelName"}}
@onEditChatChannelDescription={{action "onEditChatChannelDescription"}}
-/>
+/>
\ No newline at end of file
diff --git a/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info.hbs b/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info.hbs
index 83e6b2e8a85..e390f0a194c 100644
--- a/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info.hbs
+++ b/plugins/chat/assets/javascripts/discourse/templates/chat-channel-info.hbs
@@ -13,7 +13,7 @@
{{else}}
<LinkTo
@route="chat.channel"
- @models={{array this.model.id (slugify-channel this.model)}}
+ @models={{this.model.routeModels}}
class="chat-full-page-header__back-btn no-text btn-flat btn"
title={{i18n "chat.channel_info.back_to_channel"}}
>
@@ -38,7 +38,7 @@
>
<LinkTo
@route={{concat "chat.channel.info." tab}}
- @models={{array this.model.id (slugify-channel this.model)}}
+ @models={{this.model.routeModels}}
class="chat-tabs-list__link"
>
<span>{{i18n (concat "chat.channel_info.tabs." tab)}}</span>
@@ -62,4 +62,4 @@
{{outlet}}
</div>
</div>
-</div>
+</div>
\ No newline at end of file
diff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name.hbs
index 00492a25217..fffffe406c7 100644
--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name.hbs
+++ b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name.hbs
@@ -19,4 +19,4 @@
@disabled={{this.isSaveDisabled}}
/>
<DModalCancel @close={{route-action "closeModal"}} />
-</div>
+</div>
\ No newline at end of file
diff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/create-channel.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/create-channel.hbs
index c25dc4e63b6..ae6e068897a 100644
--- a/plugins/chat/assets/javascripts/discourse/templates/modal/create-channel.hbs
+++ b/plugins/chat/assets/javascripts/discourse/templates/modal/create-channel.hbs
@@ -85,4 +85,4 @@
@label="chat.create_channel.create"
@disabled={{this.createDisabled}}
/>
-</div>
+</div>
\ No newline at end of file
diff --git a/plugins/chat/assets/javascripts/discourse/widgets/chat-invitation-notification-item.js b/plugins/chat/assets/javascripts/discourse/widgets/chat-invitation-notification-item.js
index f9367adec4a..f85ceb6c5c3 100644
--- a/plugins/chat/assets/javascripts/discourse/widgets/chat-invitation-notification-item.js
+++ b/plugins/chat/assets/javascripts/discourse/widgets/chat-invitation-notification-item.js
@@ -38,7 +38,7 @@ createWidgetFrom(DefaultNotificationItem, "chat-invitation-notification-item", {
title: data.chat_channel_title,
slug: data.chat_channel_slug,
});
- return `/chat/channel/${data.chat_channel_id}/${slug || "-"}?messageId=${
+ return `/chat/c/${slug || "-"}/${data.chat_channel_id}?messageId=${
data.chat_message_id
}`;
},
diff --git a/plugins/chat/assets/javascripts/discourse/widgets/chat-mention-notification-item.js b/plugins/chat/assets/javascripts/discourse/widgets/chat-mention-notification-item.js
index 7d194879dc2..2cb6f373f7b 100644
--- a/plugins/chat/assets/javascripts/discourse/widgets/chat-mention-notification-item.js
+++ b/plugins/chat/assets/javascripts/discourse/widgets/chat-mention-notification-item.js
@@ -48,7 +48,7 @@ const chatNotificationItem = {
title: data.chat_channel_title,
slug: data.chat_channel_slug,
});
- return `/chat/channel/${data.chat_channel_id}/${slug || "-"}?messageId=${
+ return `/chat/c/${slug || "-"}/${data.chat_channel_id}?messageId=${
data.chat_message_id
}`;
},
diff --git a/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js b/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js
index 236277a62fb..d853a045408 100644
--- a/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js
+++ b/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js
@@ -21,7 +21,7 @@ const chatTranscriptRule = {
const channelName = tagInfo.attrs.channel;
const channelId = tagInfo.attrs.channelId;
const channelLink = channelId
- ? options.getURL(`/chat/channel/${channelId}/-`)
+ ? options.getURL(`/chat/c/-/${channelId}`)
: null;
if (!username || !messageIdStart || !messageTimeStart) {
diff --git a/plugins/chat/lib/onebox/templates/discourse_chat.mustache b/plugins/chat/lib/onebox/templates/discourse_chat.mustache
index b0bcc8ef5e8..af7955ed903 100644
--- a/plugins/chat/lib/onebox/templates/discourse_chat.mustache
+++ b/plugins/chat/lib/onebox/templates/discourse_chat.mustache
@@ -39,7 +39,7 @@
<div class="chat-transcript-datetime">
<a href="{{url}}" title="{{created_at}}">{{created_at}}</a>
</div>
- <a class="chat-transcript-channel" href="/chat/channel/{{channel_id}}/-">
+ <a class="chat-transcript-channel" href="/chat/c/-/{{channel_id}}">
{{#is_category}}
<span class="category-chat-badge" style="color: #{{color}}">
<svg class="fa d-icon d-icon-hashtag svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use href="#hashtag"></use></svg>
diff --git a/plugins/chat/plugin.rb b/plugins/chat/plugin.rb
index 10e0cb4d3f7..af905b1d727 100644
--- a/plugins/chat/plugin.rb
+++ b/plugins/chat/plugin.rb
@@ -631,12 +631,6 @@ after_initialize do
get "/browse/open" => "chat#respond"
get "/browse/archived" => "chat#respond"
get "/draft-channel" => "chat#respond"
- get "/channel/:channel_id" => "chat#respond"
- get "/channel/:channel_id/:channel_title" => "chat#respond", :as => "channel"
- get "/channel/:channel_id/:channel_title/info" => "chat#respond"
- get "/channel/:channel_id/:channel_title/info/about" => "chat#respond"
- get "/channel/:channel_id/:channel_title/info/members" => "chat#respond"
- get "/channel/:channel_id/:channel_title/info/settings" => "chat#respond"
post "/enable" => "chat#enable_chat"
post "/disable" => "chat#disable_chat"
post "/dismiss-retention-reminder" => "chat#dismiss_retention_reminder"
@@ -657,6 +651,25 @@ after_initialize do
post "/:chat_channel_id" => "chat#create_message"
put "/flag" => "chat#flag"
get "/emojis" => "emojis#index"
+
+ base_c_route = "/c/:channel_title/:channel_id"
+ get base_c_route => "chat#respond", :as => "channel"
+
+ %w[info info/about info/members info/settings].each do |route|
+ get "#{base_c_route}/#{route}" => "chat#respond"
+ end
+
+ # /channel -> /c redirects
+ get "/channel/:channel_id", to: redirect("/chat/c/-/%{channel_id}")
+
+ base_channel_route = "/channel/:channel_id/:channel_title"
+ redirect_base = "/chat/c/%{channel_title}/%{channel_id}"
+
+ get base_channel_route, to: redirect(redirect_base)
+
+ %w[info info/about info/members info/settings].each do |route|
+ get "#{base_channel_route}/#{route}", to: redirect("#{redirect_base}/#{route}")
+ end
end
Discourse::Application.routes.append do
diff --git a/plugins/chat/spec/integration/post_chat_quote_spec.rb b/plugins/chat/spec/integration/post_chat_quote_spec.rb
index a49ae55665f..ce14c313443 100644
--- a/plugins/chat/spec/integration/post_chat_quote_spec.rb
+++ b/plugins/chat/spec/integration/post_chat_quote_spec.rb
@@ -34,14 +34,14 @@ describe "chat bbcode quoting in posts" do
expect(post.cooked.chomp).to eq(<<~COOKED.chomp)
<div class="chat-transcript" data-message-id="2321" data-username="martin" data-datetime="2022-01-25T05:40:39Z" data-channel-name="Cool Cats Club" data-channel-id="1234">
<div class="chat-transcript-meta">
- Originally sent in <a href="/chat/channel/1234/-">Cool Cats Club</a>
+ Originally sent in <a href="/chat/c/-/1234">Cool Cats Club</a>
</div>
<div class="chat-transcript-user">
<div class="chat-transcript-user-avatar"></div>
<div class="chat-transcript-username">
martin</div>
<div class="chat-transcript-datetime">
- <a href="/chat/channel/1234/-?messageId=2321" title="2022-01-25T05:40:39Z"></a>
+ <a href="/chat/c/-/1234?messageId=2321" title="2022-01-25T05:40:39Z"></a>
</div>
</div>
<div class="chat-transcript-messages">
@@ -63,9 +63,9 @@ describe "chat bbcode quoting in posts" do
<div class="chat-transcript-username">
martin</div>
<div class="chat-transcript-datetime">
- <a href="/chat/channel/1234/-?messageId=2321" title="2022-01-25T05:40:39Z"></a>
+ <a href="/chat/c/-/1234?messageId=2321" title="2022-01-25T05:40:39Z"></a>
</div>
- <a class="chat-transcript-channel" href="/chat/channel/1234/-">
+ <a class="chat-transcript-channel" href="/chat/c/-/1234">
#Cool Cats Club</a>
</div>
<div class="chat-transcript-messages">
@@ -87,9 +87,9 @@ describe "chat bbcode quoting in posts" do
<div class="chat-transcript-username">
martin</div>
<div class="chat-transcript-datetime">
- <a href="/chat/channel/1234/-?messageId=2321" title="2022-01-25T05:40:39Z"></a>
+ <a href="/chat/c/-/1234?messageId=2321" title="2022-01-25T05:40:39Z"></a>
</div>
- <a class="chat-transcript-channel" href="/chat/channel/1234/-">
+ <a class="chat-transcript-channel" href="/chat/c/-/1234">
#Cool Cats Club</a>
</div>
<div class="chat-transcript-messages">
@@ -107,7 +107,7 @@ describe "chat bbcode quoting in posts" do
expect(post.cooked.chomp).to eq(<<~COOKED.chomp)
<div class="chat-transcript" data-message-id="2321" data-username="martin" data-datetime="2022-01-25T05:40:39Z" data-channel-name="Cool Cats Club" data-channel-id="1234">
<div class="chat-transcript-meta">
- Originally sent in <a href="/chat/channel/1234/-">Cool Cats Club</a>
+ Originally sent in <a href="/chat/c/-/1234">Cool Cats Club</a>
</div>
<div class="chat-transcript-user">
<div class="chat-transcript-user-avatar"></div>
@@ -137,9 +137,9 @@ describe "chat bbcode quoting in posts" do
<div class="chat-transcript-username">
martin</div>
<div class="chat-transcript-datetime">
- <a href="/chat/channel/1234/-?messageId=2321" title="2022-01-25T05:40:39Z"></a>
+ <a href="/chat/c/-/1234?messageId=2321" title="2022-01-25T05:40:39Z"></a>
</div>
- <a class="chat-transcript-channel" href="/chat/channel/1234/-">
+ <a class="chat-transcript-channel" href="/chat/c/-/1234">
#Cool Cats Club</a>
</div>
<div class="chat-transcript-messages">
@@ -242,9 +242,9 @@ martin</div>
<div class="chat-transcript-username">
#{message1.user.username}</div>
<div class="chat-transcript-datetime">
-<a href="/chat/channel/#{channel.id}/-?messageId=#{message1.id}" title="#{message1.created_at.iso8601}"></a>
+<a href="/chat/c/-/#{channel.id}?messageId=#{message1.id}" title="#{message1.created_at.iso8601}"></a>
</div>
-<a class="chat-transcript-channel" href="/chat/channel/#{channel.id}/-">
+<a class="chat-transcript-channel" href="/chat/c/-/#{channel.id}">
##{channel.name}</a>
</div>
<div class="chat-transcript-messages">
@@ -256,9 +256,9 @@ martin</div>
<div class="chat-transcript-username">
#{message2.user.username}</div>
<div class="chat-transcript-datetime">
-<a href="/chat/channel/#{channel.id}/-?messageId=#{message2.id}" title="#{message1.created_at.iso8601}"></a>
+<a href="/chat/c/-/#{channel.id}?messageId=#{message2.id}" title="#{message1.created_at.iso8601}"></a>
</div>
-<a class="chat-transcript-channel" href="/chat/channel/#{channel.id}/-">
+<a class="chat-transcript-channel" href="/chat/c/-/#{channel.id}">
##{channel.name}</a>
</div>
<div class="chat-transcript-messages">
diff --git a/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb b/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb
index 32204adc9cd..5fe55080999 100644
--- a/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb
+++ b/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb
@@ -215,7 +215,7 @@ describe Jobs::ChatNotifyMentioned do
)
expect(desktop_notification.data[:excerpt]).to eq(message.push_notification_excerpt)
expect(desktop_notification.data[:post_url]).to eq(
- "/chat/channel/#{public_channel.id}/#{public_channel.slug}?messageId=#{message.id}",
+ "/chat/c/#{public_channel.slug}/#{public_channel.id}?messageId=#{message.id}",
)
end
@@ -229,8 +229,7 @@ describe Jobs::ChatNotifyMentioned do
username: user_1.username,
tag: Chat::ChatNotifier.push_notification_tag(:mention, public_channel.id),
excerpt: message.push_notification_excerpt,
- post_url:
- "/chat/channel/#{public_channel.id}/#{public_channel.slug}?messageId=#{message.id}",
+ post_url: "/chat/c/#{public_channel.slug}/#{public_channel.id}?messageId=#{message.id}",
translated_title: payload_translated_title,
},
)
diff --git a/plugins/chat/spec/models/chat_channel_spec.rb b/plugins/chat/spec/models/chat_channel_spec.rb
index 06d12125106..8cb1a96d587 100644
--- a/plugins/chat/spec/models/chat_channel_spec.rb
+++ b/plugins/chat/spec/models/chat_channel_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe ChatChannel do
context "when the slug is nil" do
it "uses a - instead" do
category_channel1.slug = nil
- expect(category_channel1.relative_url).to eq("/chat/channel/#{category_channel1.id}/-")
+ expect(category_channel1.relative_url).to eq("/chat/c/-/#{category_channel1.id}")
end
end
@@ -17,7 +17,7 @@ RSpec.describe ChatChannel do
it "includes the slug for the channel" do
expect(category_channel1.relative_url).to eq(
- "/chat/channel/#{category_channel1.id}/some-cool-channel",
+ "/chat/c/some-cool-channel/#{category_channel1.id}",
)
end
end
diff --git a/plugins/chat/spec/models/chat_message_spec.rb b/plugins/chat/spec/models/chat_message_spec.rb
index c73b1a24315..fd775b984aa 100644
--- a/plugins/chat/spec/models/chat_message_spec.rb
+++ b/plugins/chat/spec/models/chat_message_spec.rb
@@ -129,7 +129,7 @@ describe ChatMessage do
expect(cooked).to eq(<<~COOKED.chomp)
<div class="chat-transcript chat-transcript-chained" data-message-id="#{msg1.id}" data-username="chatbbcodeuser" data-datetime="#{msg1.created_at.iso8601}" data-channel-name="testchannel" data-channel-id="#{chat_channel.id}">
<div class="chat-transcript-meta">
- Originally sent in <a href="/chat/channel/#{chat_channel.id}/-">testchannel</a>
+ Originally sent in <a href="/chat/c/-/#{chat_channel.id}">testchannel</a>
</div>
<div class="chat-transcript-user">
<div class="chat-transcript-user-avatar">
@@ -138,7 +138,7 @@ describe ChatMessage do
<div class="chat-transcript-username">
chatbbcodeuser</div>
<div class="chat-transcript-datetime">
- <a href="/chat/channel/#{chat_channel.id}/-?messageId=#{msg1.id}" title="#{msg1.created_at.iso8601}"></a>
+ <a href="/chat/c/-/#{chat_channel.id}?messageId=#{msg1.id}" title="#{msg1.created_at.iso8601}"></a>
</div>
</div>
<div class="chat-transcript-messages">
diff --git a/plugins/chat/spec/plugin_spec.rb b/plugins/chat/spec/plugin_spec.rb
index 431d1ccc616..6a23fe258de 100644
--- a/plugins/chat/spec/plugin_spec.rb
+++ b/plugins/chat/spec/plugin_spec.rb
@@ -144,7 +144,7 @@ describe Chat do
).chat_message
end
- let(:chat_url) { "#{Discourse.base_url}/chat/channel/#{chat_channel.id}" }
+ let(:chat_url) { "#{Discourse.base_url}/chat/c/-/#{chat_channel.id}" }
context "when inline" do
it "renders channel" do
@@ -209,7 +209,7 @@ describe Chat do
<div class="chat-transcript-datetime">
<a href="#{chat_url}?messageId=#{chat_message.id}" title="#{chat_message.created_at}">#{chat_message.created_at}</a>
</div>
- <a class="chat-transcript-channel" href="/chat/channel/#{chat_channel.id}/-">
+ <a class="chat-transcript-channel" href="/chat/c/-/#{chat_channel.id}">
<span class="category-chat-badge" style="color: ##{chat_channel.chatable.color}">
<svg class="fa d-icon d-icon-hashtag svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use href="#hashtag"></use></svg>
</span>
diff --git a/plugins/chat/spec/system/channel_info_pages_spec.rb b/plugins/chat/spec/system/channel_info_pages_spec.rb
index 64fb8b8da26..f7992326723 100644
--- a/plugins/chat/spec/system/channel_info_pages_spec.rb
+++ b/plugins/chat/spec/system/channel_info_pages_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe "Info pages", type: :system, js: true do
find(".chat-channel-title-wrapper").click
find(".chat-full-page-header__back-btn").click
- expect(page).to have_current_path(chat.channel_path(channel_1.id, channel_1.slug))
+ expect(page).to have_current_path(chat.channel_path(channel_1.slug, channel_1.id))
end
end
end
diff --git a/plugins/chat/spec/system/channel_members_page_spec.rb b/plugins/chat/spec/system/channel_members_page_spec.rb
index 952a45df592..f044a3dbc61 100644
--- a/plugins/chat/spec/system/channel_members_page_spec.rb
+++ b/plugins/chat/spec/system/channel_members_page_spec.rb
@@ -26,9 +26,7 @@ RSpec.describe "Channel - Info - Members page", type: :system, js: true do
it "redirects to about page" do
chat_page.visit_channel_members(channel_1)
- expect(page).to have_current_path(
- "/chat/channel/#{channel_1.id}/#{channel_1.slug}/info/about",
- )
+ expect(page).to have_current_path("/chat/c/#{channel_1.slug}/#{channel_1.id}/info/about")
end
end
diff --git a/plugins/chat/spec/system/channel_settings_page_spec.rb b/plugins/chat/spec/system/channel_settings_page_spec.rb
index 83df778c4fc..7d3be3038a0 100644
--- a/plugins/chat/spec/system/channel_settings_page_spec.rb
+++ b/plugins/chat/spec/system/channel_settings_page_spec.rb
@@ -25,9 +25,7 @@ RSpec.describe "Channel - Info - Settings page", type: :system, js: true do
it "redirects to about tab" do
chat_page.visit_channel_settings(channel_1)
- expect(page).to have_current_path(
- "/chat/channel/#{channel_1.id}/#{channel_1.slug}/info/about",
- )
+ expect(page).to have_current_path("/chat/c/#{channel_1.slug}/#{channel_1.id}/info/about")
end
it "doesn’t have settings tab" do
@@ -49,7 +47,7 @@ RSpec.describe "Channel - Info - Settings page", type: :system, js: true do
chat_page.visit_channel_settings(channel_1)
expect(page).to have_current_path(
- "/chat/channel/#{channel_1.id}/#{channel_1.slug}/info/settings",
+ "/chat/c/#{channel_1.slug}/#{channel_1.id}/info/settings",
)
end
end
diff --git a/plugins/chat/spec/system/create_channel_spec.rb b/plugins/chat/spec/system/create_channel_spec.rb
index 8cf0d19d999..294683dec1c 100644
--- a/plugins/chat/spec/system/create_channel_spec.rb
+++ b/plugins/chat/spec/system/create_channel_spec.rb
@@ -103,7 +103,7 @@ RSpec.describe "Create channel", type: :system, js: true do
expect(page).to have_content(name)
created_channel = ChatChannel.find_by(chatable_id: category_1.id)
expect(created_channel.slug).to eq("cats-dogs")
- expect(page).to have_current_path(chat.channel_path(created_channel.id, created_channel.slug))
+ expect(page).to have_current_path(chat.channel_path(created_channel.slug, created_channel.id))
end
it "allows the user to set a slug independently of name" do
@@ -119,7 +119,7 @@ RSpec.describe "Create channel", type: :system, js: true do
expect(page).to have_content(name)
created_channel = ChatChannel.find_by(chatable_id: category_1.id)
expect(created_channel.slug).to eq("pets-everywhere")
- expect(page).to have_current_path(chat.channel_path(created_channel.id, created_channel.slug))
+ expect(page).to have_current_path(chat.channel_path(created_channel.slug, created_channel.id))
end
context "when saving" do
@@ -165,7 +165,7 @@ RSpec.describe "Create channel", type: :system, js: true do
expect(page).to have_content(category_1.name)
created_channel = ChatChannel.find_by(chatable_id: category_1.id)
expect(page).to have_current_path(
- chat.channel_path(created_channel.id, created_channel.slug),
+ chat.channel_path(created_channel.slug, created_channel.id),
)
end
end
diff --git a/plugins/chat/spec/system/navigating_to_message_spec.rb b/plugins/chat/spec/system/navigating_to_message_spec.rb
index 64d6f75ccba..3b5fe12398d 100644
--- a/plugins/chat/spec/system/navigating_to_message_spec.rb
+++ b/plugins/chat/spec/system/navigating_to_message_spec.rb
@@ -26,8 +26,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:post,
topic: topic_1,
- raw:
- "<a href=\"/chat/channel/#{channel_1.id}/-?messageId=#{first_message.id}\">#{link}</a>",
+ raw: "<a href=\"/chat/c/-/#{channel_1.id}?messageId=#{first_message.id}\">#{link}</a>",
)
end
@@ -46,7 +45,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:chat_message,
chat_channel: channel_1,
- message: "[#{link}](/chat/channel/#{channel_1.id}/-?messageId=#{first_message.id})",
+ message: "[#{link}](/chat/c/-/#{channel_1.id}?messageId=#{first_message.id})",
)
end
@@ -78,7 +77,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:chat_message,
chat_channel: channel_2,
- message: "[#{link}](/chat/channel/#{channel_1.id}/-?messageId=#{first_message.id})",
+ message: "[#{link}](/chat/c/-/#{channel_1.id}?messageId=#{first_message.id})",
)
channel_2.add(current_user)
end
@@ -94,8 +93,8 @@ RSpec.describe "Navigating to message", type: :system, js: true do
end
context "when navigating directly to a message link" do
- it "highlights the correct message" do
- visit("/chat/channel/#{channel_1.id}/-?messageId=#{first_message.id}")
+ it "highglights the correct message" do
+ visit("/chat/c/-/#{channel_1.id}?messageId=#{first_message.id}")
expect(page).to have_css(
".chat-message-container.highlighted[data-id='#{first_message.id}']",
@@ -112,8 +111,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:post,
topic: topic_1,
- raw:
- "<a href=\"/chat/channel/#{channel_1.id}/-?messageId=#{first_message.id}\">#{link}</a>",
+ raw: "<a href=\"/chat/c/-/#{channel_1.id}?messageId=#{first_message.id}\">#{link}</a>",
)
end
@@ -132,7 +130,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:chat_message,
chat_channel: channel_1,
- message: "[#{link}](/chat/channel/#{channel_1.id}/-?messageId=#{first_message.id})",
+ message: "[#{link}](/chat/c/-/#{channel_1.id}?messageId=#{first_message.id})",
)
end
diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rb
index e9ee13b565f..559c9a4c2e3 100644
--- a/plugins/chat/spec/system/navigation_spec.rb
+++ b/plugins/chat/spec/system/navigation_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe "Navigation", type: :system, js: true do
chat_page.open_from_header
expect(page).to have_current_path(
- chat.channel_path(category_channel_2.id, category_channel_2.slug),
+ chat.channel_path(category_channel_2.slug, category_channel_2.id),
)
end
end
@@ -56,7 +56,7 @@ RSpec.describe "Navigation", type: :system, js: true do
chat_page.open
expect(page).to have_current_path(
- chat.channel_path(category_channel.id, category_channel.slug),
+ chat.channel_path(category_channel.slug, category_channel.id),
)
expect(page).to have_css("html.has-full-page-chat")
expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")
@@ -79,14 +79,14 @@ RSpec.describe "Navigation", type: :system, js: true do
chat_drawer_page.maximize
expect(page).to have_current_path(
- chat.channel_path(category_channel.id, category_channel.slug),
+ chat.channel_path(category_channel.slug, category_channel.id),
)
visit("/")
chat_page.open_from_header
expect(page).to have_current_path(
- chat.channel_path(category_channel.id, category_channel.slug),
+ chat.channel_path(category_channel.slug, category_channel.id),
)
end
end
@@ -149,7 +149,7 @@ RSpec.describe "Navigation", type: :system, js: true do
find("a[class*='sidebar-section-link-#{category_channel.slug}']").click
expect(page).to have_current_path(
- chat.channel_path(category_channel.id, category_channel.slug),
+ chat.channel_path(category_channel.slug, category_channel.id),
)
end
end
@@ -235,7 +235,7 @@ RSpec.describe "Navigation", type: :system, js: true do
chat_page.open_from_header
expect(page).to have_current_path(
- chat.channel_path(category_channel_2.id, category_channel_2.slug),
+ chat.channel_path(category_channel_2.slug, category_channel_2.id),
)
expect(page).to have_content(category_channel_2.title)
end
@@ -243,7 +243,7 @@ RSpec.describe "Navigation", type: :system, js: true do
context "when opening a channel in full page" do
it "activates the channel in the sidebar" do
- visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}")
+ visit("/chat/c/#{category_channel.slug}/#{category_channel.id}")
expect(page).to have_css(
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
)
@@ -252,7 +252,7 @@ RSpec.describe "Navigation", type: :system, js: true do
context "when going back to channel from channel settings in full page" do
it "activates the channel in the sidebar" do
- visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}/info/settings")
+ visit("/chat/c/#{category_channel.slug}/#{category_channel.id}/info/settings")
find(".chat-full-page-header__back-btn").click
expect(page).to have_content(message.message)
end
@@ -260,7 +260,7 @@ RSpec.describe "Navigation", type: :system, js: true do
context "when clicking logo from a channel in full page" do
it "deactivates the channel in the sidebar" do
- visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}")
+ visit("/chat/c/#{category_channel.slug}/#{category_channel.id}")
find("#site-logo").click
expect(page).not_to have_css(
diff --git a/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb b/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb
index ededff5373b..bac01c87286 100644
--- a/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb
+++ b/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb
@@ -20,11 +20,11 @@ module PageObjects
end
def open_channel(channel)
- find(".sidebar-section-link[href='/chat/channel/#{channel.id}/#{channel.slug}']").click
+ find(".sidebar-section-link[href='/chat/c/#{channel.slug}/#{channel.id}']").click
end
def find_channel(channel)
- find(".sidebar-section-link[href='/chat/channel/#{channel.id}/#{channel.slug}']")
+ find(".sidebar-section-link[href='/chat/c/#{channel.slug}/#{channel.id}']")
self
end
end
diff --git a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
index bdbde125752..90ae2001d79 100644
--- a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
+++ b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
@@ -37,10 +37,7 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true do
it "channel link has the correct href" do
visit("/")
- expect(page).to have_link(
- channel_1.name,
- href: "/chat/channel/#{channel_1.id}/#{channel_1.slug}",
- )
+ expect(page).to have_link(channel_1.name, href: "/chat/c/#{channel_1.slug}/#{channel_1.id}")
end
context "when the category is private" do
diff --git a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
index 6dfbff7105a..6adb92ab675 100644
--- a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
+++ b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
end
expect(find("#quick-access-chat-notifications")).to have_link(
I18n.t("js.notifications.popup.direct_message_chat_mention.direct"),
- href: "/chat/channel/#{dm_channel_1.id}/#{other_user.username}?messageId=#{message.id}",
+ href: "/chat/c/#{other_user.username}/#{dm_channel_1.id}?messageId=#{message.id}",
)
end
end
@@ -100,7 +100,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
identifier: "@#{group.name}",
channel: channel_1.name,
),
- href: "/chat/channel/#{channel_1.id}/#{channel_1.slug}?messageId=#{message.id}",
+ href: "/chat/c/#{channel_1.slug}/#{channel_1.id}?messageId=#{message.id}",
)
end
end
@@ -126,7 +126,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
expect(find("#quick-access-chat-notifications")).to have_link(
I18n.t("js.notifications.popup.chat_mention.direct", channel: channel_1.name),
- href: "/chat/channel/#{channel_1.id}/#{channel_1.slug}?messageId=#{message.id}",
+ href: "/chat/c/#{channel_1.slug}/#{channel_1.id}?messageId=#{message.id}",
)
end
end
@@ -153,7 +153,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
identifier: "@all",
channel: channel_1.name,
),
- href: "/chat/channel/#{channel_1.id}/#{channel_1.slug}?messageId=#{message.id}",
+ href: "/chat/c/#{channel_1.slug}/#{channel_1.id}?messageId=#{message.id}",
)
end
end
diff --git a/plugins/chat/spec/system/visit_channel_spec.rb b/plugins/chat/spec/system/visit_channel_spec.rb
index 6aad666d0dd..1fe73fad66b 100644
--- a/plugins/chat/spec/system/visit_channel_spec.rb
+++ b/plugins/chat/spec/system/visit_channel_spec.rb
@@ -61,7 +61,7 @@ RSpec.describe "Visit channel", type: :system, js: true do
context "when channel is not found" do
it "shows an error" do
- visit("/chat/channel/999/-")
+ visit("/chat/c/-/999")
expect(page).to have_content("Not Found") # this is not a translated key
end
@@ -69,7 +69,7 @@ RSpec.describe "Visit channel", type: :system, js: true do
context "when loading a non existing message of a channel" do
it "shows an error" do
- visit("/chat/channel/#{category_channel_1.id}/-?messageId=-999")
+ visit("/chat/c/-/#{category_channel_1.id}?messageId=-999")
expect(page).to have_content(I18n.t("not_found"))
end
@@ -151,10 +151,10 @@ RSpec.describe "Visit channel", type: :system, js: true do
context "when URL doesn’t contain slug" do
it "redirects to correct URL" do
- visit("/chat/channel/#{category_channel_1.id}/-")
+ visit("/chat/c/-/#{category_channel_1.id}")
expect(page).to have_current_path(
- "/chat/channel/#{category_channel_1.id}/#{category_channel_1.slug}",
+ "/chat/c/#{category_channel_1.slug}/#{category_channel_1.id}",
)
end
end
@@ -179,10 +179,10 @@ RSpec.describe "Visit channel", type: :system, js: true do
context "when URL doesn’t contain slug" do
it "redirects to correct URL" do
- visit("/chat/channel/#{dm_channel_1.id}/-")
+ visit("/chat/c/-/#{dm_channel_1.id}")
expect(page).to have_current_path(
- "/chat/channel/#{dm_channel_1.id}/#{Slug.for(dm_channel_1.title(current_user))}",
+ "/chat/c/#{Slug.for(dm_channel_1.title(current_user))}/#{dm_channel_1.id}",
)
end
end
diff --git a/plugins/chat/test/javascripts/acceptance/chat-composer-test.js b/plugins/chat/test/javascripts/acceptance/chat-composer-test.js
index 40f6d2386d5..1f8fcf38462 100644
--- a/plugins/chat/test/javascripts/acceptance/chat-composer-test.js
+++ b/plugins/chat/test/javascripts/acceptance/chat-composer-test.js
@@ -45,7 +45,7 @@ acceptance("Discourse Chat - Composer", function (needs) {
});
skip("when pasting html in composer", async function (assert) {
- await visit("/chat/channel/11/another-category");
+ await visit("/chat/c/another-category/11");
const clipboardEvent = new Event("paste", { bubbles: true });
clipboardEvent.clipboardData = {
@@ -96,7 +96,7 @@ acceptance("Discourse Chat - Composer - unreliable network", function (needs) {
});
skip("Sending a message with unreliable network", async function (assert) {
- await visit("/chat/channel/11/-");
+ await visit("/chat/c/-/11");
await fillIn(".chat-composer-input", "network-error-message");
await click(".send-btn");
@@ -133,7 +133,7 @@ acceptance("Discourse Chat - Composer - unreliable network", function (needs) {
});
skip("Draft with unreliable network", async function (assert) {
- await visit("/chat/channel/11/-");
+ await visit("/chat/c/-/11");
this.chatService.set("isNetworkUnreliable", true);
await settled();
diff --git a/plugins/chat/test/javascripts/acceptance/chat-live-pane-collapse-test.js b/plugins/chat/test/javascripts/acceptance/chat-live-pane-collapse-test.js
index 3874fb8b3a8..4674ac50722 100644
--- a/plugins/chat/test/javascripts/acceptance/chat-live-pane-collapse-test.js
+++ b/plugins/chat/test/javascripts/acceptance/chat-live-pane-collapse-test.js
@@ -113,7 +113,7 @@ acceptance("Discourse Chat - Chat live pane collapse", function (needs) {
const collapseImage =
".chat-message-container[data-id='1'] .chat-message-collapser-opened";
- await visit("/chat/channel/1/cat");
+ await visit("/chat/c/cat/1");
assert.ok(visible(youtubeContainer));
assert.ok(visible(collapseImage), "the open arrow is shown");
@@ -140,7 +140,7 @@ acceptance("Discourse Chat - Chat live pane collapse", function (needs) {
const collapseImage =
".chat-message-container[data-id='2'] .chat-message-collapser-opened";
- await visit("/chat/channel/1/cat");
+ await visit("/chat/c/cat/1");
await click(image);
diff --git a/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js b/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js
index acbf425896d..8a17d2f2039 100644
--- a/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js
+++ b/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js
@@ -55,7 +55,7 @@ acceptance(
});
skip("Handles 429 errors by displaying an alert", async function (assert) {
- await visit("/chat/channel/1/cat");
+ await visit("/chat/c/cat/1");
assert.ok(exists(".dialog-content"), "We displayed a 429 error");
await click(".dialog-footer .btn-primary");
diff --git a/plugins/chat/test/javascripts/components/chat-channel-row-test.js b/plugins/chat/test/javascripts/components/chat-channel-row-test.js
index 357c6c7366f..0c10cad2158 100644
--- a/plugins/chat/test/javascripts/components/chat-channel-row-test.js
+++ b/plugins/chat/test/javascripts/components/chat-channel-row-test.js
@@ -17,7 +17,10 @@ module("Discourse Chat | Component | chat-channel-row", function (hooks) {
assert
.dom(".chat-channel-row")
- .hasAttribute("href", `/chat/channel/${this.categoryChatChannel.id}/-`);
+ .hasAttribute(
+ "href",
+ `/chat/c/${this.categoryChatChannel.slugifiedTitle}/${this.categoryChatChannel.id}`
+ );
});
test("allows tabbing", async function (assert) {
diff --git a/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js b/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js
index fc974208893..e6fe904aabd 100644
--- a/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js
+++ b/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js
@@ -14,7 +14,7 @@ module("Discourse Chat | Unit | Helpers | format-chat-date", function (hooks) {
assert.equal(
query(".chat-time").getAttribute("href"),
- "/chat/channel/1/-?messageId=1"
+ "/chat/c/-/1?messageId=1"
);
});
});
diff --git a/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js b/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js
index 8e850d9f8ff..862cfaeada6 100644
--- a/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js
+++ b/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js
@@ -43,9 +43,9 @@ module(
const data = this.args.data;
assert.strictEqual(
query(".chat-invitation a").getAttribute("href"),
- `/chat/channel/${data.chat_channel_id}/${slugifyChannel({
+ `/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
);
});
}
diff --git a/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js b/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js
index 65532c33b10..62603da1be1 100644
--- a/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js
+++ b/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js
@@ -52,9 +52,9 @@ module(
assert.strictEqual(
query(".chat-invitation a").getAttribute("href"),
- `/chat/channel/${data.chat_channel_id}/${slugifyChannel({
+ `/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
);
});
}
@@ -91,9 +91,9 @@ module(
assert.strictEqual(
query(".chat-invitation a").getAttribute("href"),
- `/chat/channel/${data.chat_channel_id}/${slugifyChannel({
+ `/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
);
});
}
@@ -130,9 +130,9 @@ module(
assert.strictEqual(
query(".chat-invitation a").getAttribute("href"),
- `/chat/channel/${data.chat_channel_id}/${slugifyChannel({
+ `/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
);
});
}