Compare commits

..
12 Commits
Author SHA1 Message Date
GitHub Actions 9be4ee4225 chore: bump version to 4.11.182 [skip ci] 2026-10-06 00:11:46 +00:00
GitHub Actions 8c20c3d3a6 Bump cinny: Show cached spaces on the loading splash until the chats are ready
Build / increment-version (push) Successful in 5s
Build / build-android (push) Successful in 2m30s
2026-10-06 00:11:41 +00:00
GitHub Actions 9b97fb8c32 chore: bump version to 4.11.181 [skip ci] 2026-10-05 23:44:15 +00:00
litruv cef9f28dfd notifications: show reaction emoji as icon + quoted message snippet
Build / increment-version (push) Successful in 5s
Build / build-android (push) Successful in 4m47s
Reaction notifications previously had no icon and a generic body. Now the
reaction emoji is rendered as the notification icon and the body quotes the
reacted-to message. Applied to both the web/Electron/Tauri path and the
Android background sync service.
2026-10-06 10:43:12 +11:00
GitHub Actions 96d5ae40e1 chore: bump version to 4.11.180 [skip ci] 2026-10-05 21:04:21 +00:00
GitHub Actions 8f64937367 Bump cinny: Skip sourcemap generation in CI builds
Build / increment-version (push) Successful in 4s
Build / build-android (push) Successful in 6m24s
2026-10-05 21:04:14 +00:00
GitHub Actions 441de85b82 chore: bump version to 4.11.179 [skip ci] 2026-10-05 20:50:06 +00:00
GitHub Actions 7277ecf589 Bump cinny: Add 4.11.193 update notes for the shared profile cache.
Build / increment-version (push) Successful in 6s
Build / build-android (push) Successful in 6m59s
2026-10-05 20:49:57 +00:00
GitHub Actions 2a8cc22ff9 chore: bump version to 4.11.178 [skip ci] 2026-10-05 20:43:07 +00:00
GitHub Actions 72c933ca61 Bump cinny: Cache profile fields and assets behind one shared store.
Build / increment-version (push) Successful in 4s
Build / build-android (push) Canceled after 6m50s
2026-10-05 20:43:02 +00:00
GitHub Actions 68d834cd72 chore: bump version to 4.11.177 [skip ci] 2026-10-05 13:38:15 +00:00
GitHub Actions e6adb35e5b Bump cinny: Open the last seen channel on startup.
Build / increment-version (push) Successful in 4s
Build / build-android (push) Successful in 6m56s
2026-10-05 13:38:10 +00:00
4 changed files with 137 additions and 9 deletions
@@ -377,12 +377,50 @@ class MatrixSyncService : Service() {
val isMessageLike = val isMessageLike =
eventType == "m.room.message" || eventType == "m.room.message" ||
eventType == "m.room.encrypted" || eventType == "m.room.encrypted" ||
eventType == "m.sticker" eventType == "m.sticker" ||
eventType == "m.reaction"
if (!isMessageLike) continue if (!isMessageLike) continue
if (sender.isNotBlank() && sender == myUserId) continue if (sender.isNotBlank() && sender == myUserId) continue
if (eventId.isNotBlank() && !shownEventIds.add(eventId)) continue if (eventId.isNotBlank() && !shownEventIds.add(eventId)) continue
val content = event.optJSONObject("content") ?: JSONObject() val content = event.optJSONObject("content") ?: JSONObject()
// Reactions have no media, so use the emoji as the icon and quote the
// reacted-to message as the body.
if (eventType == "m.reaction") {
val relates = content.optJSONObject("m.relates_to")
val key = relates?.optString("key").orEmpty()
if (key.isBlank()) continue
val parentEventId = relates?.optString("event_id").orEmpty()
val snippet =
if (parentEventId.isNotBlank())
fetchEventBodySnippet(homeserver, token, roomId, parentEventId)
else ""
val reactionBody =
if (snippet.isNotBlank()) "reacted with $key to \"$snippet\""
else "reacted with $key"
val profile = try {
resolveProfile(sender, homeserver, token)
} catch (e: Exception) {
Log.w(TAG, "profile fetch failed: ${e.message}")
UserProfile(sender.substringAfter("@").substringBefore(":").ifBlank { "Someone" }, null)
}
Log.i(TAG, "notify room=$roomId type=$eventType sender=$sender")
showMessageNotification(
nm,
roomId,
profile.displayName,
reactionBody,
renderEmojiBitmap(key),
null,
resolveGroupInfo(roomId, notifyCtx),
)
notifiedForRoom = true
continue
}
val encrypted = eventType == "m.room.encrypted" val encrypted = eventType == "m.room.encrypted"
val msgtype = content.optString("msgtype") val msgtype = content.optString("msgtype")
val rawBody = content.optString("body") val rawBody = content.optString("body")
@@ -587,6 +625,25 @@ class MatrixSyncService : Service() {
} }
} }
/** Fetch the body of the event a reaction points at, as a short single-line snippet. */
private fun fetchEventBodySnippet(
homeserver: String,
token: String,
roomId: String,
eventId: String,
maxLength: Int = 60,
): String {
val obj = fetchJson(
"$homeserver/_matrix/client/v3/rooms/${urlEncode(roomId)}/event/${urlEncode(eventId)}",
token,
) ?: return ""
val content = obj.optJSONObject("content") ?: return ""
val rawBody = content.optString("body")
if (rawBody.isBlank()) return ""
val trimmed = rawBody.replace(Regex("\\s+"), " ").trim()
return if (trimmed.length > maxLength) trimmed.substring(0, maxLength) + "…" else trimmed
}
private fun resolveProfile(mxid: String, homeserver: String, token: String): UserProfile { private fun resolveProfile(mxid: String, homeserver: String, token: String): UserProfile {
val cachedName = displayNameCache[mxid] val cachedName = displayNameCache[mxid]
if (cachedName != null) return UserProfile(cachedName, avatarCache[mxid]) if (cachedName != null) return UserProfile(cachedName, avatarCache[mxid])
@@ -1164,6 +1221,25 @@ class MatrixSyncService : Service() {
} }
} }
/** Render a reaction emoji to a bitmap so it can be used as the notification icon. */
fun renderEmojiBitmap(emoji: String): Bitmap? {
return try {
val size = 128
val bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
paint.textSize = size * 0.7f
paint.textAlign = Paint.Align.CENTER
val fontMetrics = paint.fontMetrics
val y = size / 2f - (fontMetrics.ascent + fontMetrics.descent) / 2f
canvas.drawText(emoji, size / 2f, y, paint)
bitmap
} catch (e: Exception) {
Log.w(TAG, "Failed to render emoji icon: ${e.message}")
null
}
}
/** Crop a bitmap into a circle for the notification avatar slot. */ /** Crop a bitmap into a circle for the notification avatar slot. */
fun toCircularBitmap(bitmap: Bitmap): Bitmap { fun toCircularBitmap(bitmap: Bitmap): Bitmap {
val size = minOf(bitmap.width, bitmap.height) val size = minOf(bitmap.width, bitmap.height)
+1 -1
Submodule cinny updated: b16263b481...95d1cb9630
@@ -104,14 +104,52 @@ async function waitForEventDecryption(mx: MatrixClient, mEvent: MatrixEvent) {
}); });
} }
/** Short, single-line snippet of an event's body for use inside a notification. */
function eventBodySnippet(mEvent: MatrixEvent, maxLength = 60): string {
const content = mEvent.getClearContent() ?? mEvent.getContent();
const rawBody = typeof content.body === 'string' ? content.body : '';
if (!rawBody) return '';
const trimmed = rawBody.replace(/\s+/g, ' ').trim();
return trimmed.length > maxLength ? `${trimmed.slice(0, maxLength)}…` : trimmed;
}
/** Render a reaction emoji to a PNG base64 string so it can be used as the notification icon. */
async function renderEmojiToBase64(emoji: string): Promise<string | undefined> {
try {
const size = 128;
const canvas = document.createElement('canvas');
canvas.width = size;
canvas.height = size;
const ctx = canvas.getContext('2d');
if (!ctx) return undefined;
ctx.font = `${Math.floor(size * 0.7)}px "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`;
ctx.textBaseline = 'middle';
ctx.textAlign = 'center';
ctx.fillText(emoji, size / 2, size / 2);
const dataUrl = canvas.toDataURL('image/png');
return dataUrl.split(',')[1];
} catch (err) {
console.warn('[Notifications] Failed to render emoji icon:', err);
return undefined;
}
}
/** Build a human-readable notification body from (possibly decrypted) event content. */ /** Build a human-readable notification body from (possibly decrypted) event content. */
function notificationBodyFromEvent(mEvent: MatrixEvent): string | undefined { function notificationBodyFromEvent(mx: MatrixClient, mEvent: MatrixEvent): string | undefined {
const content = mEvent.getClearContent() ?? mEvent.getContent(); const content = mEvent.getClearContent() ?? mEvent.getContent();
const eventType = mEvent.getType(); const eventType = mEvent.getType();
if (eventType === 'm.reaction') { if (eventType === 'm.reaction') {
const reactionKey = content['m.relates_to']?.key; const relates = content['m.relates_to'];
return reactionKey ? `reacted with ${reactionKey}` : 'reacted to a message'; const reactionKey = relates?.key;
const parent = relates?.event_id ? mx.getCachedEventById(relates.event_id) : undefined;
const snippet = parent ? eventBodySnippet(parent) : '';
if (reactionKey && snippet) return `reacted with ${reactionKey} to "${snippet}"`;
if (reactionKey) return `reacted with ${reactionKey}`;
return 'reacted to a message';
} }
if (eventType === 'm.room.encrypted' || mEvent.isDecryptionFailure()) { if (eventType === 'm.room.encrypted' || mEvent.isDecryptionFailure()) {
@@ -684,12 +722,26 @@ function MessageNotifications() {
: Promise.resolve(undefined), : Promise.resolve(undefined),
]); ]);
const messageBody = notificationBodyFromEvent(mEvent); // Reactions have no media, so render the reaction emoji as the notification icon.
let finalIconBase64 = iconBase64;
let finalRoomAvatar = roomAvatar;
if (mEvent.getType() === 'm.reaction') {
const emoji = (mEvent.getClearContent() ?? mEvent.getContent())['m.relates_to']?.key;
if (emoji) {
const emojiBase64 = await renderEmojiToBase64(emoji);
if (emojiBase64) {
finalIconBase64 = emojiBase64;
finalRoomAvatar = `data:image/png;base64,${emojiBase64}`;
}
}
}
const messageBody = notificationBodyFromEvent(mx, mEvent);
notify({ notify({
roomName: room.name ?? 'Unknown', roomName: room.name ?? 'Unknown',
roomAvatar, roomAvatar: finalRoomAvatar,
iconBase64, iconBase64: finalIconBase64,
bigPictureBase64, bigPictureBase64,
username, username,
messageBody, messageBody,
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "paarrot", "name": "paarrot",
"version": "4.11.176", "version": "4.11.182",
"description": "Paarrot - A Matrix client based on Cinny", "description": "Paarrot - A Matrix client based on Cinny",
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"