mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 12:30:12 +02:00
feat: prevent self auto download
This commit is contained in:
parent
12eacf5e53
commit
a49c4e9a45
@ -103,9 +103,13 @@
|
||||
"name": "Save Folder",
|
||||
"description": "The directory where all media is saved"
|
||||
},
|
||||
"auto_download_options": {
|
||||
"name": "Auto Download Options",
|
||||
"description": "Select which medias to auto download"
|
||||
"auto_download_sources": {
|
||||
"name": "Auto Download Sources",
|
||||
"description": "Select the sources to automatically download from"
|
||||
},
|
||||
"prevent_self_auto_download": {
|
||||
"name": "Prevent Self Auto Download",
|
||||
"description": "Prevents your own Snaps from being downloaded automatically"
|
||||
},
|
||||
"path_format": {
|
||||
"name": "Path Format",
|
||||
@ -356,7 +360,7 @@
|
||||
"append_date_time": "Add the date and time to the file name",
|
||||
"append_type": "Add the media type to the file name"
|
||||
},
|
||||
"auto_download_options": {
|
||||
"auto_download_sources": {
|
||||
"friend_snaps": "Friend Snaps",
|
||||
"friend_stories": "Friend Stories",
|
||||
"public_stories": "Public Stories",
|
||||
|
@ -6,12 +6,13 @@ import me.rhunk.snapenhance.core.config.FeatureNotice
|
||||
|
||||
class DownloaderConfig : ConfigContainer() {
|
||||
val saveFolder = string("save_folder") { addFlags(ConfigFlag.FOLDER) }
|
||||
val autoDownloadOptions = multiple("auto_download_options",
|
||||
val autoDownloadSources = multiple("auto_download_sources",
|
||||
"friend_snaps",
|
||||
"friend_stories",
|
||||
"public_stories",
|
||||
"spotlight"
|
||||
)
|
||||
val preventSelfAutoDownload = boolean("prevent_self_auto_download")
|
||||
val pathFormat = multiple("path_format",
|
||||
"create_user_folder",
|
||||
"append_hash",
|
||||
|
@ -235,6 +235,8 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp
|
||||
return
|
||||
}
|
||||
|
||||
if (!forceDownload && context.config.downloader.preventSelfAutoDownload.get() && senderId == context.database.myUserId) return
|
||||
|
||||
val author = context.database.getFriendInfo(senderId) ?: return
|
||||
val authorUsername = author.usernameForSorting!!
|
||||
|
||||
@ -270,6 +272,7 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp
|
||||
|
||||
conversationParticipants.firstOrNull { it != conversationMessage.senderId }
|
||||
}
|
||||
if (!forceDownload && context.config.downloader.preventSelfAutoDownload.get() && storyUserId == context.database.myUserId) return
|
||||
|
||||
val author = context.database.getFriendInfo(
|
||||
if (storyUserId == null || storyUserId == "null")
|
||||
@ -278,6 +281,8 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp
|
||||
) ?: throw Exception("Friend not found in database")
|
||||
val authorName = author.usernameForSorting!!
|
||||
|
||||
if (!forceDownload && canUseRule(author.userId!!)) return
|
||||
|
||||
downloadOperaMedia(provideDownloadManagerClient(
|
||||
pathSuffix = authorName,
|
||||
mediaIdentifier = paramMap["MEDIA_ID"].toString(),
|
||||
@ -362,7 +367,7 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp
|
||||
}
|
||||
|
||||
private fun canAutoDownload(keyFilter: String? = null): Boolean {
|
||||
val options by context.config.downloader.autoDownloadOptions
|
||||
val options by context.config.downloader.autoDownloadSources
|
||||
return options.any { keyFilter == null || it.contains(keyFilter, true) }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user