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

new option - config.invitation_limit_for #201

Open
matzke opened this issue Apr 13, 2012 · 3 comments
Open

new option - config.invitation_limit_for #201

matzke opened this issue Apr 13, 2012 · 3 comments
Assignees
Labels

Comments

@matzke
Copy link

matzke commented Apr 13, 2012

It would be nice, if there was an option +invitation_limit_for+ = 1.day, so the user can send only X invitations per day.

I think it is important to limit the number of invitations, so nobody can spam people. But it is also important to make it possible (for power users) to invite a whole bunch of people.

@scambra
Copy link
Owner

scambra commented Apr 13, 2012

Do you have some ideas about implementation?

@teddywing
Copy link

Maybe have something like an invitation_reload_period key, an invitation_last_sent_on, and a invitations_for_period key.

So invitation_reload_period would store the amount of time between invite refills. invitation_last_sent_on stores the time the user last sent an invitation. And invitations_for_period would store the number of invitations remaining in that period.

When a new invitation is created, we check whether there are still any invitations_for_period. If so, proceed as normal and decrement invitations_for_period.

If not, check to see if Time.now - invitation_last_sent_on >= invitation_reload_period. When false, we can't send the invitation, otherwise we refill the invitations_for_period from invitation_limit and decrement.

I realise now that I've typed this, the issue with this approach is that it hinges on the invitation-create action. I was trying to come up with a solution that wouldn't involve a cron job, but now I'm not sure that's possible.

Edit:
Actually, we can also do the refilling (from paragraph 4) any time we want to get the invitation count, so that the count wouldn't show 0 invitations remaining even when we're past the invitation reload period.

@scambra
Copy link
Owner

scambra commented Sep 7, 2012

invitations_for_period is not needed, invitation_limit can be used, class.invitation_limit would be the reset value
time check could be done in has_invitations

@ghost ghost assigned scambra Nov 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants