mention_system
mention_system copied to clipboard
Adding max_mentions to prevent spam
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?
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!
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.