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

Send images missing info #80

Open
blaxer opened this issue Dec 25, 2022 · 3 comments
Open

Send images missing info #80

blaxer opened this issue Dec 25, 2022 · 3 comments

Comments

@blaxer
Copy link

blaxer commented Dec 25, 2022

Very minor issue but when sending an image, there does not appear to be any data in content --> info. This causes an issue with most of the matrix bridges I use (mautrix) as they don't recognize the message as containing an image and just show it as a binary attachement. It seems that content --> info should contain at least mimetype.

Example message that does not work correctly via bridges, sent from node-red-contrib-matrix-chat (with sensative data removed)

{
"type": "m.room.message",
"sender": "@xxxx.com",
"content": {
"body": "Camera Snapshot",
"msgtype": "m.image",
"url": "mxc://xxx/xxxx",
"info": {}
},
"origin_server_ts": xxxxx,
"unsigned": {
"age": 75
},
"event_id": "xxxx",
"room_id": "xxxx"
}

Example message sent by the element client that works properly through (mautrix) bridges

{
"type": "m.room.message",
"sender": "@xxxx.com",
"content": {
"body": "1.jpg",
"info": {
"size": 316949,
"mimetype": "image/jpeg",
"thumbnail_info": {
"w": 635,
"h": 600,
"mimetype": "image/jpeg",
"size": 166629
},
"w": 959,
"h": 906,
"xyz.amorgan.blurhash": "xxxxx",
"thumbnail_url": "mxc://xxxx/xxxx"
},
"msgtype": "m.image",
"url": "mxc://xxxx/xxxx"
},
"origin_server_ts": xxxx,
"unsigned": {
"age": 87,
"transaction_id": "xxxx"
},
"event_id": "xxxx",
"room_id": "xxxx"
}

Again from my testing the only thing that seems to be required to make an image display correctly is :

"info": {
  "mimetype": "image/jpeg",
            }

but perhaps it's a good idea to send the rest of the info as well to more closely match the "stock" client message?

TIA!

@genjudev
Copy link

genjudev commented Jan 30, 2023

Yeah its a good idea, to match the way matrix do it.

// from matrix-js-sdk
export interface IEncryptedFile {
    url: string;
    mimetype?: string;
    key: {
        alg: string;
        key_ops: string[]; // eslint-disable-line camelcase
        kty: string;
        k: string;
        ext: boolean;
    };
    iv: string;
    hashes: { [alg: string]: string };
    v: string;
}

type TMediaFile = {
    msgtype: string;
    body: string //filename, when encrypted randomized. Do not use real name.
    info: {
        mimetype: string;
        size: number;
        h: number;
        w: number;
    },
    url: string;
    file: IEncryptedFile
}

@unknown1818
Copy link

any way to implement this i node-red function node?

msg.payload = { 
    "url": msg.image_url, 
    "info": { 
        "mimetype": "image/jpg"
    } 
}
return msg;

but i got blank message

@skylord123
Copy link
Contributor

skylord123 commented Oct 22, 2023

Again from my testing the only thing that seems to be required to make an image display correctly is :

"info": {
  "mimetype": "image/jpeg",
            }

but perhaps it's a good idea to send the rest of the info as well to more closely match the "stock" client message?

Yes you are right. My testing when I created it showed that mimtype was required but the other things not so much. I'll look into automatically detecting the info. I just really don't want to add too many third party packages so I have been avoiding it.

I'm hoping in a future release to deprecate the send image and file nodes for a single upload file node. If you want to update the room or profile image you need an uploaded file to the matrix server so one of the options will be to upload a file without posting it to a room to accomplish that. I'll look into parsing extra info at that time.

At least you can send the data manually for now though if you know the information of the image.

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

No branches or pull requests

4 participants