bridge getRulesIds

This commit is contained in:
rhunk
2023-09-01 19:19:25 +02:00
parent 24fc945f1a
commit 600dec7fc6
6 changed files with 28 additions and 5 deletions

View File

@ -60,6 +60,13 @@ interface BridgeInterface {
*/
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
*

View File

@ -142,6 +142,10 @@ class BridgeClient(
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)
= service.setRule(targetUuid, type.key, state)
}

View File

@ -29,7 +29,7 @@ class PinConversations : BridgeFileFeature("PinConversations", BridgeFileType.PI
context.classCache.feedEntry.hookConstructor(HookStage.AFTER) { param ->
val instance = param.thisObject<Any>()
val conversationUUID = SnapUUID(instance.getObjectField("mConversationId"))
val conversationUUID = SnapUUID(instance.getObjectField("mConversationId") ?: return@hookConstructor)
val isPinned = exists(conversationUUID.toString())
if (isPinned) {
instance.setObjectField("mPinnedTimestampMs", 1L)