discourse/plugins/discourse-templates/assets/javascripts/lib/variables-chat-channel.js
2025-07-22 15:07:59 +02:00

26 lines
619 B
JavaScript
Vendored

export default function extractVariablesFromChatChannel(
channel,
message,
router
) {
if (!channel && !message) {
return {};
}
const inReplyTo = message?.inReplyTo;
const channelVariables = {
chat_channel_name: channel?.title,
chat_channel_url: channel?.routeModels
? router?.urlFor("chat.channel", ...channel.routeModels)
: null,
reply_to_username: inReplyTo?.user?.username,
reply_to_name: inReplyTo?.user?.name,
};
return {
...channelVariables,
context_title: channelVariables.chat_channel_name,
context_url: channelVariables.chat_channel_url,
};
}