Welcome to mirror list, hosted at ThFree Co, Russian Federation.

conversation_visibility.rb « models « app - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8501a091799ecbb813dd296ee3a77081e90d9a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class ConversationVisibility < ApplicationRecord

  belongs_to :conversation
  belongs_to :person

  after_destroy :check_orphan_conversation

  private

  def check_orphan_conversation
    conversation = Conversation.find_by_id(self.conversation.id)
    if conversation
      conversation.destroy if conversation.participants.count == 0
    end
  end
end