mention_system icon indicating copy to clipboard operation
mention_system copied to clipboard

Adding max_mentions to prevent spam

Open dave105010 opened this issue 4 years ago • 2 comments

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?

dave105010 avatar Jan 06 '21 19:01 dave105010

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!

pmviva avatar Jan 12 '21 07:01 pmviva

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[bot] avatar Jan 09 '22 01:01 stale[bot]