Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

Reuse user_groups table table for user bans - #57

Closed
midned wants to merge 1 commit into
freeCodeCamp:masterfrom
midned:reuse-user-group-table-for-bans
Closed

midned wants to merge 1 commit into
freeCodeCamp:masterfrom
midned:reuse-user-group-table-for-bans

Conversation

@midned

@midned midned commented Oct 16, 2019

Copy link
Copy Markdown

With this we can avoid using an extra table for banning users from groups.

We can actually use the already-existent pivot table to hold that information

@vaibhavsingh97 vaibhavsingh97 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thanks for the PR. LGTM 🎉

@dmmulroy

Copy link
Copy Markdown

I intentionally made these separate tables for the use case that a user leaves an organization, deletes their account, or something similar we can still easily maintain the ban information. But I'm also open to this if y'all think it'd be better 👍

@midned

midned commented Oct 16, 2019

Copy link
Copy Markdown
Author

I intentionally made these separate tables for the use case that a user leaves an organization, deletes their account, or something similar we can still easily maintain the ban information. But I'm also open to this if y'all think it'd be better 👍

I think that's a good reason actually. We could handle that by not allowing the user to leave a group where he or she is banned; and also we won't show the user in the list of members if the banned flag is true.

In the case of account deletion then maintaining the ban record won't give any information since we won't have any information of the banned user (unless we use soft deletes).

I can see advantages in both approaches, I'm personally 65% in favor of using the same table with the banned flag, and 35% for the use of separate tables

Comment thread data/ddl.sql
create table user_groups (
user_id uuid references users(id),
group_id uuid references groups(id),
banned boolean default false,

@francocorreasosa francocorreasosa Oct 16, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to convert this into a date time field, so we can keep track of how many time an user has been banned. In the future we could also implement auto unbans (or temporal bans).

  • banned_at == <ANY DATE> would mean the user is banned
  • banned_at == null would mean user is not banned
Suggested change
banned boolean default false,
banned_at timestamptz,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with this change. @dmmulroy @vaibhavsingh97 What do you guys think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep track of how many time an user has been banned.

banned_at field will be updated many times, so how can we track if the user is banned 1 time or 2 times? We will only get the last banned date if we are using timestampz

In the future we could also implement auto unbans (or temporal bans).

So probably we will need to have a separate table for this thing as then we have too many things to consider. Also, maintaining another table will record logs like the reason for banning, no. of times a user gets banned, also the state of ban i.e temp/permanent.

@francocorreasosa

francocorreasosa commented Oct 17, 2019 •

Copy link
Copy Markdown
Member

Also, on top of my previous comment, I’m not totally sure we want users to be banned from the entire platform. Who should be allowed to ban an user from all groups? never mind I didn't read correctly.

@midned

midned commented Oct 17, 2019

Copy link
Copy Markdown
Author

Also, on top of my previous comment, I’m not totally sure we want users to be banned from the entire platform. Who should be allowed to ban an user from all groups?

This change only allows for users to be banned from a group

@francocorreasosa

Copy link
Copy Markdown
Member

Oops you're right, misread the table name. Edited my comment.

@bernhard-hofmann

bernhard-hofmann commented Oct 22, 2019 •

Copy link
Copy Markdown
Contributor

I prefer the separate table for a few reasons:

  1. As mentioned by @dmmulroy , the row can persist even after the user leaves a chapter
  2. The user_bans table can (and should IMO) also have columns for reason and created_at so that we know why a user was banned and when.

I don't want to pollute this PR with the topic or reasons, I'm just including it to illustrate why this PR is not going in the direction I think the schema should:
The reason column might be a FK to a table of reasons for banning, and then a comments column for admins to write a little more about what, why, who, when, etc. (E.g. reason=Racist behaviour and comments='Jake repeatedly used the N word even after being told not to on at least 3 occasions.')

@latchkostov

Copy link
Copy Markdown

I prefer a separate table for the reason named. We should be able to keep track of multi bans and information regarding those bans. In addition, a bans table allows a user to be removed from the organization, and we don't have to do any weird one off things like not allow a user to leave an org because they are banned.

@ceciliaconsta3

Copy link
Copy Markdown
Contributor

I agree with using a separate ban table. Is this an MVP feature? Maybe not since we need to verify users (phone number?) so a banned person doesn't just create a new account with an alternate email address. Either way, if I'm understanding all correctly, sounds like this PR needs to be closed.

@vkWeb

vkWeb commented Oct 24, 2019

Copy link
Copy Markdown
Member

@ceciliaconsta3 Yes indeed banning a user is an MVP feature. I agree with you all that we should keep user_bans in a separate table to handle hard deletion.

Closing this as the consensus is: Banned users should be in separate table.

Thanks, @midned for trying to help us. This was your first time here so I know it feels bad to see your PR closed but don't worry we need a ton of help in implementing MVP features. You can find issues we need help with here :)

@vkWeb vkWeb closed this Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants