From 4153f60258ef9d941e21eede2973ec69f3fd17be Mon Sep 17 00:00:00 2001 From: caryoscelus Date: Fri, 18 Aug 2023 16:12:31 +0000 Subject: [PATCH] Don't accept file update if it's from muted user refs https://github.com/HelloZeroNet/ZeroNet/issues/1855 --- plugins/ContentFilter/ContentFilterPlugin.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/ContentFilter/ContentFilterPlugin.py b/plugins/ContentFilter/ContentFilterPlugin.py index 6cec1bc3..8a9db880 100644 --- a/plugins/ContentFilter/ContentFilterPlugin.py +++ b/plugins/ContentFilter/ContentFilterPlugin.py @@ -216,6 +216,18 @@ class SiteStoragePlugin(object): filter_storage.includeUpdateAll() return super(SiteStoragePlugin, self).onUpdated(inner_path, file=file) +@PluginManager.registerTo("FileRequest") +class FileRequestPlugin: + def actionUpdate(self, params): + inner_path = params.get('inner_path', '') + self.log.info(f'FileRequest.actionUpdate {inner_path}') + matches = re.findall('/(1[A-Za-z0-9]{26,35})/', inner_path) + for auth_address in matches: + if filter_storage.isMuted(auth_address): + self.log.info(f'Mute match in FileRequest.actionUpdate: {auth_address}, ignoring {inner_path}') + self.response({'ok': f'Thanks, file {inner_path} updated!'}) + return False + return super(FileRequestPlugin, self).actionUpdate(params) @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object):