unoffical wafrn mirror wafrn.net
atproto social-network activitypub
at angular21 48 lines 1.6 kB view raw
1import axios from 'axios' 2import { FederatedHost, User, sequelize } from '../models/index.js' 3import { completeEnvironment } from '../utils/backendOptions.js' 4//const { csv } = require("csv-parse"); 5 6async function blockHosts() { 7 // At some point this will get cooler and will offer the user the option to use THEBADSPACE. It doesnt matter if I do have opinions. Users need choices. 8 const remoteData = await axios.get('https://seirdy.one/pb/FediNuke.txt') 9 console.log('remote data obtained') 10 const hostLines: string[] = remoteData.data.split('\n') 11 //hostLines.forEach(async (line, index) => { 12 let index = 0 13 console.log('initiating marking of problematic hosts') 14 for await (const line of hostLines) { 15 if (index !== 0) { 16 const urlToBlock = line.split(',')[0] 17 const hostToBlock = await FederatedHost.findOne({ 18 where: { 19 displayName: urlToBlock 20 } 21 }) 22 if (hostToBlock) { 23 hostToBlock.blocked = true 24 hostToBlock.updatedAt = new Date() 25 hostToBlock.detail = 'Blocked by selected blocklist' 26 await hostToBlock.save() 27 } else { 28 const tmp = await FederatedHost.create({ 29 displayName: urlToBlock, 30 blocked: true, 31 detail: 'Blocked by selected blocklist' 32 }) 33 console.log(tmp.displayName) 34 } 35 36 } 37 index = index + 1 38 } 39 console.log('cleanup done') 40} 41 42blockHosts() 43 .then(() => { 44 console.log('done') 45 }) 46 .catch((error) => { 47 console.error(error) 48 })