+18
server/index.js
+18
server/index.js
···
78
78
db.updateLastPush(session);
79
79
}
80
80
81
+
const isTorment = source => {
82
+
try {
83
+
const [nsid, ...rp] = source.split(':');
84
+
const parts = nsid.split('.');
85
+
const unreversed = parts.toReversed().join('.');
86
+
const app = psl.parse(unreversed)?.domain ?? 'unknown';
87
+
const appPrefix = app.split('.').toReversed().join('.');
88
+
return source.slice(app.length + 1) in lexicons[appPrefix]?.torment_sources;
89
+
} catch (e) {
90
+
console.error('checking tormentedness failed, allowing through', e);
91
+
return false;
92
+
}
93
+
}
94
+
81
95
const handleDust = db => async event => {
82
96
console.log('got', event.data);
83
97
let data;
···
88
102
return;
89
103
}
90
104
const { link: { subject, source, source_record } } = data;
105
+
if (isTorment(source)) {
106
+
console.log('nope! not today,', source);
107
+
return;
108
+
}
91
109
const timestamp = +new Date();
92
110
93
111
let did;