Hey there,

my first ever patch for a lua based thing and first time really working
with hg and a mailing list to submit patches!

Sorry for any mistakes i might have done.

It might really be interesting for others, i thought it might be worth
sharing.

I changed mod_post_msg to support a URL being send in a way that
conversations would understand it. 

(as per Daniel G.s comment here:
https://github.com/siacs/Conversations/issues/3353#issuecomment-456782265)

So if you send e.g. a URL to a photo, it will directly be downloaded (of
course if it is below the file size limited of the recipient) and then
shown as a photo (works well for videos too!)

Example cURL cmd

      curl -v https://xmpp-server.tld:5281/msg/[email protected]
-u "[email protected]:password" \
                -H "Content-Type: application/x-www-form-urlencoded"
--data-urlencode "url=<URL HERE>"

Patch attached file attached.

Thanks a lot to Zash for his patience and help in the MUC to make the
code more efficient and clean and still do what i wanted ;)

br

Sebastian

-- 
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/prosody-dev.
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# User Sebastian J. ([email protected])
# Date 1548704034 -3600
#      Mon Jan 28 20:33:54 2019 +0100
# Node ID 860802ab941f60f03b89f13e09e54f6d43ba4fff
# Parent  b85622b577ad7a18cd36fe58717d3f00ca87cffd
Added handling for URL parameter in mod_post_msg.lua, so that conversations will understand a URI as downloadable element (e.g. photos). Thanks to Zash from the MUC for support :)

diff -r b85622b577ad -r 860802ab941f mod_post_msg/mod_post_msg.lua
--- a/mod_post_msg/mod_post_msg.lua	Tue Jan 22 15:39:35 2019 +0100
+++ b/mod_post_msg/mod_post_msg.lua	Mon Jan 28 20:33:54 2019 +0100
@@ -58,6 +58,18 @@
 			end
 			message:tag("html", {xmlns="http://jabber.org/protocol/xhtml-im"}):add_child(html):up();
 		end
+
+		if post_body.url then
+
+			message:tag("x",{xmlns="jabber:x:oob"}):tag("url"):text(post_body.url):up():up();
+
+	          module:log("info","This is what we got? %s", message)
+
+			
+		end
+
+
+
 	elseif body_type == "application/json" then
 		local post_body = json.decode(request.body);
 		if not post_body then return 400; end

Reply via email to