Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Improving mobile chat behaviour allowing interaction outside the chat modal and adding a group allow list to chat #43

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

jdmartinez1062
Copy link

Description
Discourse Livestream allows the user to create chat in an specific topic that contains an event allowing user interaction when a livestream is added to the topic.

Problem
Currently, users don't have a way to restrict access to this chat for users and the chat UI doesn't allow user interaction with the topic when the chat modal is open.

Solution

Allow users to use chat as a component when the modal_mobile_chat_channel SiteSetting is disabled and add a livestream_chat_allowed_groups SiteSettings along with the required code to allow the user to control which groups of users have access to chat

config/settings.yml Outdated Show resolved Hide resolved
plugin.rb Outdated Show resolved Hide resolved
plugin.rb Outdated Show resolved Hide resolved
plugin.rb Outdated Show resolved Hide resolved
plugin.rb Outdated Show resolved Hide resolved
@@ -46,4 +47,77 @@ class Engine < ::Rails::Engine
DiscourseLivestream.handle_topic_chat_channel_creation(topic)
end
end

register_modifier(:channel_memberships) do |f, user|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why we're doing it this way. I would have thought that the memberships would be created/updated when users join/leave the event associated with the "livestream". The users/groups allowed to join the associated chat would be controlled by the groups allowed to join the event.

Copy link
Author

@jdmartinez1062 jdmartinez1062 Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main problem here is the chat's behavior. Currently, users can't preview channels they can't follow. Initially, I implemented this in the guardian extension for chat but those users who couldn't follow couldn't preview the chat so it defeats the purpose of the plugin. This modifiers aim at changing the state of the membership depending on user permissions so we dont have to modify core, which was recentlyish modified to behave this way

I just came up with the solution and maybe there is a cleaner way to handle this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, users can't preview channels they can't follow.

That's not true. Users can preview all the channels they have access to.

Copy link
Author

@jdmartinez1062 jdmartinez1062 Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is my understanding this commit changed that, this is in the channels_controller discourse/discourse@436b68a. It changed the guardian use of can_preview_chat_channel? to can_join_chat_channel?. I am not an expert here but this is what I found after following the flow of the app

https://github.com/discourse/discourse/blob/1ae35ecce8e70da065906a56171dbaa171bf2bfe/plugins/chat/app/controllers/chat/api/channels_controller.rb#L115

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I meant. If they can join a channel, they can preview it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't answer my question.

Copy link
Author

@jdmartinez1062 jdmartinez1062 Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snippet of code I linked belongs to the function triggered when a user joins an event

async function onAcceptInvite({ status, chatChannelsManager, topic }) {

Copy link
Member

@ZogStriP ZogStriP Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done on the server using a on(:something) do ... end.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can fix that, it would require changes in the calendar plugin as well since it lacks the event trigger.

Copy link
Author

@jdmartinez1062 jdmartinez1062 Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can fix that, it would require changes in the calendar plugin as well since it lacks the event trigger. I will create a different PR for those changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants