mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
bridge getRulesIds
This commit is contained in:
@ -128,6 +128,10 @@ class BridgeService : Service() {
|
|||||||
return remoteSideContext.modDatabase.getRules(uuid).map { it.key }
|
return remoteSideContext.modDatabase.getRules(uuid).map { it.key }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getRuleIds(type: String): MutableList<String> {
|
||||||
|
return remoteSideContext.modDatabase.getRuleIds(type)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setRule(uuid: String, rule: String, state: Boolean) {
|
override fun setRule(uuid: String, rule: String, state: Boolean) {
|
||||||
remoteSideContext.modDatabase.setRule(uuid, rule, state)
|
remoteSideContext.modDatabase.setRule(uuid, rule, state)
|
||||||
}
|
}
|
||||||
|
@ -241,4 +241,14 @@ class ModDatabase(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getRuleIds(type: String): MutableList<String> {
|
||||||
|
return database.rawQuery("SELECT targetUuid FROM rules WHERE type = ?", arrayOf(type)).use { cursor ->
|
||||||
|
val ruleIds = mutableListOf<String>()
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
ruleIds.add(cursor.getStringOrNull("targetUuid")!!)
|
||||||
|
}
|
||||||
|
ruleIds
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -60,6 +60,13 @@ interface BridgeInterface {
|
|||||||
*/
|
*/
|
||||||
List<String> getRules(String uuid);
|
List<String> getRules(String uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all ids for a specific rule
|
||||||
|
* @param type rule type (MessagingRuleType)
|
||||||
|
* @return list of ids
|
||||||
|
*/
|
||||||
|
List<String> getRuleIds(String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update rule for a giver user or conversation
|
* Update rule for a giver user or conversation
|
||||||
*
|
*
|
||||||
|
@ -142,6 +142,10 @@ class BridgeClient(
|
|||||||
return service.getRules(targetUuid).map { MessagingRuleType.getByName(it) }
|
return service.getRules(targetUuid).map { MessagingRuleType.getByName(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getRuleIds(ruleType: MessagingRuleType): List<String> {
|
||||||
|
return service.getRuleIds(ruleType.key)
|
||||||
|
}
|
||||||
|
|
||||||
fun setRule(targetUuid: String, type: MessagingRuleType, state: Boolean)
|
fun setRule(targetUuid: String, type: MessagingRuleType, state: Boolean)
|
||||||
= service.setRule(targetUuid, type.key, state)
|
= service.setRule(targetUuid, type.key, state)
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class PinConversations : BridgeFileFeature("PinConversations", BridgeFileType.PI
|
|||||||
|
|
||||||
context.classCache.feedEntry.hookConstructor(HookStage.AFTER) { param ->
|
context.classCache.feedEntry.hookConstructor(HookStage.AFTER) { param ->
|
||||||
val instance = param.thisObject<Any>()
|
val instance = param.thisObject<Any>()
|
||||||
val conversationUUID = SnapUUID(instance.getObjectField("mConversationId"))
|
val conversationUUID = SnapUUID(instance.getObjectField("mConversationId") ?: return@hookConstructor)
|
||||||
val isPinned = exists(conversationUUID.toString())
|
val isPinned = exists(conversationUUID.toString())
|
||||||
if (isPinned) {
|
if (isPinned) {
|
||||||
instance.setObjectField("mPinnedTimestampMs", 1L)
|
instance.setObjectField("mPinnedTimestampMs", 1L)
|
||||||
|
@ -12,12 +12,10 @@ class CallbackMapper : AbstractClassMapper() {
|
|||||||
if (clazz.superclass == null) return@filter false
|
if (clazz.superclass == null) return@filter false
|
||||||
|
|
||||||
val superclassName = clazz.getSuperClassName()!!
|
val superclassName = clazz.getSuperClassName()!!
|
||||||
if (!superclassName.endsWith("Callback") || superclassName.endsWith("\$Callback")) return@filter false
|
if ((!superclassName.endsWith("Callback") && !superclassName.endsWith("Delegate")) || superclassName.endsWith("\$Callback")) return@filter false
|
||||||
|
|
||||||
val superClass = context.getClass(clazz.superclass) ?: return@filter false
|
val superClass = context.getClass(clazz.superclass) ?: return@filter false
|
||||||
if (superClass.isFinal()) return@filter false
|
!superClass.isFinal()
|
||||||
|
|
||||||
superClass.virtualMethods.any { it.name == "onError" }
|
|
||||||
}.map {
|
}.map {
|
||||||
it.getSuperClassName()!!.substringAfterLast("/") to it.getClassName()
|
it.getSuperClassName()!!.substringAfterLast("/") to it.getClassName()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user