Deprecated: Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead in /var/www/michaelwiller.dk/public_html/blog/wp-includes/plugin.php on line 1014

Warning: Cannot modify header information - headers already sent by (output started at /var/www/michaelwiller.dk/public_html/blog/wp-includes/plugin.php:1014) in /var/www/michaelwiller.dk/public_html/blog/wp-includes/feed-rss2.php on line 8
softwaredevelopment – Michael on IT https://michaelwiller.dk Ramblings from an old geek Wed, 23 Nov 2022 16:43:33 +0000 en-GB hourly 1 https://wordpress.org/?v=6.9.12 188526966
Deprecated: Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead in /var/www/michaelwiller.dk/public_html/blog/wp-includes/plugin.php on line 1014
Mastodon: How toots are distributed between timeline https://michaelwiller.dk/2022/11/23/mastodon-how-toots-are-distributed-between-timeline/ Wed, 23 Nov 2022 15:17:20 +0000 https://michaelwiller.dk/?p=87 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
]]>
87