Class: Decidim::Messaging::UserConversations

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-core/app/queries/decidim/messaging/user_conversations.rb

Overview

A class used to find the conversations a user is participating in.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ UserConversations

Returns a new instance of UserConversations.


14
15
16
# File 'decidim-core/app/queries/decidim/messaging/user_conversations.rb', line 14

def initialize(user)
  @user = user
end

Class Method Details

.for(user) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.

user - a User that needs to find which processes can manage


10
11
12
# File 'decidim-core/app/queries/decidim/messaging/user_conversations.rb', line 10

def self.for(user)
  new(user).query
end

Instance Method Details

#queryObject


18
19
20
21
22
# File 'decidim-core/app/queries/decidim/messaging/user_conversations.rb', line 18

def query
  Conversation
    .joins(:participations)
    .where(decidim_messaging_participations: { decidim_participant_id: user.id })
end