Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
1eb23643
Commit
1eb23643
authored
Jul 30, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let `sendMessage` return the message model, not just the text
parent
afa25434
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
20 deletions
+22
-20
spec/muc.js
spec/muc.js
+1
-1
src/converse-chatview.js
src/converse-chatview.js
+10
-9
src/converse-omemo.js
src/converse-omemo.js
+6
-4
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+5
-6
No files found.
spec/muc.js
View file @
1eb23643
...
...
@@ -2016,7 +2016,7 @@
});
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
messageSend
'
,
text
);
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
messageSend
'
,
jasmine
.
any
(
_converse
.
Message
)
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
...
...
src/converse-chatview.js
View file @
1eb23643
...
...
@@ -885,11 +885,9 @@ converse.plugins.add('converse-chatview', {
async
onFormSubmitted
(
ev
)
{
ev
.
preventDefault
();
const
textarea
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
const
message
=
textarea
.
value
.
trim
();
if
(
_converse
.
message_limit
&&
message
.
length
>
_converse
.
message_limit
)
{
return
;
}
if
(
!
message
.
replace
(
/
\s
/g
,
''
).
length
)
{
const
message_text
=
textarea
.
value
.
trim
();
if
(
_converse
.
message_limit
&&
message_text
.
length
>
_converse
.
message_limit
||
!
message_text
.
replace
(
/
\s
/g
,
''
).
length
)
{
return
;
}
if
(
!
_converse
.
connection
.
authenticated
)
{
...
...
@@ -907,18 +905,21 @@ converse.plugins.add('converse-chatview', {
}
u
.
addClass
(
'
disabled
'
,
textarea
);
textarea
.
setAttribute
(
'
disabled
'
,
'
disabled
'
);
if
(
this
.
parseMessageForCommands
(
message
)
||
await
this
.
model
.
sendMessage
(
message
,
spoiler_hint
))
{
const
is_command
=
this
.
parseMessageForCommands
(
message_text
);
const
message
=
is_command
?
null
:
await
this
.
model
.
sendMessage
(
message_text
,
spoiler_hint
);
if
(
is_command
||
message
)
{
hint_el
.
value
=
''
;
textarea
.
value
=
''
;
u
.
removeClass
(
'
correcting
'
,
textarea
);
textarea
.
style
.
height
=
'
auto
'
;
// Fixes weirdness
}
if
(
message
)
{
/**
* Triggered
just before an HTML5 message notification will be sent out.
* Triggered
whenever a message is sent by the user
* @event _converse#messageSend
* @type { _converse.Message }
* @example _converse.api.listen.on('messageSend',
data
=> { ... });
* @example _converse.api.listen.on('messageSend',
message
=> { ... });
*/
_converse
.
api
.
trigger
(
'
messageSend
'
,
message
);
}
...
...
src/converse-omemo.js
View file @
1eb23643
...
...
@@ -192,15 +192,17 @@ converse.plugins.add('converse-omemo', {
const
attrs
=
this
.
getOutgoingMessageAttributes
(
text
,
spoiler_hint
);
attrs
[
'
is_encrypted
'
]
=
true
;
attrs
[
'
plaintext
'
]
=
attrs
.
message
;
let
message
,
stanza
;
try
{
const
devices
=
await
_converse
.
getBundlesAndBuildSessions
(
this
);
const
stanza
=
await
_converse
.
createOMEMOMessageStanza
(
this
,
this
.
messages
.
create
(
attrs
),
device
s
);
_converse
.
api
.
send
(
stanza
);
message
=
this
.
messages
.
create
(
attr
s
);
stanza
=
await
_converse
.
createOMEMOMessageStanza
(
this
,
message
,
devices
);
}
catch
(
e
)
{
this
.
handleMessageSendError
(
e
);
return
false
;
return
null
;
}
return
true
;
_converse
.
api
.
send
(
stanza
);
return
message
;
}
else
{
return
this
.
__super__
.
sendMessage
.
apply
(
this
,
arguments
);
}
...
...
src/headless/converse-chatboxes.js
View file @
1eb23643
...
...
@@ -705,13 +705,12 @@ converse.plugins.add('converse-chatboxes', {
},
/**
* Responsible for sending off a text message inside an ongoing
* chat conversation.
*
* Responsible for sending off a text message inside an ongoing chat conversation.
* @method _converse.ChatBox#sendMessage
* @memberOf _converse.ChatBox
* @param {String} text - The chat message text
* @param {String} spoiler_hint - An optional hint, if the message being sent is a spoiler
* @param { String } text - The chat message text
* @param { String } spoiler_hint - An optional hint, if the message being sent is a spoiler
* @returns { _converse.Message }
* @example
* const chat = _converse.api.chats.get('buddy1@example.com');
* chat.sendMessage('hello world');
...
...
@@ -735,7 +734,7 @@ converse.plugins.add('converse-chatboxes', {
message
=
this
.
messages
.
create
(
attrs
);
}
_converse
.
api
.
send
(
this
.
createMessageStanza
(
message
));
return
tru
e
;
return
messag
e
;
},
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment