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

Matrix -> Twitter mentions do not work #12

Open
bdelwood opened this issue Nov 9, 2021 · 3 comments
Open

Matrix -> Twitter mentions do not work #12

bdelwood opened this issue Nov 9, 2021 · 3 comments

Comments

@bdelwood
Copy link

bdelwood commented Nov 9, 2021

If a user mentions a Twitter user on Matrix, it appears on the Twitter end in plain text as the Matrix user's display name.

Is this a fundamental limitation of the bridge? If not, I would be interested in contributing a fix.

@tulir
Copy link
Member

tulir commented Nov 12, 2021

Should be doable, involves some browser devtools on twitter.com/messages to find out how twitter sends mentions in messages (it's probably a separate field in the send request body) and then parsing the Matrix HTML similar to https://github.com/mautrix/facebook/blob/master/mautrix_facebook/formatter/from_matrix.py to generate that field

Other direction already happens in https://github.com/mautrix/twitter/blob/master/mautrix_twitter/formatter.py

@bdelwood
Copy link
Author

Mostly notes for myself as I debug this, but it appears what happens when a user is mentioned is

  1. The "text" key has a value that is the plaintext message, including the raw handle of the user, ie @{USER}.

  2. The "entities" object is included in "message" (this also happens for URLs, which are handled correctly), with a "user_mentions" key containing and array of objects with info on the mentioned user. It appears there is already a class, Message Entities, particularly MessageEntityUserMention, that already has the json object that twitter expects is included in the entity.

I'll check out what the formatter is doing to the value of "text" and "user_mentions." Currently it appears the formatter is only sending the full Matrix username in the "text" field, and not including the expected "entities" key.

@tulir
Copy link
Member

tulir commented Nov 12, 2021

There's currently no formatter in the Matrix -> Twitter direction, the bridge just sends the plain body.

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

No branches or pull requests

2 participants