# Explicitly Attached Links

**URL:** <https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357>\
**Category:** ActivityPub\
**Created:** [March 29, 2022, 6:44pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357 "2022-03-29T18:44:08Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![vpzom](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vpzom](https://socialhub.activitypub.rocks/u/vpzom)\
**Post date:** [March 29, 2022, 6:44pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/1 "2022-03-29T18:44:08Z")

</div>

Following a discussion that came up in [Allow post creation from Friendica · Issue #2144 · LemmyNet/lemmy · GitHub](https://github.com/LemmyNet/lemmy/issues/2144)

A problem that link aggregator style platforms run into is how to represent posting a link. The current de facto standard seems to be a `Page` object with the `url` field set to the link target. However, this doesn’t seem to be compatible with ActivityStreams definition of that field, since the url doesn’t point to a “representation of the object” but rather the object is often some sort of commentary on the link.

What structure should be used to cover this case?

---

<div class="post-metadata">

**Author:** ![vpzom](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vpzom](https://socialhub.activitypub.rocks/u/vpzom)\
**Post date:** [March 29, 2022, 6:45pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/2 "2022-03-29T18:45:20Z")

</div>

My thought is that `attachment` or `tag` would be a more fitting place to put this, as a Link object

---

<div class="post-metadata">

**Author:** ![heluecht](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/heluecht/32/195_2.png) [@heluecht](https://socialhub.activitypub.rocks/u/heluecht)\
**Post date:** [March 29, 2022, 7:19pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/3 "2022-03-29T19:19:47Z")

</div>

Have a look at the definition of the [`Page`](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-page):

```auto
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Page",
  "name": "Omaha Weather Report",
  "url": "http://example.org/weather-in-omaha.html"
}

```

So I guess that it is totally okay to use the `url` here to point to a page.

This is different to the [`Article`](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-article):

```auto
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Article",
  "name": "What a Crazy Day I Had",
  "content": "<div>... you will never believe ...</div>",
  "attributedTo": "http://sally.example.org"
}

```

The `url` isn’t mandatory for an `Article` (but is for a `Page`). It is widely used for the visual represantation of a `Note` or `Article`, but needn’t to be used at all.

---

<div class="post-metadata">

**Author:** ![macgirvin](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/m/82dd89/32.png) [@macgirvin](https://socialhub.activitypub.rocks/u/macgirvin)\
**Post date:** [March 29, 2022, 8:09pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/4 "2022-03-29T20:09:08Z")

</div>

The ‘url’ element can and should be be an array of different representations of (and different relations to) the selected object. There’s no reason this array couldn’t contain both a text/html representation and an application/activity+json representation with corresponding relations of ‘self’ (for instance). For media elements you might distinguish further based on dimensions.

Consuming applications only need to choose the flavours and relations and dimensions they are capable of consuming.

---

<div class="post-metadata">

**Author:** ![vpzom](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vpzom](https://socialhub.activitypub.rocks/u/vpzom)\
**Post date:** [March 29, 2022, 8:10pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/5 "2022-03-29T20:10:16Z")

</div>

Page could make sense as a representation of the link itself, though that’s distinct from the “link post” which seems to me more like a Note that may be connected to that Page

---

<div class="post-metadata">

**Author:** ![macgirvin](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/m/82dd89/32.png) [@macgirvin](https://socialhub.activitypub.rocks/u/macgirvin)\
**Post date:** [March 29, 2022, 8:13pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/6 "2022-03-29T20:13:23Z")

</div>

Agreed - and in that case attachment is much better suited as I brought up recently in regards to the whole QuotedPost mess.

---

<div class="post-metadata">

**Author:** ![heluecht](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/heluecht/32/195_2.png) [@heluecht](https://socialhub.activitypub.rocks/u/heluecht)\
**Post date:** [March 29, 2022, 8:30pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/7 "2022-03-29T20:30:19Z")

</div>

You would need a link to the HTML representation of the post. This could be `self`. But which `rel` would be suitable for the external link that is described with the `Page` element?

---

<div class="post-metadata">

**Author:** ![macgirvin](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/m/82dd89/32.png) [@macgirvin](https://socialhub.activitypub.rocks/u/macgirvin)\
**Post date:** [March 29, 2022, 9:39pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/8 "2022-03-29T21:39:29Z")

</div>

Perhaps “alternate”?

---

<div class="post-metadata">

**Author:** ![heluecht](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/heluecht/32/195_2.png) [@heluecht](https://socialhub.activitypub.rocks/u/heluecht)\
**Post date:** [March 30, 2022, 3:42am UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/9 "2022-03-30T03:42:32Z")

</div>

I don’t fully understand what you mean. Can you provide an example?

---

<div class="post-metadata">

**Author:** ![vpzom](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vpzom](https://socialhub.activitypub.rocks/u/vpzom)\
**Post date:** [March 30, 2022, 4:09am UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/10 "2022-03-30T04:09:57Z")

</div>

Here’s an example of what I’m calling a “link post”: [Alternative web client for lotide: Luna](https://narwhal.city/posts/5949)

The post points to another page, but also has its own title and content

---

<div class="post-metadata">

**Author:** ![heluecht](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/heluecht/32/195_2.png) [@heluecht](https://socialhub.activitypub.rocks/u/heluecht)\
**Post date:** [March 30, 2022, 4:48am UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/11 "2022-03-30T04:48:51Z")

</div>

I still don’t understand. For me that post appears to me to have exactly the same structure like the `Page` posts we talked about. I’m extremely bad in interpreting other people’s content.

---

<div class="post-metadata">

**Author:** ![vpzom](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vpzom](https://socialhub.activitypub.rocks/u/vpzom)\
**Post date:** [March 30, 2022, 5:04am UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/12 "2022-03-30T05:04:40Z")

</div>

Currently it is a Page but I don’t think that’s the right structure going forward since the post isn’t the page itself

---

<div class="post-metadata">

**Author:** ![nutomic](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/nutomic/32/1055_2.png) [@nutomic](https://socialhub.activitypub.rocks/u/nutomic)\
**Post date:** [March 30, 2022, 11:17am UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/13 "2022-03-30T11:17:47Z")

</div>

@heluecht: I think the definition of `url` is quite clear: “Identifies one or more links to representations of the object”. Thats not at all what we use it for in Lemmy now, we use the field for links to other websites (or images) which are discussed in the `Page`. I also dont see any indication that the `link` field has a different meaning in `Article` and `Page`, beside that example. And its just that, an example, not a definition.

So for me using `attachment` field makes the most sense. I can certainly migrate Lemmy towards using that, although we will have to keep using `link` field for some months for backwards compatibility. In the future it will then look like this:

```auto
"attachment": {
  "href": "http://example.org/abc",
  "type": "Link"
}

```

---

<div class="post-metadata">

**Author:** ![heluecht](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/heluecht/32/195_2.png) [@heluecht](https://socialhub.activitypub.rocks/u/heluecht)\
**Post date:** [March 30, 2022, 9:50pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/14 "2022-03-30T21:50:04Z")

</div>

Whar will you do when the attachment will contain multiple links? Or links to pictures? Or a combination of both?

For example a picture post looks like this:

```auto
        "attachment": [
            {
                "type": "Document",
                "mediaType": "image/jpeg",
                "url": "https://pirati.ca/photo/1691553768623f30c08ec22333961586-0.jpg",
                "name": "Fischstäbchenpizza im Eisfach eines Supermarktes neben anderen Pizzen ",
                "height": 2160,
                "width": 3840,
                "image": "https://pirati.ca/photo/1691553768623f30c08ec22333961586-1.jpg"
            }
        ],

```

I don’t oppose to the idea of using the `attachment`, but when using that you should consider a full support.

---

<div class="post-metadata">

**Author:** ![vpzom](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vpzom](https://socialhub.activitypub.rocks/u/vpzom)\
**Post date:** [March 30, 2022, 10:10pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/15 "2022-03-30T22:10:23Z")

</div>

attachment can be an array, I guess a system that only supports one attachment would just grab the first one? But yeah ideally it would do something more useful with the rest

---

<div class="post-metadata">

**Author:** ![diogo](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/diogo/32/943_2.png) [@diogo](https://socialhub.activitypub.rocks/u/diogo)\
**Post date:** [April 1, 2022, 10:04am UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/16 "2022-04-01T10:04:08Z")

</div>

Should we also add random links in the page/note/article content to the attachment array, or only the links explicitly specified by the author? If only the specified, a GNU social `Page` will look like this:

```auto
{
  "type": "Page",
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    {
      "gs": "https://www.gnu.org/software/social/ns#"
    },
    {
      "inConversation": {
        "@id": "gs:inConversation",
        "@type": "@id"
      }
    }
  ],
  "id": "https://instance.gnusocial.test/object/note/1339",
  "published": "2022-03-17T23:30:26+00:00",
  "attributedTo": "https://instance.gnusocial.test/actor/42",
  "name": "hello, world. This is my first bookmark!",
  "summary": "<p>This is the summary of a GNU social bookmark.</p>",
  "content": "<p>This is the description. And it references <a href=\"https://duck.com\">DuckDuckGo></a> too.</p>",
  "mediaType": "text/html",
  "source": {
    "content": "This is the description. And it references [DuckDuckGo](https://duck.com) too.",
    "mediaType": "text/markdown"
  },
  "attachment": [
    {
      "href": "https://gnu.org",
      "type": "Link"
    }
  ],
  "tag": [],
  "inConversation": "https://instance.gnusocial.test/conversation/1339",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "cc": [
    "https://instance.gnusocial.test/actor/21"
  ]
}

```

and this is rendered as:

```auto
<h1>hello, world. This is my first bookmark!</h1>
<a href="https://gnu.org" rel="noopener noreferrer">https://gnu.org</a>
<details>
<summary><p>This is the summary of a GNU social bookmark.</p></summary>
<p>This is the description. And it references <a href="https://duck.com">DuckDuckGo></a> too.</p>
</details>

```

---

<div class="post-metadata">

**Author:** ![nutomic](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/nutomic/32/1055_2.png) [@nutomic](https://socialhub.activitypub.rocks/u/nutomic)\
**Post date:** [April 1, 2022, 1:31pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/17 "2022-04-01T13:31:07Z")

</div>

For Lemmy it will only contain a single link which is specified explicitly by the author. I also didnt implement it as an array but a single value, though if all other implementations use an array, thats probably the better choice.

Edit: Changed to array for `attachment` field now. For now Lemmy will always use the first item. In the future we could implement some smarter logic to select a link. Presenting multiple attached links to the user would be much more complicated, as it would require changes to database, api and frontend.

---

<div class="post-metadata">

**Author:** ![vpzom](https://socialhub.activitypub.rocks/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vpzom](https://socialhub.activitypub.rocks/u/vpzom)\
**Post date:** [April 1, 2022, 3:59pm UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/18 "2022-04-01T15:59:22Z")

</div>

I think I would expect attachment to contain things that aren’t also specified in the content, maybe those could go into `tag`, similar to mentions?

---

<div class="post-metadata">

**Author:** ![heluecht](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/heluecht/32/195_2.png) [@heluecht](https://socialhub.activitypub.rocks/u/heluecht)\
**Post date:** [April 2, 2022, 5:24am UTC](https://socialhub.activitypub.rocks/t/explicitly-attached-links/2357/19 "2022-04-02T05:24:20Z")

</div>

The url to the external resource needn’t to be part of the `content` it can solely being used in `attachment`.

Concerning the content of the `attachment` I suggest to also add the `mediaType`.
