Skip to content

Commit 7fdff74

Browse files
authored
Merge pull request #235 from caryoscelus/no-muted-propagation
Remove and don't update muted users' content
2 parents 19056b4 + c9dbc49 commit 7fdff74

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

plugins/ContentFilter/ContentFilterPlugin.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def cbMuteAdd(self, to, auth_address, cert_user_id, reason):
5858
def actionMuteAdd(self, to, auth_address, cert_user_id, reason):
5959
self.cmd(
6060
"prompt",
61-
[_["Hide all content from <b>%s</b>?"] % html.escape(cert_user_id), reason, _["Mute"]],
61+
[_["Remove all content from <b>%s</b>?"] % html.escape(cert_user_id), reason, _["Mute"]],
6262
lambda res: self.cbMuteAdd(to, auth_address, cert_user_id, res if res else reason)
6363
)
6464

@@ -216,6 +216,28 @@ def onUpdated(self, inner_path, file=None):
216216
filter_storage.includeUpdateAll()
217217
return super(SiteStoragePlugin, self).onUpdated(inner_path, file=file)
218218

219+
@PluginManager.registerTo("Site")
220+
class SitePlugin(object):
221+
def needFile(self, inner_path, update=False, blocking=True, peer=None, priority=0):
222+
self.log.debug(f'needFile {inner_path}')
223+
matches = re.findall('/(1[A-Za-z0-9]{26,35})/', inner_path)
224+
for auth_address in matches:
225+
if filter_storage.isMuted(auth_address):
226+
self.log.info(f'Mute match in Site.needFile: {auth_address}, ignoring {inner_path}')
227+
return False
228+
return super(SitePlugin, self).needFile(inner_path, update, blocking, peer, priority)
229+
230+
@PluginManager.registerTo("FileRequest")
231+
class FileRequestPlugin:
232+
def actionUpdate(self, params):
233+
inner_path = params.get('inner_path', '')
234+
matches = re.findall('/(1[A-Za-z0-9]{26,35})/', inner_path)
235+
for auth_address in matches:
236+
if filter_storage.isMuted(auth_address):
237+
self.log.info(f'Mute match in FileRequest.actionUpdate: {auth_address}, ignoring {inner_path}')
238+
self.response({'ok': f'Thanks, file {inner_path} updated!'})
239+
return False
240+
return super(FileRequestPlugin, self).actionUpdate(params)
219241

220242
@PluginManager.registerTo("UiRequest")
221243
class UiRequestPlugin(object):

plugins/ContentFilter/ContentFilterStorage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def changeDbs(self, auth_address, action):
158158
dir_inner_path = helper.getDirname(row["inner_path"])
159159
for file_name in site.storage.walk(dir_inner_path):
160160
if action == "remove":
161-
site.storage.onUpdated(dir_inner_path + file_name, False)
161+
site.storage.delete(dir_inner_path + file_name)
162162
else:
163163
site.storage.onUpdated(dir_inner_path + file_name)
164164
site.onFileDone(dir_inner_path + file_name)

0 commit comments

Comments
 (0)