Skip to content

Commit

Permalink
Merge branch 'main' into test-1
Browse files Browse the repository at this point in the history
  • Loading branch information
xteamlyer committed May 5, 2024
2 parents e47189c + 28dca3b commit 375fe4a
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 152 deletions.
19 changes: 19 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:best-practices"
],
"forkProcessing": "enabled",
"autodiscover": true,
"branchConcurrentLimit": 0,
"enabled": true,
"git-submodules": {
"enabled": true
},
"ignoreDeprecated": false,
"ignoreUnstable": false,
"includeMirrors": true,
"prConcurrentLimit": 0,
"prHourlyLimit": 0,
"dependencyDashboard": true
}
26 changes: 0 additions & 26 deletions .github/renovate.json5

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/java/eu/kanade/domain/DomainModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class DomainModule : InjektModule {
addFactory { ToggleLanguage(get()) }
addFactory { ToggleSource(get()) }
addFactory { ToggleSourcePin(get()) }
addFactory { TrustExtension(get()) }
addFactory { TrustExtension(get(), get()) }

addSingletonFactory<ExtensionRepoRepository> { ExtensionRepoRepositoryImpl(get()) }
addFactory { ExtensionRepoService(get(), get()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GetExtensionsByType(
extensionManager.installedExtensionsFlow,
extensionManager.untrustedExtensionsFlow,
extensionManager.availableExtensionsFlow,
) { _activeLanguages, _installed, _untrusted, _available ->
) { enabledLanguages, _installed, _untrusted, _available ->
val (updates, installed) = _installed
.filter { (showNsfwSources || !it.isNsfw) }
.sortedWith(
Expand All @@ -40,9 +40,9 @@ class GetExtensionsByType(
}
.flatMap { ext ->
if (ext.sources.isEmpty()) {
return@flatMap if (ext.lang in _activeLanguages) listOf(ext) else emptyList()
return@flatMap if (ext.lang in enabledLanguages) listOf(ext) else emptyList()
}
ext.sources.filter { it.lang in _activeLanguages }
ext.sources.filter { it.lang in enabledLanguages }
.map {
ext.copy(
name = it.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ package eu.kanade.domain.extension.interactor
import android.content.pm.PackageInfo
import androidx.core.content.pm.PackageInfoCompat
import eu.kanade.domain.source.service.SourcePreferences
import mihon.domain.extensionrepo.repository.ExtensionRepoRepository
import tachiyomi.core.common.preference.getAndSet

class TrustExtension(
private val extensionRepoRepository: ExtensionRepoRepository,
private val preferences: SourcePreferences,
) {

fun isTrusted(pkgInfo: PackageInfo, signatureHash: String): Boolean {
val key = "${pkgInfo.packageName}:${PackageInfoCompat.getLongVersionCode(pkgInfo)}:$signatureHash"
return key in preferences.trustedExtensions().get()
suspend fun isTrusted(pkgInfo: PackageInfo, fingerprints: List<String>): Boolean {
val trustedFingerprints = extensionRepoRepository.getAll().map { it.signingKeyFingerprint }.toHashSet()
val key = "${pkgInfo.packageName}:${PackageInfoCompat.getLongVersionCode(pkgInfo)}:${fingerprints.last()}"
return trustedFingerprints.any { fingerprints.contains(it) } || key in preferences.trustedExtensions().get()
}

fun trust(pkgName: String, versionCode: Long, signatureHash: String) {
preferences.trustedExtensions().getAndSet { exts ->
// Remove previously trusted versions
val removed = exts.filterNot { it.startsWith("$pkgName:") }.toMutableSet()

removed.also {
it += "$pkgName:$versionCode:$signatureHash"
}
removed.also { it += "$pkgName:$versionCode:$signatureHash" }
}
}

Expand Down
Loading

0 comments on commit 375fe4a

Please sign in to comment.