notifservice: remove json persistence (plaintext notification bodies are a security concern)
This commit is contained in:
parent
ce14a170a5
commit
7fbd186b4a
1 changed files with 0 additions and 57 deletions
|
|
@ -2,7 +2,6 @@ pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
import "." as M
|
import "." as M
|
||||||
|
|
||||||
|
|
@ -26,7 +25,6 @@ QtObject {
|
||||||
list = list.filter(n => n !== item);
|
list = list.filter(n => n !== item);
|
||||||
delete _byId[notifId];
|
delete _byId[notifId];
|
||||||
item.destroy();
|
item.destroy();
|
||||||
_saveTimer.restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissAll() {
|
function dismissAll() {
|
||||||
|
|
@ -36,7 +34,6 @@ QtObject {
|
||||||
item.destroy();
|
item.destroy();
|
||||||
}
|
}
|
||||||
list = [];
|
list = [];
|
||||||
_saveTimer.restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissPopup(notifId) {
|
function dismissPopup(notifId) {
|
||||||
|
|
@ -129,7 +126,6 @@ QtObject {
|
||||||
NotifItem {}
|
NotifItem {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Persistence
|
|
||||||
// Single global tick for all NotifItem.timeStr bindings — replaces per-item 5s timers
|
// Single global tick for all NotifItem.timeStr bindings — replaces per-item 5s timers
|
||||||
property real _now: Date.now()
|
property real _now: Date.now()
|
||||||
property Timer _nowTimer: Timer {
|
property Timer _nowTimer: Timer {
|
||||||
|
|
@ -138,57 +134,4 @@ QtObject {
|
||||||
interval: 5000
|
interval: 5000
|
||||||
onTriggered: root._now = Date.now()
|
onTriggered: root._now = Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
property Timer _saveTimer: Timer {
|
|
||||||
interval: 1000
|
|
||||||
onTriggered: {
|
|
||||||
const data = root.list.filter(n => n.state !== "dismissed").map(n => ({
|
|
||||||
id: n.id,
|
|
||||||
summary: n.summary,
|
|
||||||
body: n.body,
|
|
||||||
appName: n.appName,
|
|
||||||
appIcon: n.appIcon,
|
|
||||||
image: n.image,
|
|
||||||
urgency: n.urgency,
|
|
||||||
time: n.time
|
|
||||||
}));
|
|
||||||
_storage.setText(JSON.stringify(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property FileView _storage: FileView {
|
|
||||||
path: (Quickshell.env("XDG_STATE_HOME") || (Quickshell.env("HOME") + "/.local/state")) + "/nova-shell/notifs.json"
|
|
||||||
onLoaded: {
|
|
||||||
try {
|
|
||||||
const data = JSON.parse(text());
|
|
||||||
const maxHistory = M.Modules.notifications.maxHistory ?? -1;
|
|
||||||
const limit = maxHistory > 0 ? Math.min(data.length, maxHistory) : data.length;
|
|
||||||
for (let i = 0; i < limit; i++) {
|
|
||||||
const n = data[i];
|
|
||||||
const item = _itemComp.createObject(root, {
|
|
||||||
id: "p_" + (n.id ?? i) + "_" + n.time,
|
|
||||||
summary: n.summary || "",
|
|
||||||
body: n.body || "",
|
|
||||||
appName: n.appName || "",
|
|
||||||
appIcon: n.appIcon || "",
|
|
||||||
image: n.image || "",
|
|
||||||
urgency: n.urgency ?? 1,
|
|
||||||
time: n.time || Date.now(),
|
|
||||||
popup: false,
|
|
||||||
actions: []
|
|
||||||
});
|
|
||||||
root._byId[item.id] = item;
|
|
||||||
root.list.push(item);
|
|
||||||
}
|
|
||||||
root.list.sort((a, b) => {
|
|
||||||
const aU = a.urgency === NotificationUrgency.Critical ? 1 : 0;
|
|
||||||
const bU = b.urgency === NotificationUrgency.Critical ? 1 : 0;
|
|
||||||
if (aU !== bU)
|
|
||||||
return bU - aU;
|
|
||||||
return b.time - a.time;
|
|
||||||
});
|
|
||||||
root._changed();
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue