Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reactions to export chat history #28252

Merged
merged 22 commits into from
Sep 30, 2024

Conversation

BohdanTkachenko
Copy link
Contributor

This should allow to export reactions in both JSON and HTML exports. Fixes #27971

Tested in a local environment.

Current limitations in HTML output:

  • Not rendering userpics. Only initials. As far as I understand, chat messages also don't render userpics.
  • Not rendering custom emojis. It looks like there is no existing way to render them in HTML output and in messages they are not rendered as well. But instead, simple emoji alternative is rendered. Unfortunately, for reactions there is no simplified emoji provided. Thus, it is not possible to render custom emojis. As a placeholder I added "(custom emoji)".

Example JSON message with reactions:

  {
   "id": 112233,
   "type": "message",

   ...

   "reactions": [
     {
      "type": "emoji",
      "count": 1,
      "emoji": "😁",
      "recent": [
       {
        "from": "Jane Smith",
        "from_id": "user54321",
        "date": "2023-11-08T10:10:30"
       }
      ]
     },
     {
      "type": "emoji",
      "count": 1,
      "emoji": "😢",
      "recent": [
       {
        "from": "John Doe",
        "from_id": "user12345",
        "date": "2023-11-08T10:20:30"
       }
      ]
     }
    ]
  },

Example generated HTML:

Example generated HTML

As you can see, custom emojis embedded into text_entries were properly serialized as a path to an image. I tried to follow the same code for serializing custom emojis in reactions, but somehow it is still different. I am definitely missing something, but cannot yet figure out exactly what.

@john-preston
Copy link
Member

Nice! I'll try to look into that after the current release (that I'm building now).

@john-preston
Copy link
Member

@BohdanTkachenko Please update to the latest code that should take care of paid reactions (star reactions),

@23rd
Copy link
Collaborator

23rd commented Sep 4, 2024

I have exported a couple channels for a test and I see reactions as a vertical list.

Screenshot image

Copy link
Collaborator

@23rd 23rd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And so on.
The code style of this repository demands to use auto a = Type() instead of Type a.

Telegram/SourceFiles/export/data/export_data_types.cpp Outdated Show resolved Hide resolved
Telegram/SourceFiles/export/data/export_data_types.cpp Outdated Show resolved Hide resolved
Telegram/SourceFiles/export/data/export_data_types.cpp Outdated Show resolved Hide resolved
@@ -1803,38 +1812,52 @@ Data::FileOrigin ApiWrap::currentFileMessageOrigin() const {
return result;
}

bool ApiWrap::renderCustomEmoji(QByteArray *data) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QByteArray *data

Can’t say I like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to return an optional value instead and avoid passing data by pointer directly. Does it look better now?

@BohdanTkachenko
Copy link
Contributor Author

I have exported a couple channels for a test and I see reactions as a vertical list.

Screenshot
image

Hmm... I don't see such issue. For me it shows them horizontally.

@BohdanTkachenko
Copy link
Contributor Author

I checked in Chrome and Firefox and in both it renders properly. I mean it still a bit ugly because I don't know what to do with custom emojis, but it renders them horizontally.

Screenshot from 2024-09-21 17-43-57

Would you mind sharing a bit more info about the issue? Like what OS and browser. Also, can you please try to reproduce it in some public channel, so I can reproduce it later on my machine. Also maybe you can share a snippet of generated HTML so I can take a look?

@BohdanTkachenko
Copy link
Contributor Author

BohdanTkachenko commented Sep 21, 2024

I just fixed the rendering for paid reactions and also I decided to put waving hand emoji (👋) instead of (custom emoji) placeholder. This makes it look nice overall, however not really accurate. Please let me know if you have a better idea how to do this.

Here is what I have right now (tested on https://t.me/durov channel):

image

@23rd
Copy link
Collaborator

23rd commented Sep 29, 2024

Would you mind sharing a bit more info about the issue? Like what OS and browser. Also, can you please try to reproduce it in some public channel, so I can reproduce it later on my machine. Also maybe you can share a snippet of generated HTML so I can take a look?

I have tested the latest code and the issue seems to had gone away.

Copy link
Collaborator

@23rd 23rd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about 👋 for custom emoji, but still it seems to be work.

@23rd
Copy link
Collaborator

23rd commented Sep 29, 2024

Don’t forget to rebase.

@Aokromes
Copy link
Collaborator

Don’t forget to rebase.

you an merge rebasing. :)

@john-preston john-preston merged commit a970fe9 into telegramdesktop:dev Sep 30, 2024
10 checks passed
@john-preston
Copy link
Member

Thanks for the hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Export chat history" should include reactions
4 participants