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
09457d84
Commit
09457d84
authored
Apr 28, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly handle notifications for groupchat messages
parent
902cf072
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
7 deletions
+43
-7
spec/notification.js
spec/notification.js
+33
-1
src/converse-notification.js
src/converse-notification.js
+10
-6
No files found.
spec/notification.js
View file @
09457d84
...
...
@@ -26,7 +26,7 @@
describe
(
"
And the desktop is not focused
"
,
function
()
{
describe
(
"
an HTML5 Notification
"
,
function
()
{
it
(
"
is shown when a new message is received
"
,
function
()
{
it
(
"
is shown when a new
private
message is received
"
,
function
()
{
// TODO: not yet testing show_desktop_notifications setting
spyOn
(
converse
,
'
showMessageNotification
'
);
spyOn
(
converse
,
'
areDesktopNotificationsEnabled
'
).
andReturn
(
true
);
...
...
@@ -45,6 +45,38 @@
expect
(
converse
.
showMessageNotification
).
toHaveBeenCalled
();
});
it
(
"
is shown when you are mentioned in a chat room
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
view
=
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
if
(
!
view
.
$el
.
find
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
var
no_notification
=
false
;
if
(
typeof
window
.
Notification
===
'
undefined
'
)
{
no_notification
=
true
;
window
.
Notification
=
function
()
{
return
{
'
close
'
:
function
()
{}
};
};
}
spyOn
(
converse
,
'
showMessageNotification
'
).
andCallThrough
();
spyOn
(
converse
,
'
areDesktopNotificationsEnabled
'
).
andReturn
(
true
);
var
message
=
'
dummy: This message will show a desktop notification
'
;
var
nick
=
mock
.
chatroom_names
[
0
],
msg
=
$msg
({
from
:
'
lounge@localhost/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
converse
.
chatboxes
.
onMessage
(
msg
);
// This will emit 'message'
expect
(
converse
.
areDesktopNotificationsEnabled
).
toHaveBeenCalled
();
expect
(
converse
.
showMessageNotification
).
toHaveBeenCalled
();
if
(
no_notification
)
{
delete
window
.
Notification
;
}
});
it
(
"
is shown when a user changes their chat state
"
,
function
()
{
// TODO: not yet testing show_desktop_notifications setting
spyOn
(
converse
,
'
areDesktopNotificationsEnabled
'
).
andReturn
(
true
);
...
...
src/converse-notification.js
View file @
09457d84
...
...
@@ -124,6 +124,9 @@
// XXX: 2nd check is workaround for Prosody which doesn't
// give type "headline"
title
=
__
(
___
(
"
Notification from %1$s
"
),
from_jid
);
}
else
{
if
(
$message
.
attr
(
'
type
'
)
===
'
groupchat
'
)
{
title
=
__
(
___
(
"
%1$s says
"
),
Strophe
.
getResourceFromJid
(
from_jid
));
}
else
{
if
(
typeof
converse
.
roster
===
'
undefined
'
)
{
converse
.
log
(
"
Could not send notification, because roster is undefined
"
,
"
error
"
);
...
...
@@ -133,6 +136,7 @@
roster_item
=
converse
.
roster
.
get
(
contact_jid
);
title
=
__
(
___
(
"
%1$s says
"
),
roster_item
.
get
(
'
fullname
'
));
}
}
n
=
new
Notification
(
title
,
{
body
:
$message
.
children
(
'
body
'
).
text
(),
lang
:
converse
.
i18n
.
locale_data
.
converse
[
""
].
lang
,
...
...
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