Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac6321aa3e | ||
|
|
e54429fa3b | ||
|
|
47f6e5a890 | ||
|
|
dd89b87aea | ||
|
|
d47e42401c | ||
|
|
39511a3224 | ||
|
|
1b7bbe4b8a | ||
|
|
00c221a805 |
@@ -9,6 +9,10 @@ on:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: build
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
increment-version:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -75,6 +79,13 @@ jobs:
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: Cache npm packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json', 'cinny/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-npm-
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
@@ -87,6 +98,15 @@ jobs:
|
||||
with:
|
||||
# Google removed the legacy `tools` package; v3 still tries to install it.
|
||||
packages: platform-tools
|
||||
|
||||
- name: Cache Gradle
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper/dists
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: ${{ runner.os }}-gradle-
|
||||
|
||||
- name: Install dependencies (root)
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
@@ -384,22 +384,29 @@ class MatrixSyncService : Service() {
|
||||
|
||||
val content = event.optJSONObject("content") ?: JSONObject()
|
||||
val encrypted = eventType == "m.room.encrypted"
|
||||
val msgtype = content.optString("msgtype")
|
||||
val rawBody = content.optString("body")
|
||||
val body = when {
|
||||
encrypted -> "Encrypted message"
|
||||
eventType == "m.sticker" -> "Sticker"
|
||||
else -> {
|
||||
val msgtype = content.optString("msgtype")
|
||||
val rawBody = content.optString("body")
|
||||
when (msgtype) {
|
||||
"m.image" -> "Photo"
|
||||
"m.video" -> rawBody.ifBlank { "Video" }
|
||||
"m.audio" -> rawBody.ifBlank { "Audio" }
|
||||
"m.file" -> rawBody.ifBlank { "File" }
|
||||
else -> rawBody.takeIf { it.isNotBlank() }
|
||||
}
|
||||
else -> when (msgtype) {
|
||||
"m.image" -> "Photo"
|
||||
"m.video" -> rawBody.ifBlank { "Video" }
|
||||
"m.audio" -> rawBody.ifBlank { "Audio" }
|
||||
"m.file" -> rawBody.ifBlank { "File" }
|
||||
else -> rawBody.takeIf { it.isNotBlank() }
|
||||
}
|
||||
} ?: continue
|
||||
|
||||
// Fetch an inline preview for image/sticker events. Plaintext only —
|
||||
// encrypted media can't be decrypted inside the raw-sync listener.
|
||||
val inlineImage =
|
||||
if (!encrypted && (msgtype == "m.image" || eventType == "m.sticker")) {
|
||||
resolveInlineImage(content, homeserver, token)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val profile = try {
|
||||
resolveProfile(sender, homeserver, token)
|
||||
} catch (e: Exception) {
|
||||
@@ -414,7 +421,7 @@ class MatrixSyncService : Service() {
|
||||
profile.displayName,
|
||||
body,
|
||||
profile.avatar,
|
||||
null,
|
||||
inlineImage,
|
||||
resolveGroupInfo(roomId, notifyCtx),
|
||||
)
|
||||
notifiedForRoom = true
|
||||
@@ -678,6 +685,37 @@ class MatrixSyncService : Service() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve an inline preview bitmap for an image/sticker event content.
|
||||
* Prefers a small thumbnail (keeps the notification light), falling back to the
|
||||
* full download. Only works for plaintext events — encrypted media can't be
|
||||
* decrypted inside the raw-sync listener.
|
||||
*/
|
||||
private fun resolveInlineImage(
|
||||
content: JSONObject,
|
||||
homeserver: String,
|
||||
token: String,
|
||||
): Bitmap? {
|
||||
val info = content.optJSONObject("info")
|
||||
val thumbnailMxc =
|
||||
info?.optString("thumbnail_url")?.takeIf { it.startsWith("mxc://") }
|
||||
?: info?.optJSONObject("thumbnail_file")?.optString("url")?.takeIf { it.startsWith("mxc://") }
|
||||
if (thumbnailMxc != null) {
|
||||
for (url in mxcToThumbnailUrls(thumbnailMxc, homeserver, 512)) {
|
||||
downloadBitmap(url, token)?.let { return it }
|
||||
}
|
||||
}
|
||||
val fullMxc =
|
||||
content.optString("url").takeIf { it.startsWith("mxc://") }
|
||||
?: content.optJSONObject("file")?.optString("url")?.takeIf { it.startsWith("mxc://") }
|
||||
if (fullMxc != null) {
|
||||
for (url in mxcToDownloadUrls(fullMxc, homeserver)) {
|
||||
downloadBitmap(url, token)?.let { return it }
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private data class NotificationGroupInfo(
|
||||
val groupId: String,
|
||||
val groupName: String,
|
||||
|
||||
+1
-1
Submodule cinny updated: 47979718eb...b16263b481
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paarrot",
|
||||
"version": "4.11.171",
|
||||
"version": "4.11.175",
|
||||
"description": "Paarrot - A Matrix client based on Cinny",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
Reference in New Issue
Block a user