Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
FEATURE: Use direct_message_enabled_groups for DM access (#1209)
Browse files Browse the repository at this point in the history
This commit introduces the direct_message_enabled_groups setting,
which is used to control which groups can send direct messages in
chat. Staff can always send direct messages.

If a user is not part of any direct_message_enabled_groups,
then they cannot create new DM channels, cannot send messages
in existing DM channels, and if they have no existing DM channels
they will not see the DM channel list in the sidebar.
  • Loading branch information
martin-brennan committed Oct 6, 2022
1 parent 7761627 commit 77b1a03
Show file tree
Hide file tree
Showing 25 changed files with 466 additions and 189 deletions.
21 changes: 21 additions & 0 deletions assets/javascripts/discourse/components/channels-list.js
Expand Up @@ -17,6 +17,27 @@ export default class ChannelsList extends Component {
@reads("chat.directMessageChannels.[]") directMessageChannels;
@empty("publicChannels") publicChannelsEmpty;

@computed("canCreateDirectMessageChannel")
get createDirectMessageChannelLabel() {
if (!this.canCreateDirectMessageChannel) {
return "chat.direct_messages.cannot_create";
}

return "chat.direct_messages.new";
}

@computed("canCreateDirectMessageChannel", "directMessageChannels")
get showDirectMessageChannels() {
return (
this.canCreateDirectMessageChannel ||
this.directMessageChannels?.length > 0
);
}

get canCreateDirectMessageChannel() {
return this.chat.userCanDirectMessage;
}

@computed("directMessageChannels.@each.last_message_sent_at")
get sortedDirectMessageChannels() {
if (!this.directMessageChannels?.length) {
Expand Down

0 comments on commit 77b1a03

Please sign in to comment.