-
Notifications
You must be signed in to change notification settings - Fork 5
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
Pushing Images / Files #2
Comments
Great idea! I haven't got any use case for it yet that's why it wasn't implemented but it can be definitely done: https://matrix-nio.readthedocs.io/en/latest/examples.html#sending-an-image The only thing need to be figured out is how to get the file and its stats from the post message without creating a temp file (if it's possible, not to spam the container's filesystem nor have the responsibility of cleanup). |
@immanuelfodor Nice! Thanks for looking into this. This is wonderful project. |
Fantastic project well done. Is there a way to send json strings without quotations surrounding it? |
Thanks! Could you please provide an example what would you want to achieve? My first intuition is that the JSON should be parseable by Python. Second guess is that |
When I send Also, when I send a webhook from iOS (Shortcuts) it appears as Just trying to send strings so that its just the string when it appears in element.io My .env file has the following:
|
Oh, I see what you mean by extra quotes. It's just a coincidence that it is a valid YAML according to the Python YAML parser. The built-in parser appends the extra quotes as the |
As for the iOS Shortcuts, it probably sends a JSON like this: {
"message": "coming to you from shortcuts"
} Or a form-data payload like this:
So I think this one is normal (feature, not bug), the gateway doesn't alter the payload it receives by stripping out elements (keys or values). What you want to achieve here is some custom functionality based on sender token or payload structure (to remove the message key). |
Ah ok. That explains it. Thank you. Do you have anything you can link me regarding to stripping out the JSON elements? |
Oh, it's just plain old Python, you can alter the message anywhere between the payload decode and the send message function call: https://github.com/immanuelfodor/matrix-encrypted-webhooks/blob/main/src/WebhookServer.py#L55 If you'll use the gateway for only Shortcuts, you can replace the message formatting with
|
Receives this (which is fine): But then prints this out: Where is this new information coming from? |
The second log line is the message sent to Matrix by the bridge received back in the bridge as a new Matrix message event. The bridge receives a webhook -> the bridge logs the payload -> the bridge sends it as a message to the configured room -> Matrix sends the message event (back) to the bridge -> the bridge logs the message event. The last two steps also happen when a regular user sends a message in the room, and it could provide a capability later to manage the bridge from the room via messages/commands. Do you see the
in your Matrix client as well? |
Yep. It comes up as that. See here: https://ibb.co/hV5GJw4 Is there a way so it's just Test? |
Well, I tested it, and I can't see any extra $ curl -d "world" https://example.com/post/TOKEN
{"success": true} See the image for the Matrix output: Even the logs are fine:
The settings I used were the same as yours: MESSAGE_FORMAT: "raw"
USE_MARKDOWN: "False"
DISPLAY_APP_NAME: "False"
ALLOW_UNICODE: "True" |
Thanks @immanuelfodor What about sending JSON webhooks? When I send:
I receive the following: The settings I am using for this is: MESSAGE_FORMAT: "json" Is there a way to only extract the Hello World? |
Yes, the answer is at #2 (comment) 😄 |
Note to self: Regarding the original idea of pushing images and files, Apprise is considering a Matrix notification channel overhaul at caronc/apprise#795 . When they implement this, the custom E2E client written in this repo could be replaced by Apprise, just the same way we use that in the RocketChat gateway (https://github.com/immanuelfodor/rocketchat-push-gateway). We depend on two issues of Apprise to be completed before it can be integrated: caronc/apprise#356 for attachment support and caronc/apprise#305 for E2E support. When this happens, the Matrix webhook bridge's API can mainly stay the same and the project could become a wrapper of Apprise to provide the necessary (containerized) REST API to accept webhooks. |
Is there any current or planned support for pushing files?
The text was updated successfully, but these errors were encountered: