title: Firebase realtime database rules for chat app for 2 nodes
body: <p>My Chat and Friends node are separate of course, so would it be possible to refer to the friend node when writing rules for my Chat.</p>
  <p>my current chat rules are as follows:</p>
  <pre><code>&quot;Chats&quot;: {
          &quot;$uid_1&quot;:{
            &quot;$uid_2&quot;:{
             &quot;.read&quot;: &quot;auth.uid == $uid_1  || auth.uid == $uid_2&quot;, 
             &quot;.write&quot;: &quot;auth.uid == $uid_1  || auth.uid == $uid_2 &quot;
            }
          }
      },
  
  </code></pre>
  <p>Friends structure in database</p>
  <pre><code> - Friends
  
        -uid1
           -uid2
               - username
  
  
          -uid2
             -uid1
                - username
      
      
  </code></pre>
  <p>when users are no longer friends, how do I make sure that messages do not go through? I have rules inside my android application but was told that I should write it in the security rules too.</p>