fix: friend menu injection

This commit is contained in:
rhunk
2023-08-04 13:17:21 +02:00
parent 3df11aadb8
commit 910cbd0bba
2 changed files with 19 additions and 1 deletions

View File

@@ -141,6 +141,22 @@ class DatabaseAccess(private val context: ModContext) : Manager {
}
}
fun getConversationType(conversationId: String): Int? {
return safeDatabaseOperation(openArroyo()) {
val cursor = it.rawQuery(
"SELECT * FROM user_conversation WHERE client_conversation_id = ?",
arrayOf(conversationId)
)
if (!cursor.moveToFirst()) {
cursor.close()
return@safeDatabaseOperation null
}
val type = cursor.getInt(cursor.getColumnIndex("conversation_type"))
cursor.close()
type
}
}
fun getDMConversationIdFromUserId(userId: String): UserConversationLink? {
return safeDatabaseOperation(openArroyo()) {
readDatabaseObject(

View File

@@ -33,7 +33,9 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C
val conversationId = viewItem.substringAfter("conversationId: ").substring(0, 36).also {
if (it.startsWith("null")) return@hook
}
lastFetchGroupConversationUUID = SnapUUID.fromString(conversationId)
context.database.getConversationType(conversationId)?.takeIf { it == 1 }?.run {
lastFetchGroupConversationUUID = SnapUUID.fromString(conversationId)
}
}
}