Module: Decidim::Messaging::ConversationHelper
- Defined in:
- app/helpers/decidim/messaging/conversation_helper.rb
Instance Method Summary collapse
-
#link_to_current_or_new_conversation_with(user) ⇒ String
Builds a link to the conversation between the current user and another user.
Instance Method Details
#link_to_current_or_new_conversation_with(user) ⇒ String
Builds a link to the conversation between the current user and another user.
-
If there’s no current user, it links to the login form.
-
If there’s no prior existing conversation between the users, it links to the new conversation form.
-
Otherwise, it links to the existing conversation.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/decidim/messaging/conversation_helper.rb', line 21 def link_to_current_or_new_conversation_with(user) return decidim.new_user_session_path unless user_signed_in? conversation_between = UserConversations.for(current_user).find do |conversation| conversation.participants.to_set == [current_user, user].to_set end if conversation_between decidim.conversation_path(conversation_between) else decidim.new_conversation_path(recipient_id: user.id) end end |