Forráskód Böngészése

fixed sendMessage for so that tests will work again

worlword 7 éve
szülő
commit
7839f20846
2 módosított fájl, 13 hozzáadás és 11 törlés
  1. 10 10
      src/converse-chatview.js
  2. 3 1
      src/converse-muc-views.js

+ 10 - 10
src/converse-chatview.js

@@ -813,7 +813,7 @@
                     return stanza;
                 },
 
-                sendMessage (message) {
+                sendMessage (message, file=null) {
                     /* Responsible for sending off a text message.
                      *
                      *  Parameters:
@@ -821,7 +821,14 @@
                      */
                     // TODO: We might want to send to specfic resources.
                     // Especially in the OTR case.
-                    _converse.connection.send(message);
+                    var messageStanza;
+                    if(file !== null){
+                        messageStanza = this.createFileMessageStanza(message);
+                    }
+                    else {
+                        messageStanza = this.createMessageStanza(message);
+                    }
+                    _converse.connection.send(messageStanza);
                     if (_converse.forward_messages) {
                         // Forward the message, so that other connected resources are also aware of it.
                         _converse.connection.send(
@@ -878,14 +885,7 @@
                     const message = this.model.messages.create(attrs);
                     
                     /* check, if a file was send. If true it will send the file with XEP-0066. */
-                    var messageStanza;
-                    if(file !== null){
-                        messageStanza = this.createFileMessageStanza(message);
-                    }
-                    else {
-                        messageStanza = this.createMessageStanza(message);
-                    }
-                    this.sendMessage(messageStanza);
+                    this.sendMessage(message, file);
                 },
 
                 getOutgoingMessageAttributes (text, spoiler_hint) {

+ 3 - 1
src/converse-muc-views.js

@@ -747,7 +747,9 @@
                     this.showStatusNotification(__("Error: could not execute the command"), true);
                 },
 
-                onMessageSubmitted (text, notNeeded, file = null) {
+                // the notNeeded-Parameter is there so this method has the same amount of parameters as converse-chatview.js->onMessageSubmitted
+                // this allows to call the same method from diffrent plugins 
+                onMessageSubmitted (text, notNeeded = null, file = null) {
                     /* Gets called when the user presses enter to send off a
                      * message in a chat room.
                      *