Skip to content

Commit

Permalink
Create communityModeration.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 4, 2024
1 parent b409989 commit 95f7b70
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/community/communityModeration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// communityModeration.js

class CommunityModeration {
constructor() {
this.reports = []; // Store reports
this.bannedUsers = new Set(); // Store banned users
}

// Report a user
reportUser (reporterId, reportedId, reason) {
this.reports.push({
reporterId,
reportedId,
reason,
timestamp: new Date(),
});
console.log(`User ${reporterId} reported user ${reportedId} for: ${reason}`);
}

// Review reports
reviewReports() {
return this.reports;
}

// Ban a user
banUser (userId) {
this.bannedUsers.add(userId);
console.log(`User ${userId} has been banned from the community.`);
}

// Unban a user
unbanUser (userId) {
this.bannedUsers.delete(userId);
console.log(`User ${userId} has been unbanned from the community.`);
}

// Check if a user is banned
isUser Banned(userId) {
return this.bannedUsers.has(userId);
}
}

// Example usage
const moderation = new CommunityModeration();
moderation.reportUser ('user1', 'user2', 'Inappropriate behavior');
moderation.reportUser ('user3', ' user4', 'Spam content');

moderation.banUser ('user2');
console.log('Current Reports:', moderation.reviewReports());
console.log('Is user2 banned?', moderation.isUser Banned('user2'));

moderation.unbanUser ('user2');
console.log('Is user2 banned after unbanning?', moderation.isUser Banned('user2'));

0 comments on commit 95f7b70

Please sign in to comment.