Does ActivityPub send those to other instances, or does ActivityPub only send the original post and the rest (upvotes, downvotes, replies) are stored only on the original server where the post was made?

  • Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    arrow-up
    6
    ·
    9 months ago

    Yes it does, Lemmy keeps a record of all votes on the server and rebroadcasts them to other servers (most of the time). Other servers may get out of sync, especially when you take defederation into account, but that’s not a huge problem in my experience.

    Network traffic is not as bad as you may think, especially with modern HTTPS libraries that will keep connections open while also multiplexing requests.

    The protocol is described in https://www.w3.org/TR/activitypub/ (with a few implemented objects and implementations as the spec allows)

    This is a example from the spec:

    {"@context": "https://www.w3.org/ns/activitystreams",
     "type": "Like",
     "id": "https://social.example/alyssa/posts/5312e10e-5110-42e5-a09b-934882b3ecec",
     "to": ["https://chatty.example/ben/"],
     "actor": "https://social.example/alyssa/",
     "object": "https://chatty.example/ben/p/51086"}
    

    That’s about 287 characters per vote.

    • Tehhund@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      9 months ago

      Thanks, that’s very informative. How does this work since ActivityPub can be used for other things, e.g., Mastodon? They ignore any “Type” entries that they don’t support?

      • Skull giver@popplesburger.hilciferous.nl
        link
        fedilink
        arrow-up
        8
        ·
        9 months ago

        They ignore any “Type” entries that they don’t support?

        Basically. For example, ActivityPub objects such as events or locations aren’t supported by many platforms (though they do exist).

        Exact implementations differ per platform. Mastodon doesn’t have a like button, but it does have a favourite button, which is translated into a like when the activity federates. Downvotes are implemented as dislikes (an Activity Streams 2.0 feature, not part of the ActivityPub spec itself) but Mastodon just ignore those.

        Furthermore, there are tons of extra JSON fields and extensions that allow servers of a particular type to talk to each other better. For example, take the JSON returned when I query for details on your user account:

        curl -LH 'Accept: application/ld+json; profile="w3.org/ns/activitystreams"' https://lemmy.world/u/Tehhund | jq
        {
          "@context": [
            "https://www.w3.org/ns/activitystreams",
            "https://w3id.org/security/v1",
            {
              "lemmy": "https://join-lemmy.org/ns#",
              "litepub": "http://litepub.social/ns#",
              "pt": "https://joinpeertube.org/ns#",
              "sc": "http://schema.org/",
              "ChatMessage": "litepub:ChatMessage",
              "commentsEnabled": "pt:commentsEnabled",
              "sensitive": "as:sensitive",
              "matrixUserId": "lemmy:matrixUserId",
              "postingRestrictedToMods": "lemmy:postingRestrictedToMods",
              "removeData": "lemmy:removeData",
              "stickied": "lemmy:stickied",
              "moderators": {
                "@type": "@id",
                "@id": "lemmy:moderators"
              },
              "expires": "as:endTime",
              "distinguished": "lemmy:distinguished",
              "language": "sc:inLanguage",
              "identifier": "sc:identifier"
            }
          ],
          "type": "Person",
          "id": "https://lemmy.world/u/Tehhund",
          "preferredUsername": "Tehhund",
          "inbox": "https://lemmy.world/u/Tehhund/inbox",
          "outbox": "https://lemmy.world/u/Tehhund/outbox",
          "publicKey": {
            "id": "https://lemmy.world/u/Tehhund#main-key",
            "owner": "https://lemmy.world/u/Tehhund",
            "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr8QYBRNqyM3A8JHL+rWD\nN22EJDEBd+1D8hzbOnevWnmalBhbp94MY5xyTCOfGIxYo1tZs5BeuM79JRT7eFV6\nefSPZclwri4XOmizgMY2VVRw2zH3zVXmKjbIn84JaNIUez5z5NAtqgzPr+UDxWIZ\n2lH0kJuZ2YBBvH3Bk1xsJznQ3olnh0hGD9+wU10fTSI4d/razTO+4btOMV5yQYry\noZ3RWD4Zq9nhKw5s4Sb5QPQ0NNHnPsnsZPip5FfN67XOQn/d/H2TzBAdKUtEIVBH\nDivI3FWPWmCbdaz3LImS5FpKNoJvoh7Dwlfh2eIE7mkZ9FH64DNw6cd6A2fSOm1w\nXQIDAQAB\n-----END PUBLIC KEY-----\n"
          },
          "endpoints": {
            "sharedInbox": "https://lemmy.world/inbox"
          },
          "published": "2023-06-11T19:07:49.583473+00:00"
        }
        

        Notice the special fields for PeerTube, LitePub, Matrix in the context object: these are additional fields to provide optional metadata for compatibility, in case they’re necessary. In your case (and in most cases to be honest), they’re not used.

        ActivityPub has a relatively simple core architecture with lots of flexibility. You can ignore most of that flexibility to get an extremely simple client, or you can go through every server and find all the rich content they provide to build the mother of all social media apps.