Compare commits

..

5 commits
main ... main

3 changed files with 33 additions and 17 deletions

File diff suppressed because one or more lines are too long

17
main.js
View file

@ -8,7 +8,8 @@ if (!USER_TOKEN) {
process.exit(1);
}
console.log("Spierdalaj");
const PERIOD = process.env.PERIOD; // Time in days: int
const INSTANCE_URL = process.env.INSTANCE_URL;
const API_BASE = `${INSTANCE_URL}/api`;
@ -50,17 +51,19 @@ async function main() {
const users = response.data;
const now = new Date();
const fiveDaysAgo = new Date(now - 5 * 24 * 60 * 60 * 1000);
const timeAgo = new Date(now - PERIOD * 24 * 60 * 60 * 1000);
const usersToDelete = users.filter(user => {
const createdAt = new Date(user.createdAt);
const updatedAt = new Date(user.updatedAt);
return user.notesCount === 0 &&
createdAt < fiveDaysAgo &&
updatedAt < fiveDaysAgo;
const excludedUsers = ['instance.actor', 'relay.actor'];
return user.notesCount === 0 &&
createdAt < timeAgo &&
updatedAt < timeAgo &&
!excludedUsers.includes(user.username)
});
console.log(`Found ${usersToDelete.length} users matching criteria (no posts, not updated, and older than 5 days)`);
console.log(`Found ${usersToDelete.length} users matching criteria (no posts, not updated, and older than ${PERIOD} days)`);
console.log('\nUsers to be deleted:');
usersToDelete.forEach(user => {
@ -72,7 +75,7 @@ async function main() {
console.log();
const confirmed = await askForConfirmation(`Are you sure you want to delete ${usersToDelete.length} users?`);
if (!confirmed) {
console.log('Operation cancelled by user');
rl.close();

View file

@ -1,5 +1,5 @@
{
"dependencies": { // Kus
"dependencies": {
"axios": "^1.7.8",
"dotenv": "^16.4.5",
"readline": "^1.3.0"