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
dc0085bf
Commit
dc0085bf
authored
Jun 06, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All received MUC messages are "received" by definition
parent
690052e1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
11 deletions
+33
-11
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+8
-0
src/headless/converse-muc.js
src/headless/converse-muc.js
+25
-11
No files found.
src/headless/converse-chatboxes.js
View file @
dc0085bf
...
...
@@ -70,6 +70,13 @@ converse.plugins.add('converse-chatboxes', {
});
/**
* Represents a chat message
* @class
* @namespace _converse.Message
* @memberOf _converse
* @example const msg = new _converse.Message({'message': 'hello world!'});
*/
_converse
.
Message
=
ModelWithContact
.
extend
({
defaults
()
{
...
...
@@ -851,6 +858,7 @@ converse.plugins.add('converse-chatboxes', {
attrs
.
from
=
stanza
.
getAttribute
(
'
from
'
);
attrs
.
nick
=
Strophe
.
unescapeNode
(
Strophe
.
getResourceFromJid
(
attrs
.
from
));
attrs
.
sender
=
attrs
.
nick
===
this
.
get
(
'
nick
'
)
?
'
me
'
:
'
them
'
;
attrs
.
received
=
(
new
Date
()).
toISOString
();
}
else
{
attrs
.
from
=
Strophe
.
getBareJidFromJid
(
stanza
.
getAttribute
(
'
from
'
));
if
(
attrs
.
from
===
_converse
.
bare_jid
)
{
...
...
src/headless/converse-muc.js
View file @
dc0085bf
...
...
@@ -169,7 +169,6 @@ converse.plugins.add('converse-muc', {
/**
* Represents an open/ongoing groupchat conversation.
*
* @class
* @namespace _converse.ChatRoom
* @memberOf _converse
...
...
@@ -1200,17 +1199,36 @@ converse.plugins.add('converse-muc', {
* @param { Object } attrs - The message attributes
*/
ignorableCSN
(
attrs
)
{
const
is_csn
=
u
.
isOnlyChatStateNotification
(
attrs
),
own_message
=
Strophe
.
getResourceFromJid
(
attrs
.
from
)
==
this
.
get
(
'
nick
'
);
return
is_csn
&&
(
attrs
.
is_delayed
||
own_message
);
const
is_csn
=
u
.
isOnlyChatStateNotification
(
attrs
);
return
is_csn
&&
(
attrs
.
is_delayed
||
this
.
isOwnMessage
(
attrs
));
},
/**
* Determines whether the message is from ourselves by checking
* the `from` attribute. Doesn't check the `type` attribute.
* @private
* @method _converse.ChatRoom#isOwnMessage
* @param { Object|XMLElement|_converse.Message } msg
* @returns { boolean }
*/
isOwnMessage
(
msg
)
{
let
from
;
if
(
_
.
isElement
(
msg
))
{
from
=
msg
.
getAttribute
(
'
from
'
);
}
else
if
(
msg
instanceof
_converse
.
Message
)
{
from
=
msg
.
get
(
'
from
'
);
}
else
{
from
=
msg
.
from
;
}
return
Strophe
.
getResourceFromJid
(
from
)
==
this
.
get
(
'
nick
'
);
},
getUpdatedMessageAttributes
(
message
,
stanza
)
{
// Overridden in converse-muc and converse-mam
const
attrs
=
_converse
.
ChatBox
.
prototype
.
getUpdatedMessageAttributes
.
call
(
this
,
message
,
stanza
);
const
from
=
stanza
.
getAttribute
(
'
from
'
);
const
own_message
=
Strophe
.
getResourceFromJid
(
from
)
==
this
.
get
(
'
nick
'
);
if
(
own_message
)
{
if
(
this
.
isOwnMessage
(
message
))
{
const
stanza_id
=
sizzle
(
`stanza-id[xmlns="
${
Strophe
.
NS
.
SID
}
"]`
,
stanza
).
pop
();
const
by_jid
=
stanza_id
?
stanza_id
.
getAttribute
(
'
by
'
)
:
undefined
;
if
(
by_jid
)
{
...
...
@@ -1322,7 +1340,6 @@ converse.plugins.add('converse-muc', {
this
.
isChatMarker
(
stanza
))
{
return
_converse
.
api
.
trigger
(
'
message
'
,
{
'
stanza
'
:
original_stanza
});
}
let
attrs
=
await
this
.
getMessageAttributesFromStanza
(
stanza
,
original_stanza
);
if
(
attrs
.
nick
&&
!
this
.
subjectChangeHandled
(
attrs
)
&&
...
...
@@ -1332,9 +1349,6 @@ converse.plugins.add('converse-muc', {
attrs
=
this
.
addOccupantData
(
attrs
);
const
msg
=
this
.
correctMessage
(
attrs
)
||
this
.
messages
.
create
(
attrs
);
this
.
incrementUnreadMsgCounter
(
msg
);
if
(
forwarded
&&
msg
&&
msg
.
get
(
'
sender
'
)
===
'
me
'
)
{
msg
.
save
({
'
received
'
:
(
new
Date
()).
toISOString
()});
}
}
_converse
.
api
.
trigger
(
'
message
'
,
{
'
stanza
'
:
original_stanza
,
'
chatbox
'
:
this
});
},
...
...
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