Page MenuHomePhorge

Notifier.qml
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

Notifier.qml

/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.15
import 'matrix-helpers.js' as Helpers
import '.' as Kazv
QtObject {
id: notifier
property var notificationComp: Component {
Kazv.MessageNotification {
autoDelete: true
}
}
property var conn: Connections {
target: matrixSdk
function onReceivedMessage(roomId, eventId) {
const roomList = matrixSdk.roomList();
const room = roomList.room(roomId);
const event = room.messageById(eventId);
const sender = room.member(event.sender);
const senderName = sender.name || sender.userId || '';
if (matrixSdk.shouldNotify(event)) {
console.debug('Push rules say we should notify this');
const notification = notificationComp.createObject(
notifier,
{
roomId,
});
notification.eventId = matrixSdk.shouldPlaySound(event) ? 'message' : 'messageWithoutSound';
notification.title = Helpers.roomNameOrHeroes(room, l10n);
const message = event.content.body;
notification.text = message
? l10n.get('notification-message', { user: senderName, message })
: l10n.get('notification-message-no-content', { user: senderName });
notification.sendEvent();
} else {
console.debug('Push rules say we should not notify this');
}
}
}
}

File Metadata

Mime Type
text/plain
Expires
Tue, Jun 24, 4:36 PM (23 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
234934
Default Alt Text
Notifier.qml (1 KB)

Event Timeline