Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow admins to "pause" a user's account #3163

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

fettuccinae
Copy link
Contributor

@fettuccinae fettuccinae commented Feb 1, 2025

Problem

Right now when we see users spamming their LB feeds, the only thing we can do is delete their account, which is pretty harsh. Admins should have the ability to "pause" an account, so that is stops accepting listens and then sends the user an email about this pause.
https://tickets.metabrainz.org/browse/LB-1730

Solution

  1. Added a flag to the user table called is_paused with a default value of false
  2. There's 3 ways to import listens: submit-listens api endpoint, lastfm importer and spotify importer(last 2 use the same base class), Added an conditional statement which would check if the flag is set as True, if it is, the user is skipped during processing (for spotify and lastfm importers), for submit-listen api, it raises an APIUnauthorized error.
  3. Added a "pause" function to set the "is_paused" flag to true and send an email to the user.
  4. Added an "unpause" function to set the "is_paused" flag to false and sends an email to the user.
  5. Added relevant test cases

Copy link
Member

@mayhem mayhem left a comment

Choose a reason for hiding this comment

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

Looking pretty good. A few things:

  1. I've added some text on how to improve the wording of your messages.
  2. You'll need to check the users paused status in the timescale writer as well: https://github.com/metabrainz/listenbrainz-server/blob/master/listenbrainz/timescale_writer/timescale_writer.py
  3. How does an admin set/unset the admin flag? Right now that doesn't seem possible in the admin interface, so I think more work needs to be done there.

listenbrainz/db/user.py Outdated Show resolved Hide resolved
listenbrainz/db/user.py Outdated Show resolved Hide resolved
def _notify_user_email(db_conn, user_id,paused):
user = get(db_conn, user_id, fetch_email=True)
if user["email"] is None:
return
Copy link
Member

Choose a reason for hiding this comment

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

We should log an error here, just in case.

return
url = current_app.config['SERVER_ROOT_URL']
template = 'emails/id_paused.txt' if paused else 'emails/id_unpaused.txt'
subject = 'ListenBrainz UserID Paused' if paused else 'ListenBrainz UserID Unpaused'
Copy link
Member

Choose a reason for hiding this comment

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

I think the strings here should say:

"Your ListenBrainz account has been paused and is not accepting incoming listens"
and
"Your ListenBrainz account has been unpaused and is accepting incoming listens"

Options: Add the account name: "Your ListenBrainz accout ([account_name]) has been..."

@@ -0,0 +1,7 @@
Hi {{ username }}!

We have paused your listenbrainz ID due to sus activities, you wont be able to import new listens.
Copy link
Member

Choose a reason for hiding this comment

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

sus, lol. :)

Lets go with:

"We have paused your ListenBrainz account ([user name]) because of a problem with your account. Our community manager will reach out to you with the details as to why we took this step. Feel free to [Contact Us] if you have any questions about this."

and

"Your ListenBrainz account ([account name]) has been restore and is now accepting listens again."

@@ -76,6 +76,9 @@ def submit_listen():
if mb_engine and current_app.config["REJECT_LISTENS_WITHOUT_USER_EMAIL"] and not user["email"]:
raise APIUnauthorized(REJECT_LISTENS_WITHOUT_EMAIL_ERROR)

if user['is_paused']:
raise APIUnauthorized("user_id is paused.")
Copy link
Member

Choose a reason for hiding this comment

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

" ... is paused and is currently not accepting listens. Feel free to [Contact Us] if you have any questions about this."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants