Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit cda6e4e

Browse files
Merge pull request #1152 from ssbc/opt-in-auto-delete
Make feed deletion an opt-in setting
2 parents c9212ed + c8a680f commit cda6e4e

File tree

5 files changed

+414
-353
lines changed

5 files changed

+414
-353
lines changed

lib/depject/page/html/render/settings.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ exports.create = function (api) {
3535
const fontSize = api.settings.obs.get('patchwork.fontSize', '')
3636
const fontFamily = api.settings.obs.get('patchwork.fontFamily', '')
3737
const includeParticipating = api.settings.obs.get('patchwork.includeParticipating', false)
38+
const autoDeleteBlocked = api.settings.obs.get('patchwork.autoDeleteBlocked', false)
3839

3940
// const filterFollowing = api.settings.obs.get('filters.following')
4041
// const filterSubscriptions = api.settings.obs.get('filters.subscriptions')
@@ -108,6 +109,14 @@ exports.create = function (api) {
108109
checkbox(includeParticipating, {
109110
label: i18n('Include "Participating" tab in navigation bar')
110111
})
112+
]),
113+
114+
h('h2', i18n('Blocking')),
115+
116+
h('div', [
117+
checkbox(autoDeleteBlocked, {
118+
label: i18n('Automatically delete messages from blocked authors. This is irreversible and will cause problems with clients that share the database but do not support deleted messages. Enable at your own risk!')
119+
})
111120
])
112121
]),
113122

lib/main-window.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module.exports = function (config) {
6060
var latestUpdate = LatestUpdate()
6161
var subscribedChannels = api.channel.obs.subscribed(id)
6262
var includeParticipating = api.settings.obs.get('patchwork.includeParticipating', false)
63+
var autoDeleteBlocked = api.settings.obs.get('patchwork.autoDeleteBlocked', false)
6364

6465
// prompt to setup profile on first use
6566
onceTrue(api.sbot.obs.connection, (ssb) => {
@@ -77,39 +78,42 @@ module.exports = function (config) {
7778
const currentlyDeleting = {}
7879

7980
watch(api.contact.obs.blocking(id), (blocking) => {
81+
if (autoDeleteBlocked() !== true) return
8082
if (blocking.length === 0) return
8183

8284
if (ssb.del == null) return
8385

84-
blocking.forEach(feed => {
85-
pull(
86-
ssb.createUserStream({ id: feed }),
87-
pull.asyncMap((msg, cb) => {
88-
const key = msg.key
89-
if (currentlyDeleting[key] === true) {
90-
return cb(null, null) // already deleting
91-
}
86+
blocking
87+
.filter(feedId => feedId !== ssb.id)
88+
.forEach(feed => {
89+
pull(
90+
ssb.createUserStream({ id: feed }),
91+
pull.asyncMap((msg, cb) => {
92+
const key = msg.key
93+
if (currentlyDeleting[key] === true) {
94+
return cb(null, null) // already deleting
95+
}
9296

93-
currentlyDeleting[key] = true
97+
currentlyDeleting[key] = true
98+
99+
ssb.del(key, (err) => {
100+
currentlyDeleting[key] = false
101+
cb(err, key)
102+
})
103+
}),
104+
pull.filter(),
105+
pull.collect((err, keys) => {
106+
if (err) {
107+
console.error(keys)
108+
throw err
109+
}
94110

95-
ssb.del(key, (err) => {
96-
currentlyDeleting[key] = false
97-
cb(err, key)
111+
if (keys.length > 0) {
112+
console.log(`deleted ${keys.length} messages from blocked authors`)
113+
}
98114
})
99-
}),
100-
pull.filter(),
101-
pull.collect((err, keys) => {
102-
if (err) {
103-
console.error(keys)
104-
throw err
105-
}
106-
107-
if (keys.length > 0) {
108-
console.log(`deleted ${keys.length} messages from blocked authors`)
109-
}
110-
})
111-
)
112-
})
115+
)
116+
})
113117
})
114118
})
115119

locales/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,8 @@
308308
" replied but is blocked by ": " replied but is blocked by ",
309309
"Content of a blocked user": "Content of a blocked user",
310310
"el": "el",
311-
"eo": "eo"
312-
}
311+
"eo": "eo",
312+
"zh-TW": "zh-TW",
313+
"Blocking": "Blocking",
314+
"Automatically delete messages from blocked authors. This is irreversible and will cause problems with clients that share the database but do not support deleted messages. Enable at your own risk!": "Automatically delete messages from blocked authors. This is irreversible and will cause problems with clients that share the database but do not support deleted messages. Enable at your own risk!"
315+
}

0 commit comments

Comments
 (0)