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

Adding max_mentions to prevent spam #6

Open
dave105010 opened this issue Jan 6, 2021 · 2 comments
Open

Adding max_mentions to prevent spam #6

dave105010 opened this issue Jan 6, 2021 · 2 comments

Comments

@dave105010
Copy link

Is there a built-in method or any easy solution to add max_mention_count kinda functionality to prevent spam?

Let's say someone mentioned 40 users but that's highly unlikely and probably will be done by a bot.

if there isn't any build-in method, where can I add that number limit before processing the mentions?

@pmviva
Copy link
Owner

pmviva commented Jan 12, 2021

Hi, actually there's no way to limit the maximum number of mentions implemented in the framework. A suggestion I haven't tested yet, you could implement a custom mention processor and then override the find_mentionees_by_handles method. In there you can raise an error or slice the handles array.

  def find_mentionees_by_handles(*handles)
    handles = handles.slice(0, MAX_MENTIONS_COUNT)
    User.where(username: handles)
  end
  def find_mentionees_by_handles(*handles)
    raise 'Spam detected' unless handles.length <= MAX_MENTIONS_COUNT
    User.where(username: handles)
  end

Hope that helps!

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants