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