tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
6.97k stars 1.43k forks source link

Instant View for urls with caption #989

Closed zevlg closed 1 year ago

zevlg commented 4 years ago

If I send message with url like https://ru.m.wikipedia.org/wiki/Моральный_кодекс_строителя_коммунизма#История_создания , new message gets web_page attached in the message content, however url of the web_page appears without "История_создания" caption.

Here is the cut from the logs:

[ 3][t 3][1586104798.879821777][MessagesManager.cpp:5270][#1][!net_actor]   Receive from on_updateNewMessage pending updateNewMessage {
  message = message {
    flags = 896
    id = 143034
    from_id = 82439953
    to_id = peerUser {
      user_id = 82439953
    }
    date = 1586104798
    message = "https://ru.m.wikipedia.org/wiki/Моральный_кодекс_строителя_коммунизма#История_создания"
    media = messageMediaWebPage {
      webpage = webPage {
        flags = 1039
        id = 1633011975046757226
        url = "https://ru.m.wikipedia.org/wiki/%D0%9C%D0%BE%D1%80%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9_%D0%BA%D0%BE%D0%B4%D0%B5%D0%BA%D1%81_%D1%81%D1%82%D1%80%D0%BE%D0%B8%D1%82%D0%B5%D0%BB%D1%8F_%D0%BA%D0%BE%D0%BC%D0%BC%D1%83%D0%BD%D0%B8%D0%B7%D0%BC%D0%B0"
        display_url = "ru.m.wikipedia.org/wiki/Моральный_кодекс_строителя_коммунизма"
        hash = -1583138128
        type = "article"
        site_name = "Wikipedia"
        title = "Моральный кодекс строителя коммунизма"
        description = "12 кодифицированных моральных правил в СССР"
...

Is it possible somehow to keep that "История_создания" caption in the web_page url, so when Instant View is initiated by user, it will be possible to jump to the contents at that caption?

Thanks!

levlam commented 4 years ago

Link preview doesn't depend on the anchor and this is unlikely to be changed. But if the URL in the message text contains an anchor, then clients try to open Instant View from the anchor's position. On Android it works with the provided URL only if the URL and the anchor exactly match the web page URL and the instant view anchor name: https://ru.m.wikipedia.org/wiki/%D0%9C%D0%BE%D1%80%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9_%D0%BA%D0%BE%D0%B4%D0%B5%D0%BA%D1%81_%D1%81%D1%82%D1%80%D0%BE%D0%B8%D1%82%D0%B5%D0%BB%D1%8F_%D0%BA%D0%BE%D0%BC%D0%BC%D1%83%D0%BD%D0%B8%D0%B7%D0%BC%D0%B0#История_создания. The page is very short, so you need to open some details sections to see that opening instant view of this link really works. On iPhone neither of the link works, but it works on other sites for links not hidden in pageBlockDetails. So this looks like a Telegram apps bug.

zevlg commented 4 years ago

BTW: in Instant View for the https://core.telegram.org page, there is a link to "https://core.telegram.org/#tdlib--build-your-own-telegram", but internal anchor has "tdlib-build-your-own-telegram" name (single dash instead of double)

Is it some known notion or just a typo in the link?

Thanks

levlam commented 4 years ago

@zevlg It was a misprint. Fixed now.