summaryrefslogtreecommitdiff
path: root/app/finders/joined_groups_finder.rb
blob: 4d8128dd82491cd00532d86bf4e4492c607bf24a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

class JoinedGroupsFinder
  def initialize(user)
    @user = user
  end

  # Finds the groups of the source user, optionally limited to those visible to
  # the current user.
  def execute(current_user = nil)
    @user.authorized_groups
      .public_or_visible_to_user(current_user)
      .order_id_desc
  end
end