Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ en:
max_reactions_limit_reached: "New reactions are not allowed on this message."
message_move_invalid_channel: "The source and destination channel must be public channels."
message_move_no_messages_found: "No messages were found with the provided message IDs."
cannot_react_without_joining: "You must join the channel first to react to messages. Send a message or join the channel manually from the channel list."
reviewables:
actions:
agree:
Expand Down
4 changes: 3 additions & 1 deletion lib/chat_message_reactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ def react!(message_id:, react_action:, emoji:)
private

def validate_channel_membership!
raise Discourse::InvalidAccess if !UserChatChannelMembership.exists?(
return if UserChatChannelMembership.exists?(
chat_channel: @chat_channel,
user: @user,
following: true
)

raise Discourse::InvalidAccess.new(nil, nil, custom_message: "chat.errors.cannot_react_without_joining")
end

def validate_channel_status!
Expand Down
1 change: 1 addition & 0 deletions spec/requests/chat_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@
sign_in(user)
put "/chat/#{chat_channel_no_memberships.id}/react/#{chat_message_no_memberships.id}.json", params: { emoji: ":heart:", react_action: "add" }
expect(response.status).to eq(403)
expect(response.parsed_body["errors"]).to include(I18n.t("chat.errors.cannot_react_without_joining"))
end

it "errors when user tries to react to private channel they can't access" do
Expand Down