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
70135ba0
Commit
70135ba0
authored
Jun 16, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new config option `notify_all_room_messages`
parent
249fb0fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
docs/source/configuration.rst
docs/source/configuration.rst
+12
-0
src/converse-notification.js
src/converse-notification.js
+9
-6
No files found.
docs/source/configuration.rst
View file @
70135ba0
...
@@ -637,6 +637,18 @@ different approach.
...
@@ -637,6 +637,18 @@ different approach.
If you're using MAM for archiving chat room messages, you might want to set
If you're using MAM for archiving chat room messages, you might want to set
this option to zero.
this option to zero.
notify_all_room_messages
------------------------
* Default: ``false``
By default, sound and desktop notifications will only be made when you are
mentioned in a room. If you set this setting to `true`, then you will be
notified of all messages received in a room.
You can also pass an array of room JIDs to this option, to only apply it to
certain rooms.
notification_icon
notification_icon
-----------------
-----------------
...
...
src/converse-notification.js
View file @
70135ba0
...
@@ -18,8 +18,6 @@
...
@@ -18,8 +18,6 @@
var
__
=
utils
.
__
.
bind
(
converse
);
var
__
=
utils
.
__
.
bind
(
converse
);
var
___
=
utils
.
___
;
var
___
=
utils
.
___
;
var
supports_html5_notification
=
"
Notification
"
in
window
;
converse_api
.
plugins
.
add
(
'
converse-notification
'
,
{
converse_api
.
plugins
.
add
(
'
converse-notification
'
,
{
...
@@ -28,8 +26,10 @@
...
@@ -28,8 +26,10 @@
* loaded by converse.js's plugin machinery.
* loaded by converse.js's plugin machinery.
*/
*/
var
converse
=
this
.
converse
;
var
converse
=
this
.
converse
;
converse
.
supports_html5_notification
=
"
Notification
"
in
window
;
this
.
updateSettings
({
this
.
updateSettings
({
notify_all_room_messages
:
false
,
show_desktop_notifications
:
true
,
show_desktop_notifications
:
true
,
chatstate_notification_blacklist
:
[],
chatstate_notification_blacklist
:
[],
// ^ a list of JIDs to ignore concerning chat state notifications
// ^ a list of JIDs to ignore concerning chat state notifications
...
@@ -54,7 +54,8 @@
...
@@ -54,7 +54,8 @@
converse
.
shouldNotifyOfGroupMessage
=
function
(
$message
)
{
converse
.
shouldNotifyOfGroupMessage
=
function
(
$message
)
{
/* Is this a group message worthy of notification?
/* Is this a group message worthy of notification?
*/
*/
var
jid
=
$message
.
attr
(
'
from
'
),
var
notify_all
=
converse
.
notify_all_room_messages
,
jid
=
$message
.
attr
(
'
from
'
),
resource
=
Strophe
.
getResourceFromJid
(
jid
),
resource
=
Strophe
.
getResourceFromJid
(
jid
),
sender
=
resource
&&
Strophe
.
unescapeNode
(
resource
)
||
''
;
sender
=
resource
&&
Strophe
.
unescapeNode
(
resource
)
||
''
;
if
(
sender
===
''
||
$message
.
find
(
'
delay
'
).
length
>
0
)
{
if
(
sender
===
''
||
$message
.
find
(
'
delay
'
).
length
>
0
)
{
...
@@ -62,7 +63,9 @@
...
@@ -62,7 +63,9 @@
}
}
var
room
=
converse
.
chatboxes
.
get
(
Strophe
.
getBareJidFromJid
(
jid
));
var
room
=
converse
.
chatboxes
.
get
(
Strophe
.
getBareJidFromJid
(
jid
));
var
body
=
$message
.
children
(
'
body
'
).
text
();
var
body
=
$message
.
children
(
'
body
'
).
text
();
if
(
sender
===
room
.
get
(
'
nick
'
)
||
!
(
new
RegExp
(
"
\\
b
"
+
room
.
get
(
'
nick
'
)
+
"
\\
b
"
)).
test
(
body
))
{
var
mentioned
=
(
new
RegExp
(
"
\\
b
"
+
room
.
get
(
'
nick
'
)
+
"
\\
b
"
)).
test
(
body
);
notify_all
=
notify_all
===
true
||
(
_
.
isArray
(
notify_all
)
&&
_
.
contains
(
notify_all
,
jid
));
if
(
sender
===
room
.
get
(
'
nick
'
)
||
(
!
notify_all
&&
!
mentioned
))
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -107,7 +110,7 @@
...
@@ -107,7 +110,7 @@
};
};
converse
.
areDesktopNotificationsEnabled
=
function
(
ignore_blur
)
{
converse
.
areDesktopNotificationsEnabled
=
function
(
ignore_blur
)
{
var
enabled
=
supports_html5_notification
&&
var
enabled
=
converse
.
supports_html5_notification
&&
converse
.
show_desktop_notifications
&&
converse
.
show_desktop_notifications
&&
Notification
.
permission
===
"
granted
"
;
Notification
.
permission
===
"
granted
"
;
if
(
ignore_blur
)
{
if
(
ignore_blur
)
{
...
@@ -233,7 +236,7 @@
...
@@ -233,7 +236,7 @@
};
};
converse
.
requestPermission
=
function
(
evt
)
{
converse
.
requestPermission
=
function
(
evt
)
{
if
(
supports_html5_notification
&&
if
(
converse
.
supports_html5_notification
&&
!
_
.
contains
([
'
denied
'
,
'
granted
'
],
Notification
.
permission
))
{
!
_
.
contains
([
'
denied
'
,
'
granted
'
],
Notification
.
permission
))
{
// Ask user to enable HTML5 notifications
// Ask user to enable HTML5 notifications
Notification
.
requestPermission
();
Notification
.
requestPermission
();
...
...
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