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
e2001896
Commit
e2001896
authored
Sep 30, 2015
by
Christoph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix outgoing chat messages not having a msgid when being put into sessionStorage, fixes #467
parent
57a30917
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
15 deletions
+23
-15
converse.js
converse.js
+20
-13
docs/CHANGES.rst
docs/CHANGES.rst
+1
-0
spec/chatbox.js
spec/chatbox.js
+1
-1
src/templates/message.html
src/templates/message.html
+1
-1
No files found.
converse.js
View file @
e2001896
...
@@ -932,7 +932,14 @@
...
@@ -932,7 +932,14 @@
}
}
});
});
this
.
Message
=
Backbone
.
Model
;
this
.
Message
=
Backbone
.
Model
.
extend
({
idAttribute
:
'
msgid
'
,
defaults
:
function
(){
return
{
msgid
:
converse
.
connection
.
getUniqueId
()
};
}
});
this
.
Messages
=
Backbone
.
Collection
.
extend
({
this
.
Messages
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
Message
,
model
:
converse
.
Message
,
comparator
:
'
time
'
comparator
:
'
time
'
...
@@ -1087,7 +1094,7 @@
...
@@ -1087,7 +1094,7 @@
this
.
trigger
(
'
showReceivedOTRMessage
'
,
msg
);
this
.
trigger
(
'
showReceivedOTRMessage
'
,
msg
);
}.
bind
(
this
));
}.
bind
(
this
));
this
.
otr
.
on
(
'
io
'
,
function
(
msg
)
{
this
.
otr
.
on
(
'
io
'
,
function
(
msg
)
{
this
.
trigger
(
'
sendMessage
'
,
msg
);
this
.
trigger
(
'
sendMessage
'
,
new
converse
.
Message
({
message
:
msg
})
);
}.
bind
(
this
));
}.
bind
(
this
));
this
.
otr
.
on
(
'
error
'
,
function
(
msg
)
{
this
.
otr
.
on
(
'
error
'
,
function
(
msg
)
{
this
.
trigger
(
'
showOTRError
'
,
msg
);
this
.
trigger
(
'
showOTRError
'
,
msg
);
...
@@ -1498,6 +1505,7 @@
...
@@ -1498,6 +1505,7 @@
extra_classes
+=
'
mentioned
'
;
extra_classes
+=
'
mentioned
'
;
}
}
return
$
(
template
({
return
$
(
template
({
msgid
:
attrs
.
msgid
,
'
sender
'
:
attrs
.
sender
,
'
sender
'
:
attrs
.
sender
,
'
time
'
:
msg_time
.
format
(
'
hh:mm
'
),
'
time
'
:
msg_time
.
format
(
'
hh:mm
'
),
'
isodate
'
:
msg_time
.
format
(),
'
isodate
'
:
msg_time
.
format
(),
...
@@ -1553,30 +1561,29 @@
...
@@ -1553,30 +1561,29 @@
}
}
},
},
sendMessage
:
function
(
text
)
{
sendMessage
:
function
(
message
)
{
/* Responsible for sending off a text message.
/* Responsible for sending off a text message.
*
*
* Parameters:
* Parameters:
* (
string) text - The chat message text.
* (
Message) message - The chat message
*/
*/
// TODO: We might want to send to specfic resources. Especially in the OTR case.
// TODO: We might want to send to specfic resources. Especially in the OTR case.
var
timestamp
=
(
new
Date
()).
getTime
();
var
bare_jid
=
this
.
model
.
get
(
'
jid
'
);
var
bare_jid
=
this
.
model
.
get
(
'
jid
'
);
var
message
=
$msg
({
from
:
converse
.
connection
.
jid
,
to
:
bare_jid
,
type
:
'
chat
'
,
id
:
timestamp
})
var
message
Stanza
=
$msg
({
from
:
converse
.
connection
.
jid
,
to
:
bare_jid
,
type
:
'
chat
'
,
id
:
message
.
get
(
'
msgid
'
)
})
.
c
(
'
body
'
).
t
(
text
).
up
()
.
c
(
'
body
'
).
t
(
message
.
get
(
'
message
'
)
).
up
()
.
c
(
ACTIVE
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
();
.
c
(
ACTIVE
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
();
if
(
this
.
model
.
get
(
'
otr_status
'
)
!=
UNENCRYPTED
)
{
if
(
this
.
model
.
get
(
'
otr_status
'
)
!=
UNENCRYPTED
)
{
// OTR messages aren't carbon copied
// OTR messages aren't carbon copied
message
.
c
(
'
private
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CARBONS
});
message
Stanza
.
c
(
'
private
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CARBONS
});
}
}
converse
.
connection
.
send
(
message
);
converse
.
connection
.
send
(
message
Stanza
);
if
(
converse
.
forward_messages
)
{
if
(
converse
.
forward_messages
)
{
// Forward the message, so that other connected resources are also aware of it.
// Forward the message, so that other connected resources are also aware of it.
var
forwarded
=
$msg
({
to
:
converse
.
bare_jid
,
type
:
'
chat
'
,
id
:
timestamp
})
var
forwarded
=
$msg
({
to
:
converse
.
bare_jid
,
type
:
'
chat
'
,
id
:
message
.
get
(
'
msgid
'
)
})
.
c
(
'
forwarded
'
,
{
xmlns
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
forwarded
'
,
{
xmlns
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
delay
'
,
{
xmns
:
'
urn:xmpp:delay
'
,
stamp
:
timestamp
}).
up
()
.
c
(
'
delay
'
,
{
xmns
:
'
urn:xmpp:delay
'
,
stamp
:
timestamp
}).
up
()
.
cnode
(
message
.
tree
());
.
cnode
(
message
Stanza
.
tree
());
converse
.
connection
.
send
(
forwarded
);
converse
.
connection
.
send
(
forwarded
);
}
}
},
},
...
@@ -1618,13 +1625,13 @@
...
@@ -1618,13 +1625,13 @@
// We only save unencrypted messages.
// We only save unencrypted messages.
var
fullname
=
converse
.
xmppstatus
.
get
(
'
fullname
'
);
var
fullname
=
converse
.
xmppstatus
.
get
(
'
fullname
'
);
fullname
=
_
.
isEmpty
(
fullname
)?
converse
.
bare_jid
:
fullname
;
fullname
=
_
.
isEmpty
(
fullname
)?
converse
.
bare_jid
:
fullname
;
this
.
model
.
messages
.
create
({
var
message
=
this
.
model
.
messages
.
create
({
fullname
:
fullname
,
fullname
:
fullname
,
sender
:
'
me
'
,
sender
:
'
me
'
,
time
:
moment
().
format
(),
time
:
moment
().
format
(),
message
:
text
message
:
text
});
});
this
.
sendMessage
(
text
);
this
.
sendMessage
(
message
);
}
}
},
},
...
...
docs/CHANGES.rst
View file @
e2001896
...
@@ -8,6 +8,7 @@ Changelog
...
@@ -8,6 +8,7 @@ Changelog
* #468 Fix [object Object] being sometimes shown as status [1st8]
* #468 Fix [object Object] being sometimes shown as status [1st8]
* #493 Roster wasn't being updated after a Roster push update [teseo, jcbrand]
* #493 Roster wasn't being updated after a Roster push update [teseo, jcbrand]
* #496 Bugfix. Pings weren't being sent out. [teseo, jcbrand]
* #496 Bugfix. Pings weren't being sent out. [teseo, jcbrand]
* #467 Fix outgoing chat messages not having a msgid when being put into sessionStorage [1st8]
0.9.5 (2015-08-24)
0.9.5 (2015-08-24)
------------------
------------------
...
...
spec/chatbox.js
View file @
e2001896
...
@@ -779,7 +779,7 @@
...
@@ -779,7 +779,7 @@
var
chatbox
=
converse
.
chatboxes
.
get
(
sender_jid
);
var
chatbox
=
converse
.
chatboxes
.
get
(
sender_jid
);
spyOn
(
converse
.
connection
,
'
send
'
);
spyOn
(
converse
.
connection
,
'
send
'
);
chatbox
.
set
(
'
otr_status
'
,
1
);
// Set OTR status to UNVERIFIED, to mock an encrypted session
chatbox
.
set
(
'
otr_status
'
,
1
);
// Set OTR status to UNVERIFIED, to mock an encrypted session
chatbox
.
trigger
(
'
sendMessage
'
,
msgtext
);
chatbox
.
trigger
(
'
sendMessage
'
,
new
converse
.
Message
({
message
:
msgtext
})
);
var
$sent
=
$
(
converse
.
connection
.
send
.
argsForCall
[
0
][
0
].
tree
());
var
$sent
=
$
(
converse
.
connection
.
send
.
argsForCall
[
0
][
0
].
tree
());
expect
(
$sent
.
find
(
'
body
'
).
siblings
(
'
private
'
).
length
).
toBe
(
1
);
expect
(
$sent
.
find
(
'
body
'
).
siblings
(
'
private
'
).
length
).
toBe
(
1
);
expect
(
$sent
.
find
(
'
private
'
).
length
).
toBe
(
1
);
expect
(
$sent
.
find
(
'
private
'
).
length
).
toBe
(
1
);
...
...
src/templates/message.html
View file @
e2001896
<div
class=
"chat-message {{extra_classes}}"
data-isodate=
"{{isodate}}"
>
<div
class=
"chat-message {{extra_classes}}"
data-isodate=
"{{isodate}}"
data-msgid=
"{{msgid}}"
>
<span
class=
"chat-message-{{sender}}"
>
{{time}} {{username}}:
</span>
<span
class=
"chat-message-{{sender}}"
>
{{time}} {{username}}:
</span>
<span
class=
"chat-message-content"
>
{{message}}
</span>
<span
class=
"chat-message-content"
>
{{message}}
</span>
</div>
</div>
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