Mastodon: How toots are distributed between timeline

Mastodon: How toots are distributed between timeline

On Mastodon @zatnosk@helvede.net shared the image below about where a Toot is displayed.

Since I’m learning Python and Python in my view is so readable that anyone, I thought I’d share it here with a bit of (incomplete) Python code implementing the diagram. (edit: diagram removed, as the code brought a semantic error to light)

This piece of code is how I understand the decisions – but that might just be me…

def display_toot(toot,my_user):
  '''
  An incomplete function showing how public toots will be
  displayed on respective timelines.
  This code is not representative of any Mastodon API.
  It is simply a way for the writer to understand the
  decisions on where a toot is shown.
  '''
  if is_public(toot):
    if toot.user.followed_by(my_user):
      show_on_home_timeline(toot)
    else:
      if toot.user.on_server(my_user.server):
        show_on_local_timeline(toot)
      else:
        everyone_followed_on_server =
          get_all_followed_on(my_user.server)
        if (
              toot.user.followed_by_any( 
                everyone_followed_on_server)
              or
              toot.boosted_by_any(
                everyone_followed_on_server)
              or 
              toot.response_from_any_on(my_user.server)
           ):
              show_on_federated_timeline(toot)
  else:
    pass # Incomplete. Non-public toots missing