Merge pull request #235 from caryoscelus/no-muted-propagation
Remove and don't update muted users' content
This commit is contained in:
commit
7fdff749ff
2 changed files with 24 additions and 2 deletions
|
@ -58,7 +58,7 @@ class UiWebsocketPlugin(object):
|
||||||
def actionMuteAdd(self, to, auth_address, cert_user_id, reason):
|
def actionMuteAdd(self, to, auth_address, cert_user_id, reason):
|
||||||
self.cmd(
|
self.cmd(
|
||||||
"prompt",
|
"prompt",
|
||||||
[_["Hide all content from <b>%s</b>?"] % html.escape(cert_user_id), reason, _["Mute"]],
|
[_["Remove all content from <b>%s</b>?"] % html.escape(cert_user_id), reason, _["Mute"]],
|
||||||
lambda res: self.cbMuteAdd(to, auth_address, cert_user_id, res if res else reason)
|
lambda res: self.cbMuteAdd(to, auth_address, cert_user_id, res if res else reason)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -216,6 +216,28 @@ class SiteStoragePlugin(object):
|
||||||
filter_storage.includeUpdateAll()
|
filter_storage.includeUpdateAll()
|
||||||
return super(SiteStoragePlugin, self).onUpdated(inner_path, file=file)
|
return super(SiteStoragePlugin, self).onUpdated(inner_path, file=file)
|
||||||
|
|
||||||
|
@PluginManager.registerTo("Site")
|
||||||
|
class SitePlugin(object):
|
||||||
|
def needFile(self, inner_path, update=False, blocking=True, peer=None, priority=0):
|
||||||
|
self.log.debug(f'needFile {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 Site.needFile: {auth_address}, ignoring {inner_path}')
|
||||||
|
return False
|
||||||
|
return super(SitePlugin, self).needFile(inner_path, update, blocking, peer, priority)
|
||||||
|
|
||||||
|
@PluginManager.registerTo("FileRequest")
|
||||||
|
class FileRequestPlugin:
|
||||||
|
def actionUpdate(self, params):
|
||||||
|
inner_path = params.get('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")
|
@PluginManager.registerTo("UiRequest")
|
||||||
class UiRequestPlugin(object):
|
class UiRequestPlugin(object):
|
||||||
|
|
|
@ -158,7 +158,7 @@ class ContentFilterStorage(object):
|
||||||
dir_inner_path = helper.getDirname(row["inner_path"])
|
dir_inner_path = helper.getDirname(row["inner_path"])
|
||||||
for file_name in site.storage.walk(dir_inner_path):
|
for file_name in site.storage.walk(dir_inner_path):
|
||||||
if action == "remove":
|
if action == "remove":
|
||||||
site.storage.onUpdated(dir_inner_path + file_name, False)
|
site.storage.delete(dir_inner_path + file_name)
|
||||||
else:
|
else:
|
||||||
site.storage.onUpdated(dir_inner_path + file_name)
|
site.storage.onUpdated(dir_inner_path + file_name)
|
||||||
site.onFileDone(dir_inner_path + file_name)
|
site.onFileDone(dir_inner_path + file_name)
|
||||||
|
|
Loading…
Reference in a new issue