mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-02 07:34:25 +02:00
feat(core): exclude from message logger
Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
parent
9761d73ece
commit
31feea3d85
@ -285,6 +285,9 @@
|
|||||||
},
|
},
|
||||||
"pin_conversation": {
|
"pin_conversation": {
|
||||||
"name": "Pin Conversation"
|
"name": "Pin Conversation"
|
||||||
|
},
|
||||||
|
"exclude_message_logger": {
|
||||||
|
"name": "Exclude From Message Logger"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,7 @@ package me.rhunk.snapenhance.common.data
|
|||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.Message
|
||||||
import androidx.compose.material.icons.outlined.*
|
import androidx.compose.material.icons.outlined.*
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
@ -53,7 +54,8 @@ enum class MessagingRuleType(
|
|||||||
UNSAVEABLE_MESSAGES("unsaveable_messages", true, Icons.Outlined.FolderOff, defaultValue = null),
|
UNSAVEABLE_MESSAGES("unsaveable_messages", true, Icons.Outlined.FolderOff, defaultValue = null),
|
||||||
HIDE_FRIEND_FEED("hide_friend_feed", false, Icons.Outlined.VisibilityOff, showInFriendMenu = false),
|
HIDE_FRIEND_FEED("hide_friend_feed", false, Icons.Outlined.VisibilityOff, showInFriendMenu = false),
|
||||||
E2E_ENCRYPTION("e2e_encryption", false, Icons.Outlined.Lock),
|
E2E_ENCRYPTION("e2e_encryption", false, Icons.Outlined.Lock),
|
||||||
PIN_CONVERSATION("pin_conversation", false, Icons.Outlined.PushPin, showInFriendMenu = false);
|
PIN_CONVERSATION("pin_conversation", false, Icons.Outlined.PushPin, showInFriendMenu = false),
|
||||||
|
EXCLUDE_MESSAGE_LOGGER("exclude_message_logger", false, Icons.AutoMirrored.Filled.Message, showInFriendMenu = false);
|
||||||
|
|
||||||
fun translateOptionKey(optionKey: String): String {
|
fun translateOptionKey(optionKey: String): String {
|
||||||
return if (listMode) "rules.properties.$key.options.$optionKey" else "rules.properties.$key.name"
|
return if (listMode) "rules.properties.$key.options.$optionKey" else "rules.properties.$key.name"
|
||||||
|
@ -12,20 +12,22 @@ import me.rhunk.snapenhance.bridge.logger.LoggedChatEdit
|
|||||||
import me.rhunk.snapenhance.common.config.impl.MessagingTweaks
|
import me.rhunk.snapenhance.common.config.impl.MessagingTweaks
|
||||||
import me.rhunk.snapenhance.common.data.ContentType
|
import me.rhunk.snapenhance.common.data.ContentType
|
||||||
import me.rhunk.snapenhance.common.data.MessageState
|
import me.rhunk.snapenhance.common.data.MessageState
|
||||||
|
import me.rhunk.snapenhance.common.data.MessagingRuleType
|
||||||
import me.rhunk.snapenhance.common.data.QuotedMessageContentStatus
|
import me.rhunk.snapenhance.common.data.QuotedMessageContentStatus
|
||||||
|
import me.rhunk.snapenhance.common.data.RuleState
|
||||||
import me.rhunk.snapenhance.common.util.ktx.longHashCode
|
import me.rhunk.snapenhance.common.util.ktx.longHashCode
|
||||||
import me.rhunk.snapenhance.common.util.lazyBridge
|
import me.rhunk.snapenhance.common.util.lazyBridge
|
||||||
import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
|
import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
|
||||||
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
||||||
import me.rhunk.snapenhance.core.event.events.impl.BuildMessageEvent
|
import me.rhunk.snapenhance.core.event.events.impl.BuildMessageEvent
|
||||||
import me.rhunk.snapenhance.core.features.Feature
|
import me.rhunk.snapenhance.core.features.MessagingRuleFeature
|
||||||
import me.rhunk.snapenhance.core.ui.addForegroundDrawable
|
import me.rhunk.snapenhance.core.ui.addForegroundDrawable
|
||||||
import me.rhunk.snapenhance.core.ui.removeForegroundDrawable
|
import me.rhunk.snapenhance.core.ui.removeForegroundDrawable
|
||||||
import me.rhunk.snapenhance.core.util.EvictingMap
|
import me.rhunk.snapenhance.core.util.EvictingMap
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
class MessageLogger : Feature("MessageLogger") {
|
class MessageLogger : MessagingRuleFeature("MessageLogger", MessagingRuleType.EXCLUDE_MESSAGE_LOGGER) {
|
||||||
companion object {
|
companion object {
|
||||||
const val PREFETCH_MESSAGE_COUNT = 20
|
const val PREFETCH_MESSAGE_COUNT = 20
|
||||||
const val PREFETCH_FEED_COUNT = 20
|
const val PREFETCH_FEED_COUNT = 20
|
||||||
@ -128,6 +130,11 @@ class MessageLogger : Feature("MessageLogger") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
threadPool.execute {
|
threadPool.execute {
|
||||||
|
// ignore excluded conversations
|
||||||
|
if (getState(conversationId)) {
|
||||||
|
return@execute
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loggerInterface.addMessage(
|
loggerInterface.addMessage(
|
||||||
BridgeLoggedMessage().also {
|
BridgeLoggedMessage().also {
|
||||||
@ -144,7 +151,7 @@ class MessageLogger : Feature("MessageLogger") {
|
|||||||
it.messageData = context.gson.toJson(messageInstance).toByteArray(Charsets.UTF_8)
|
it.messageData = context.gson.toJson(messageInstance).toByteArray(Charsets.UTF_8)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} catch (ignored: DeadObjectException) {}
|
} catch (_: DeadObjectException) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return@subscribe
|
return@subscribe
|
||||||
@ -193,4 +200,6 @@ class MessageLogger : Feature("MessageLogger") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getRuleState() = RuleState.WHITELIST
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user