facebook icon indicating copy to clipboard operation
facebook copied to clipboard

Translating displaynames in mention text Matrix -> Facebook

Open tohojo opened this issue 4 years ago • 17 comments

When tagging (with @) a user on Matrix, that gets displayed as the matrix user ID on the Facebook side. Would be nice if these could be translated as proper tags instead...

tohojo avatar May 17 '21 09:05 tohojo

Converting mentions in both directions is already supported

tulir avatar May 17 '21 10:05 tulir

Tulir Asokan @.***> writes:

Converting mentions in both directions is already supported

So why doesn't it work for me, then? I tagged a user in the Matrix group, and that showed up as @.***_121217xxxx:example.org` on the Facebook side... Do I need to configure something to get it to work?

tohojo avatar May 17 '21 10:05 tohojo

Are you sure you actually tagged the user instead of just sending their user ID as plaintext?

tulir avatar May 17 '21 10:05 tulir

Tulir Asokan @.***> writes:

Are you sure you actually tagged the user instead of just sending their user ID as plaintext?

Yes, it shows up as a tag in my Matrix clients (and I tagged them by display name, not ID, so it's not like I actually entered the ID anywhere)...

tohojo avatar May 17 '21 10:05 tohojo

Could you provide event json from matrix and some screenshots from matrix and fb?

JuniorJPDJ avatar May 17 '21 11:05 JuniorJPDJ

Sure:

{
  "type": "m.room.message",
  "sender": "@toke:example.org",
  "content": {
    "msgtype": "m.text",
    "body": "@facebook_121217xxxx:example.org rest of message here",
    "format": "org.matrix.custom.html",
    "formatted_body": "<a href=\"https://matrix.to/#/@facebook_121217xxxx:example.org\">@facebook_121217xxxx:toke.dk</a>  rest of message here"
  },
  "origin_server_ts": 1620982551513,
  "unsigned": {
    "age": 269798427
  },
  "event_id": "$7Asb1kLdUdSTJjrBkJ6T7hrokP4N-YA5NFrzpJUF4V8",
  "room_id": "!BIfRMdyQsIDRnHAdRv:example.org"
}

Looks like this in Facebook chat (edited the text using devtools, but otherwise identical):

image

BTW, I noticed in another message that came from Facebook, that two users tagged in the original message only turned into one tag on the Matrix side (replaced the text and user names but kept the syntax around it):

{
  "type": "m.room.message",
  "sender": "@facebook_103855yyyy:example.org",
  "content": {
    "msgtype": "m.text",
    "body": "Some text here. More text tagging @User1 @User2 in the middle of a sentence",
    "format": "org.matrix.custom.html",
    "formatted_body": "Some text here. More text tagging <a href=\"https://matrix.to/#/@facebook_70189zzzz:example.org\">User1⁣ @121217xxxxUser2</a>  in the middle of a sentence"
  },
  "origin_server_ts": 1620980677074,
  "unsigned": {
    "age": 271669088
  },
  "event_id": "$ZTCgRuFyp9BRpHkNftm40F_CLe7kDpDx8C_RcDhK46g",
  "room_id": "!BIfRMdyQsIDRnHAdRv:example.org"
}

tohojo avatar May 17 '21 12:05 tohojo

The mention translation doesn't change the text in the mention, it only converts the mention metadata (if you click the mention on Messenger, it should open that user's Facebook profile like any other mention). Both Matrix and Messenger allow custom text inside mentions.

Replacing the text in the event with the facebook user's displayname might be a valid issue.

The bug with multiple mentions from facebook was fixed a couple of months ago (#144)

tulir avatar May 17 '21 12:05 tulir

But facebook message looks like it's tagged! Just username is got from Matrix and you seem to need some sync in your bridge ;)

JuniorJPDJ avatar May 17 '21 12:05 JuniorJPDJ

Tulir Asokan @.***> writes:

The mention translation doesn't change the text in the mention, it only converts the mention metadata (if you click the mention on Messenger, it should open that user's Facebook profile like any other mention). Both Matrix and Messenger allow custom text inside mentions.

Ah, right! Yeah, clicking the link on the FB side gets me to the right profile; but the person I was talking to was still pretty confused about that @facebook_* text :)

Replacing the text in the event with the facebook user's displayname might be a valid issue.

Yeah, translating iff the text is == the user ID would be more in line with expectations

The bug with multiple mentions from facebook was fixed a couple of months ago (#144)

Ah! Updating the bridge version was on my TODO list as well, so guess I'll go do that now :)

tohojo avatar May 17 '21 12:05 tohojo

Syncing bridge should fix this name, your bridge failed to load Facebook name of contact.

JuniorJPDJ avatar May 17 '21 12:05 JuniorJPDJ

Erm, the name shows up just fine in the contact list and when that user talks?

tohojo avatar May 17 '21 12:05 tohojo

Restart client then ;D

JuniorJPDJ avatar May 17 '21 12:05 JuniorJPDJ

JuniorJPDJ @.***> writes:

Restart client then ;D

Ah, you mean that would make the client insert the right name? That does not seem to be the issue, actually (the client has the display name just fine). It seems that it's simply how that particular client (FluffyChat) behaves: It always inserts the full user ID when @-completing, and won't create mentions at all for anything else... I'll go open a bug for the client as well, but I still think it makes sense for the bridge to detect and translate client IDs, since those obviously are completely senseless outside of Matrix...

tohojo avatar May 17 '21 13:05 tohojo

Yup, client is inserting that name and bridge is just reading summon name.

JuniorJPDJ avatar May 17 '21 18:05 JuniorJPDJ

JuniorJPDJ @.***> writes:

Yup, client is inserting that name and bridge is just reading summon name.

Right, opened a bug for that as well: https://gitlab.com/famedly/fluffychat/-/issues/408

I do think it would be reasonable for the bridge to detect this and rewrite, though...

tohojo avatar May 17 '21 20:05 tohojo

IMO workarounding client's problems in bridges isn't the best way. Bridge would end as duck-taped shit fixing lot's of random bugs floating in internet. This one bug may be OK, but general idea is B A D.

JuniorJPDJ avatar May 18 '21 00:05 JuniorJPDJ

JuniorJPDJ @.***> writes:

IMO workarounding client's problems in bridges isn't the best way. Bridge would end as duck-taped shit fixing lot's of random bugs floating in internet.

Don't worry, most of the internet is held together with duct tape and string anyway ;)

And really, the bridge is the point of interface with the world outside Matrix, so it's a reasonable place to have a translation like this. After all, there's already a translation of the link itself, so it's not like this would be an entirely new thing, just another check for a specific string.

And sure, you could say "this is not our problem go fix the clients", but then this just becomes whack-a-mole with all the different clients... :/

tohojo avatar May 18 '21 15:05 tohojo