bluesky-social / social-app

The Bluesky Social application for Web, iOS, and Android
https://bsky.app
MIT License
12.97k stars 1.66k forks source link

Hashtags not turning into links when sent from API #5111

Closed jesusjimsa closed 2 months ago

jesusjimsa commented 2 months ago

Describe the bug

I created @beatleslyricsb.bsky.social, a bot that posts beatles lyrics every hour. At the end of every message, I add a #TheBeatles hashtag but it is not turning into a link to other messages with the same hashtag.

To Reproduce

Expected behavior

I send a message with the hashtag text and the client turns it into a link to other messages with the same hashtag.

Screenshots

These posts from my account have the hashtag but it is not a link: image

This other post from Astronomy Picture Of the Day shows the hashtag as a link: image

Details

Additional context

This is the code I use for sending the posts: https://github.com/jesusjimsa/beatles-lyrics-every-hour/blob/master/beatles_lyrics_bot.py#L67-L83

    post = {
        "$type": "app.bsky.feed.post",
        "text": text,
        "createdAt": now,
    }
    post["langs"] = ["en-US"]

    resp = requests.post(
        "https://bsky.social/xrpc/com.atproto.repo.createRecord",
        headers={"Authorization": "Bearer " + session["accessJwt"]},
        json={
            "repo": session["did"],
            "collection": "app.bsky.feed.post",
            "record": post,
        },
        timeout=10,
    )
matheusrod92 commented 2 months ago

Hi @jesusjimsa, I think that for you problem you might need to use facets to enrich the content you're sending to create the post. Looking at the docs I could find three facet options and for your case you would need to use the tag one app.bsky.richtext.facet#tag.

The only problem is that here they say that the facets are only working for mentions and links but I would give it a try anyway.

In the last link I've sent they show some examples on how to send a payload containing facets, good luck man ๐Ÿ˜‰

jesusjimsa commented 2 months ago

Thank you very much @matheusrod92, that fixed it. ๐Ÿ‘ ๐Ÿ‘