lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Community post tags (part 3/3: federation)

Open phiresky opened this issue 8 months ago • 8 comments

This is the third and final part of post tags, implementing federation of tags.

  • Previous PR: https://github.com/LemmyNet/lemmy/pull/5389
  • Original RFC: https://github.com/LemmyNet/rfcs/pull/4 (there has been multiple changes since the RFC, so I'll update the RFC after this is all done)

No new activities are added - federation is purely done through the existing UpdateCommunity and CreateOrUpdatePost activities.

  • On the group (community), the available tags for posts are attached as a lemmy:tagsForPosts attribute.
  • On each page (post), the associated tags are attached within the tag: attribute (which comes from the ActivityStreams vocabulary)

Example community activity:

{
  "id": "http://lemmy-alpha:8541/activities/update/971bc72f-e316-4efd-a096-523b65ded34c",
  "actor": "http://lemmy-alpha:8541/u/lemmy_alpha",
  "to": [
    "http://lemmy-alpha:8541/c/6PbAFiVY80",
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "object": {
    "type": "Group",
    "id": "http://lemmy-alpha:8541/c/6PbAFiVY80",
    "name": "6PbAFiVY80",
    /* ... */
    "lemmy:tagsForPosts": [
      {
        "type": "lemmy:CommunityTag",
        "id": "http://lemmy-alpha:8541/c/6PbAFiVY80/tag/nneflhujpm",
        "display_name": "Some Post Tag Name"
      }
    ]
  },
  "cc": ["http://lemmy-alpha:8541/c/6PbAFiVY80"],
  "type": "Update"
}

Example post activity:

{
  "actor": "http://lemmy-alpha:8541/c/6PbAFiVY80",
  "type": "Announce",
  "id": "http://lemmy-alpha:8541/activities/announce/page/9bf77a89-a248-47fd-9778-4f1ba16c6394",
  "to": [
    "http://lemmy-alpha:8541/c/6PbAFiVY80",
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "cc": ["http://lemmy-alpha:8541/c/6PbAFiVY80/followers"],
  "object": {
    "id": "http://lemmy-alpha:8541/post/1",
    "actor": "http://lemmy-alpha:8541/u/lemmy_alpha",
    "type": "Page",
    /* ... */
    "tag": [
      {
        "type": "lemmy:CommunityTag",
        "id": "http://lemmy-alpha:8541/c/6PbAFiVY80/tag/eomfsnm9om",
        "display_name": "eoMFSNm9Om"
      },
      {
        "type": "lemmy:CommunityTag",
        "id": "http://lemmy-alpha:8541/c/6PbAFiVY80/tag/k8mm66irqo",
        "display_name": "k8Mm66iRQO"
      },
      {
        "href": "http://lemmy-alpha:8541/post/1",
        "name": "#uFKPYSi5d_",
        "type": "Hashtag"
      }
    ]
  }
}

Older Lemmy versions should silently ignore the new properties due to deserialize_skip_error on the Page tag property.

phiresky avatar Apr 22 '25 13:04 phiresky

I'm getting some test failures in the private_community tests, e.g. here:

not_found thrown in:

./api_tests/src/private_community.spec.ts:162:3: https://github.com/LemmyNet/lemmy/blob/7bb471d106128c7bd598fff7453cb93aad59c4eb/api_tests/src/private_community.spec.ts#L162-L165

I'm not sure why these are happening because those parts of the code should not be affected. Does anyone know whether something has changed wrt private communities that is maybe unrelated to this PR?

phiresky avatar Apr 26 '25 09:04 phiresky

Was probably just a CI blip (we still have a few api tests that randomly get errors). I'll rerun now to make sure.

dessalines avatar Apr 28 '25 17:04 dessalines

regarding why it's taking so long - I think that's mainly because I've only been working on it very sparodically. I'm sorry about that

El lun, 5 may 2025, 12:49, Nutomic @.***> escribió:

@.**** commented on this pull request.

In crates/apub/src/protocol/objects/group.rs https://github.com/LemmyNet/lemmy/pull/5636#discussion_r2073226007:

  • /// We add available post tags as a custom field on the group. another option would be to use the
  • /// standard "attachments" property, but it seems unlikely for there to be a benefit to that.
  • #[serde(default, rename = "lemmy:tagsForPosts")]
  • pub(crate) tags_for_posts: Vec<LemmyCommunityTag>,

Why do you keep insisting to go against the maintainer's decisions and make it harder to merge your pull requests? Same with the discussion about names below. @dessalines https://github.com/dessalines and I work on Lemmy every day, we review every single pull request and are in contact with developers of Lemmy apps and other Fediverse platforms. So we are very well aware of the different tradeoffs. It would be much easier if you followed our suggestions, then this series of pull requests would be fully merged already.

— Reply to this email directly, view it on GitHub https://github.com/LemmyNet/lemmy/pull/5636#discussion_r2073226007, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARSOYLQNX4U4EZQBDFTRZD2446Z7AVCNFSM6AAAAAB3TWOSEOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDQMJUGQZTENRQGI . You are receiving this because you authored the thread.Message ID: @.***>

phiresky avatar May 05 '25 11:05 phiresky

Its alright, no rush. We have a ton of other work to get caught on.

dessalines avatar May 06 '25 14:05 dessalines

Consider adding properties to the lemmy:CommunityTag structure for text color and background color? It makes them more visually interesting, as used here - https://piefed.social/c/fediverse

e.g.

      {
        "type": "lemmy:CommunityTag",
        "id": "http://lemmy-alpha:8541/c/6PbAFiVY80/tag/eomfsnm9om",
        "display_name": "eoMFSNm9Om",
        "text_color": '#000000',
        "background_color": '#dddddd'
      },

rimu avatar May 07 '25 07:05 rimu

Also possibly you might like to add a weight or order attribute, which determines the order tags are shown in when they are listed in the community sidebar. Not all tags are equal.

rimu avatar May 07 '25 10:05 rimu

Not a bad idea, but hard-coding colors like that wouldn't be a good idea, esp for app and platforms that use their own color schemes, and adapt to dark modes.

Priority of tags is definitely a good idea.

I can't find any good field that has priority... so we have to come up with something on our own. Doesn't look like mastodon has any of these either.

dessalines avatar May 07 '25 19:05 dessalines

There's three pending changes for this PR:

  • using batch delete + upsert for the update of the community available tag list instead of loops
  • making the tests use three instances (separate community, post creator, tag editor)
  • renaming display_name back to name

otherwise it is done. Due to my lack of motivation after the unresolved discussions about the naming of JSON-LD AP extensions I'm likely not going to work on this PR in the near future. Anyone else should feel free to pick this up.

Any extensions (adding mulitple names for a tag, adding hierarchical tags, adding tag colors, priorities, etc) should likely be discussed and implemented separately after the base is finished.

phiresky avatar May 10 '25 19:05 phiresky

Replaced by https://github.com/LemmyNet/lemmy/pull/5869

Nutomic avatar Jul 17 '25 09:07 Nutomic