notificationDaemon: Include timestamp in serialized notifications

GNotifications are persistent until dismissed or withdrawn, including
across restarts. As we show the time a notification was received in the
calendar, we need to include that information when serializing the
notification in order to be correct.

https://bugzilla.gnome.org/show_bug.cgi?id=775799
This commit is contained in:
Florian Müllner 2017-02-27 00:15:29 +01:00
parent 0569bb18f5
commit 4e491b6f75

View File

@ -600,7 +600,8 @@ const GtkNotificationDaemonNotification = new Lang.Class({
"priority": priority, "priority": priority,
"buttons": buttons, "buttons": buttons,
"default-action": defaultAction, "default-action": defaultAction,
"default-action-target": defaultActionTarget } = notification; "default-action-target": defaultActionTarget,
"timestamp": time } = notification;
if (priority) { if (priority) {
let urgency = PRIORITY_URGENCY_MAP[priority.unpack()]; let urgency = PRIORITY_URGENCY_MAP[priority.unpack()];
@ -623,7 +624,8 @@ const GtkNotificationDaemonNotification = new Lang.Class({
this._defaultActionTarget = defaultActionTarget; this._defaultActionTarget = defaultActionTarget;
this.update(title.unpack(), body ? body.unpack() : null, this.update(title.unpack(), body ? body.unpack() : null,
{ gicon: gicon ? Gio.icon_deserialize(gicon) : null }); { gicon: gicon ? Gio.icon_deserialize(gicon) : null,
datetime : time ? GLib.DateTime.new_from_unix_local(time.unpack()) : null });
}, },
_activateAction: function(namespacedActionId, target) { _activateAction: function(namespacedActionId, target) {
@ -864,6 +866,9 @@ const GtkNotificationDaemon = new Lang.Class({
return; return;
} }
let timestamp = GLib.DateTime.new_now_local().to_unix();
notification['timestamp'] = new GLib.Variant('x', timestamp);
source.addNotification(notificationId, notification, true); source.addNotification(notificationId, notification, true);
invocation.return_value(null); invocation.return_value(null);