Changeset View
Changeset View
Standalone View
Standalone View
src/contents/ui/Notifier.qml
| Show All 22 Lines | function onReceivedMessage(roomId, eventId) { | ||||
| const roomList = matrixSdk.roomList(); | const roomList = matrixSdk.roomList(); | ||||
| const room = roomList.room(roomId); | const room = roomList.room(roomId); | ||||
| const event = room.messageById(eventId); | const event = room.messageById(eventId); | ||||
| const sender = room.member(event.sender); | const sender = room.member(event.sender); | ||||
| const senderName = sender.name || sender.userId || ''; | const senderName = sender.name || sender.userId || ''; | ||||
| if (matrixSdk.shouldNotify(event)) { | if (matrixSdk.shouldNotify(event)) { | ||||
| console.debug('Push rules say we should notify this'); | console.debug('Push rules say we should notify this'); | ||||
| const notification = notificationComp.createObject(notifier); | const notification = notificationComp.createObject(notifier); | ||||
| notification.eventId = matrixSdk.shouldPlaySound(event) ? 'message' : 'messageWithoutSound'; | |||||
| notification.title = Helpers.roomNameOrHeroes(room, l10n); | notification.title = Helpers.roomNameOrHeroes(room, l10n); | ||||
| const message = event.content.body; | const message = event.content.body; | ||||
| notification.text = message | notification.text = message | ||||
| ? l10n.get('notification-message', { user: senderName, message }) | ? l10n.get('notification-message', { user: senderName, message }) | ||||
| : l10n.get('notification-message-no-content', { user: senderName }); | : l10n.get('notification-message-no-content', { user: senderName }); | ||||
| notification.sendEvent(); | notification.sendEvent(); | ||||
| } else { | } else { | ||||
| console.debug('Push rules say we should not notify this'); | console.debug('Push rules say we should not notify this'); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||