mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-23 03:41:54 +08:00
26 lines
619 B
JavaScript
Vendored
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,
|
|
};
|
|
}
|