Approximate translating message links that OOYE did not handle #14

Closed
opened 2023-10-18 07:05:02 +00:00 by cadence · 3 comments
Owner

OOYE already translates message links (i.e. discord.com/channels/x/y/z and matrix.to/#/#x/$y) in both directions, as long as OOYE originally bridged the message/event that's being linked to.

I should extend this to approximate links between platforms when OOYE did not bridge the original event. Here is how I will do this:

m->d

  1. After the database lookup for the replied-to event ID fails, use the /event API to get the replied-to event. (Fail if the event doesn't exist.)
  2. Read the event's timestamp.
  3. Convert the timestamp to an approximate Discord snowflake.
  4. Link to that snowflake.

d->m

  1. The database lookup for the replied-to message ID fails.
  2. Convert the message ID snowflake to a timestamp.
  3. Use the /timestamp_to_event API to look up the closest event.
  4. Fail if the origin_server_ts property is too far away for the link to be useful. (Remember that if this check fails, the Discord message link will be posted, which will probably be completely useless to Matrix users. This check should be relatively lax.)
  5. Link to that event.
OOYE **already translates message links** (i.e. discord.com/channels/x/y/z and matrix.to/#/#x/$y) in both directions, **as long as** OOYE originally bridged the message/event that's being linked to. I should extend this to _approximate_ links between platforms when OOYE did not bridge the original event. Here is how I will do this: ### m->d 1. After the database lookup for the replied-to event ID fails, use the /event API to get the replied-to event. (Fail if the event doesn't exist.) 1. Read the event's timestamp. 1. Convert the timestamp to an approximate Discord snowflake. 1. Link to that snowflake. ### d->m 1. The database lookup for the replied-to message ID fails. 1. Convert the message ID snowflake to a timestamp. 1. Use the /timestamp_to_event API to look up the closest event. 1. Fail if the origin_server_ts property is too far away for the link to be useful. (Remember that if this check fails, the Discord message link will be posted, which will probably be _completely_ useless to Matrix users. This check should be relatively lax.) 1. Link to that event.
Author
Owner

Done in the d->m direction in 8d452102d5

Done in the d->m direction in 8d452102d5
Author
Owner

Done in the m->d direction in 2df7c665cb, awaiting testing

Done in the m->d direction in 2df7c665cb, awaiting testing
Author
Owner

This feature is complete

This feature is complete
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cadence/out-of-your-element#14
No description provided.