mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 19:07:08 +02:00
fix: fucking ai
This commit is contained in:
@@ -6,9 +6,9 @@ const db = require('../database');
|
||||
const request = require('../request');
|
||||
const activitypub = module.parent.exports;
|
||||
|
||||
const blocklists = module.exports;
|
||||
const Blocklists = module.exports;
|
||||
|
||||
blocklists.list = async () => {
|
||||
Blocklists.list = async () => {
|
||||
const blocklists = await db.getSortedSetMembers('blocklists');
|
||||
const counts = await db.sortedSetsCard(blocklists.map(blocklist => `blocklist:${blocklist}`));
|
||||
|
||||
@@ -17,7 +17,7 @@ blocklists.list = async () => {
|
||||
});
|
||||
};
|
||||
|
||||
blocklists.get = async (url) => {
|
||||
Blocklists.get = async (url) => {
|
||||
const domains = await db.getSortedSetMembers(`blocklist:${url}`);
|
||||
|
||||
return {
|
||||
@@ -26,23 +26,23 @@ blocklists.get = async (url) => {
|
||||
};
|
||||
};
|
||||
|
||||
blocklists.add = async (url) => {
|
||||
Blocklists.add = async (url) => {
|
||||
const now = Date.now();
|
||||
|
||||
await Promise.all([
|
||||
db.sortedSetAdd('blocklists', now, url),
|
||||
blocklists.refresh(url),
|
||||
Blocklists.refresh(url),
|
||||
]);
|
||||
};
|
||||
|
||||
blocklists.remove = async (url) => {
|
||||
Blocklists.remove = async (url) => {
|
||||
await Promise.all([
|
||||
db.sortedSetRemove('blocklists', url),
|
||||
db.delete(`blocklist:${url}`),
|
||||
]);
|
||||
};
|
||||
|
||||
blocklists.refresh = async (url) => {
|
||||
Blocklists.refresh = async (url) => {
|
||||
activitypub.helpers.log(`[blocklists/refresh] Processing ${url}`);
|
||||
|
||||
const { body: csv } = await request.get(url);
|
||||
@@ -69,8 +69,8 @@ blocklists.refresh = async (url) => {
|
||||
return records.length;
|
||||
};
|
||||
|
||||
blocklists.check = async (domain) => {
|
||||
const blocklists = await blocklists.list();
|
||||
Blocklists.check = async (domain) => {
|
||||
const blocklists = await Blocklists.list();
|
||||
let present = await db.isMemberOfSortedSets(blocklists.map(({ url }) => `blocklist:${url}`), domain);
|
||||
present = present.reduce((memo, present) => memo || present, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user