Index: lib/notification.js |
=================================================================== |
--- a/lib/notification.js |
+++ b/lib/notification.js |
@@ -128,45 +128,60 @@ let Notification = exports.Notification |
/** |
* Determines which notification is to be shown next. |
* @param {Array of Object} notifications active notifications |
* @return {Object} notification to be shown, or null if there is none |
*/ |
getNextToShow: function() |
{ |
+ function checkTarget(target, parameter, name, version) |
+ { |
+ let minVersionKey = parameter + "MinVersion"; |
+ let maxVersionKey = parameter + "MaxVersion"; |
+ return !((parameter in target && target[parameter] != name) || |
+ (minVersionKey in target && Services.vc.compare(version, target[minVersionKey]) < 0) || |
+ (maxVersionKey in target && Services.vc.compare(version, target[maxVersionKey]) > 0)); |
+ |
+ } |
+ |
if (typeof Prefs.notificationdata.data != "object" || !(Prefs.notificationdata.data.notifications instanceof Array)) |
return null; |
if (!(Prefs.notificationdata.shown instanceof Array)) |
{ |
Prefs.notificationdata.shown = []; |
saveNotificationData(); |
} |
- let {application, addonVersion} = require("info"); |
+ let {addonName, addonVersion, application, applicationVersion, platform, platformVersion} = require("info"); |
let notifications = Prefs.notificationdata.data.notifications; |
let notificationToShow = null; |
for each (let notification in notifications) |
{ |
if ((typeof notification.severity == "undefined" || notification.severity === "information") |
&& Prefs.notificationdata.shown.indexOf(notification.id) !== -1) |
continue; |
- if (notification.platforms instanceof Array |
- && notification.platforms.indexOf(application) === -1) |
- continue; |
- |
- if ("minVersion" in notification |
- && Services.vc.compare(addonVersion, notification.minVersion) < 0) |
- continue; |
- |
- if ("maxVersion" in notification |
- && Services.vc.compare(addonVersion, notification.maxVersion) > 0) |
- continue; |
+ if (notification.targets instanceof Array) |
+ { |
+ let match = false; |
+ for each (let target in notification.targets) |
+ { |
+ if (checkTarget(target, "extension", addonName, addonVersion) && |
+ checkTarget(target, "application", application, applicationVersion) && |
+ checkTarget(target, "platform", platform, platformVersion)) |
+ { |
+ match = true; |
+ break; |
+ } |
+ } |
+ if (!match) |
+ continue; |
+ } |
if (!notificationToShow |
|| getNumericalSeverity(notification) > getNumericalSeverity(notificationToShow)) |
notificationToShow = notification; |
} |
if (notificationToShow && "id" in notificationToShow) |
{ |