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

client: handle card and tweet attachment #50

Merged
merged 3 commits into from
Feb 19, 2025
Merged

client: handle card and tweet attachment #50

merged 3 commits into from
Feb 19, 2025

Conversation

rnons
Copy link
Contributor

@rnons rnons commented Feb 17, 2025

No description provided.

@rnons rnons requested a review from tulir February 17, 2025 06:03
linkPreview.ImageWidth = media.OriginalInfo.Width
linkPreview.ImageHeight = media.OriginalInfo.Height
linkPreview.ImageSize = int(resp.ContentLength)
linkPreview.ImageURL, _, err = intent.UploadMediaStream(ctx, portal.MXID, resp.ContentLength, false, func(file io.Writer) (*bridgev2.FileStreamResult, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can't figure out why ImageURL is empty and err is nil

Copy link
Member

Choose a reason for hiding this comment

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

downloadFile's error doesn't seem to be handled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, but in my testing, ImageWidth, ImageHeight, ImageSize all have values, only ImageURL is empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested again with synapse, image was uploaded fine

"com.beeper.linkpreviews": [
      {
        "og:url": "https://x.com/*",
        "og:title": "* on X",
        "og:description": "**. https://t.co/*",
        "og:image": "mxc://*.*/wKtjAnYXjafJtLrKZsKcRLDh",
        "matrix:image:size": 47126,
        "og:image:width": 903,
        "og:image:height": 984,
        "og:image:type": "image/jpeg"
      }

So maybe a problem with my bridge-manager setup.

content := bridgeEvt.MessageEventContent{
MsgType: bridgeEvt.MsgText,
BeeperLinkPreviews: []*bridgeEvt.BeeperLinkPreview{tc.attachmentCardToMatrix(ctx, attachment.Card, msg.Entities.URLs)},
}
Copy link
Member

Choose a reason for hiding this comment

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

These should probably include the card/tweet url in body rather than just a link preview

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other fields are placeholders here, only the BeeperLinkPreviews fields is used in client.go. The card/tweet url is still in the textPart, which will be expanded in my next PR

if msg.Attachment.Card != nil || msg.Attachment.Tweet != nil {
	textPart.Content.BeeperLinkPreviews = convertedAttachmentPart.Content.BeeperLinkPreviews
}

linkPreview.ImageWidth = media.OriginalInfo.Width
linkPreview.ImageHeight = media.OriginalInfo.Height
linkPreview.ImageSize = int(resp.ContentLength)
linkPreview.ImageURL, _, err = intent.UploadMediaStream(ctx, portal.MXID, resp.ContentLength, false, func(file io.Writer) (*bridgev2.FileStreamResult, error) {
Copy link
Member

Choose a reason for hiding this comment

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

downloadFile's error doesn't seem to be handled?

@rnons rnons merged commit ec5de88 into main Feb 19, 2025
11 checks passed
@rnons rnons deleted the rnons/plat-29649 branch February 19, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants