commit b1860ed29f1a862b2aac91ebb94a5ab102598993
parent ad76feb77df165264fe4e921e109d8cf6d051d28
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Mon,  1 Apr 2024 15:40:02 +0200

feat: map reaction content type

Diffstat:
Mcommon/src/main/assets/lang/en_US.json | 3++-
Mcommon/src/main/kotlin/me/rhunk/snapenhance/common/data/SnapEnums.kt | 4+++-
Mcommon/src/main/kotlin/me/rhunk/snapenhance/common/logger/AbstractLogger.kt | 2+-
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/downloader/decoder/MessageDecoder.kt | 24++++++++++++++----------
4 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -1036,7 +1036,8 @@ "FAMILY_CENTER_LEAVE": "Family Center Leave", "STATUS_PLUS_GIFT": "Status Plus Gift", "TINY_SNAP": "Tiny Snap", - "STATUS_COUNTDOWN": "Countdown" + "STATUS_COUNTDOWN": "Countdown", + "MAP_REACTION": "Map Reaction" }, "media_download_source": { diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/data/SnapEnums.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/data/SnapEnums.kt @@ -79,7 +79,8 @@ enum class ContentType(val id: Int) { EEL_UPGRADE_PROMPT(24), PROMPT_LENS_RESPONSE(25), TINY_SNAP(26), - STATUS_COUNTDOWN(27); + STATUS_COUNTDOWN(27), + MAP_REACTION(28); companion object { fun fromId(i: Int): ContentType { @@ -98,6 +99,7 @@ enum class ContentType(val id: Int) { contains(4) -> STICKER contains(5) -> SHARE contains(7) -> EXTERNAL_MEDIA // story replies + contains(20) -> MAP_REACTION else -> null } } diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/logger/AbstractLogger.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/logger/AbstractLogger.kt @@ -17,7 +17,7 @@ abstract class AbstractLogger( fun directError(message: Any?, throwable: Throwable, tag: String = TAG) { Log.println(Log.ERROR, tag, message.toString()) - Log.println(Log.ERROR, tag, throwable.toString()) + Log.println(Log.ERROR, tag, throwable.stackTraceToString()) } } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/downloader/decoder/MessageDecoder.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/downloader/decoder/MessageDecoder.kt @@ -100,7 +100,7 @@ object MessageDecoder { customMediaReferences?.let { mediaReferences.addAll(it) } var mediaKeyIndex = 0 - fun decodeMedia(type: AttachmentType, protoReader: ProtoReader) { + fun decodeSnapDocMediaPlayback(type: AttachmentType, protoReader: ProtoReader) { decodedAttachment.add( DecodedAttachment( mediaUrlKey = mediaReferences.getOrNull(mediaKeyIndex++), @@ -110,9 +110,8 @@ object MessageDecoder { ) } - // for snaps, external media, and original story replies - fun decodeDirectMedia(type: AttachmentType, protoReader: ProtoReader) { - protoReader.followPath(5) { decodeMedia(type,this) } + fun decodeSnapDocMedia(type: AttachmentType, protoReader: ProtoReader) { + protoReader.followPath(5) { decodeSnapDocMediaPlayback(type,this) } } fun decodeSticker(protoReader: ProtoReader) { @@ -141,7 +140,7 @@ object MessageDecoder { mediaReader.apply { // external media eachBuffer(3, 3) { - decodeDirectMedia(AttachmentType.EXTERNAL_MEDIA, this) + decodeSnapDocMedia(AttachmentType.EXTERNAL_MEDIA, this) } // stickers @@ -149,7 +148,7 @@ object MessageDecoder { // shares followPath(5, 24, 2) { - decodeDirectMedia(AttachmentType.EXTERNAL_MEDIA, this) + decodeSnapDocMedia(AttachmentType.EXTERNAL_MEDIA, this) } // audio notes @@ -169,24 +168,29 @@ object MessageDecoder { followPath(7) { // original story reply followPath(3) { - decodeDirectMedia(AttachmentType.ORIGINAL_STORY, this) + decodeSnapDocMedia(AttachmentType.ORIGINAL_STORY, this) } // external medias followPath(12) { - eachBuffer(3) { decodeDirectMedia(AttachmentType.EXTERNAL_MEDIA, this) } + eachBuffer(3) { decodeSnapDocMedia(AttachmentType.EXTERNAL_MEDIA, this) } } // attached sticker followPath(13) { decodeSticker(this) } // attached audio note - followPath(15) { decodeMedia(AttachmentType.NOTE, this) } + followPath(15) { decodeSnapDocMediaPlayback(AttachmentType.NOTE, this) } } // snaps followPath(11) { - decodeDirectMedia(AttachmentType.SNAP, this) + decodeSnapDocMedia(AttachmentType.SNAP, this) + } + + // map reaction + followPath(20, 2) { + decodeSnapDocMedia(AttachmentType.EXTERNAL_MEDIA, this) } }