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

Add consumable invites #5814

Merged
merged 8 commits into from
Nov 27, 2017
Merged

Add consumable invites #5814

merged 8 commits into from
Nov 27, 2017

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Nov 25, 2017

  • By default configured to only be available to admins
  • Admin setting to make it available to mods, normal users, or completely disable
  • Generate 8-char readable code (link) that enables to pass through closed registrations
  • Configurable optional limit by max uses or expiration time for each code
  • Users can delete their invite codes
  • Admin UI to view all codes, delete

Normal user UI:

image

Admin UI:

image

Admin settings UI:

image

  • Invites structure
  • Consuming invites to sign up even when registrations are closed
  • UI for creating invites

@Gargron Gargron added moderation Administration and moderation tooling work in progress Not to be merged, currently being worked on labels Nov 25, 2017
@ykzts
Copy link
Sponsor Member

ykzts commented Nov 25, 2017

Related to #977?

@Gargron Gargron removed the work in progress Not to be merged, currently being worked on label Nov 25, 2017
accepts_nested_attributes_for :account

has_many :applications, class_name: 'Doorkeeper::Application', as: :owner

validates :locale, inclusion: I18n.available_locales.map(&:to_s), if: :locale?
validates_with BlacklistedEmailValidator, if: :email_changed?
validates_with InviteCodeValidator
Copy link
Member

Choose a reason for hiding this comment

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

This should only validate when the record is being created, so records don't start erroring once the invite expires

# expires_at :datetime
# max_uses :integer
# uses :integer default(0), not null
# default_follow_account_ids :integer is an Array
Copy link
Member

Choose a reason for hiding this comment

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

Unused?

- Default follows not used, probably bad idea
- InviteCodeValidator is redundant because RegistrationsController
  checks invite code validity
- Admin UI that lists everyone's invites, always available
- Admin setting min_invite_role to control who can invite people
- Non-admin invite UI only visible if users are allowed to
def destroy
@invite = Invite.where(user: current_user).find(params[:id])
authorize @invite, :destroy?
@invite.destroy!
Copy link
Member

@nightpool nightpool Nov 27, 2017

Choose a reason for hiding this comment

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

instead of destroying the record, this should probably just set expires_at = Time.now or something so that it's still auditable.

otherwise we have the situation where someone makes 100 accounts and deletes the invites so they can't be traced back to them.

'21600': 6 hours
'3600': 1 hour
'43200': 12 hours
'86400': 1 day
Copy link
Member

@nightpool nightpool Nov 27, 2017

Choose a reason for hiding this comment

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

shouldn't this just be done with some sort of interval helper?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we overwrote the rails strings to be super short for relative time. Unless you know a better way


.fields-group
= f.input :max_uses, wrapper: :with_label, collection: [1, 5, 10, 25, 50, 100], label_method: lambda { |num| I18n.t('invites.max_uses', count: num) }, prompt: I18n.t('invites.max_uses_prompt')
= f.input :expires_in, wrapper: :with_label, collection: [30.minutes, 1.hour, 6.hours, 12.hours, 1.day].map(&:to_i), label_method: lambda { |i| I18n.t("invites.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt')
Copy link
Member

@nightpool nightpool Nov 27, 2017

Choose a reason for hiding this comment

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

7 days is probably useful here. 6 hours is probably not super useful? Or keep 6 hours, but get rid of 1 hour because we already have 30 minutes.

@Gargron Gargron dismissed nightpool’s stale review November 27, 2017 15:06

Addressed the expiry thing

@Gargron Gargron merged commit 740f8a9 into master Nov 27, 2017
@Gargron Gargron deleted the feature-invites branch November 27, 2017 15:08
@Gargron Gargron mentioned this pull request Nov 27, 2017
10 tasks
@mkljczk mkljczk mentioned this pull request Nov 30, 2017
1 task
yi0713 added a commit to yi0713/mastodon that referenced this pull request Dec 2, 2017
ykzts pushed a commit that referenced this pull request Dec 5, 2017
* i18n: (zh-CN) Add missing translations for multiple PRs.
Related PRs: #5838 #5762 #5835 #5837 #5832 #5823 #5814 #5757

* i18n: (zh-CN) Fix translation for #5823 / #5835

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Change `发送者` to `作者`

* i18n: (zh-CN) Add missing translations for #5862

* i18n: (zh-CN) Add missing translation for #5874

* i18n: (zh-CN) Improve translations for keyboard shortcuts
cobodo pushed a commit to cobodo/mastodon that referenced this pull request Dec 6, 2017
* Add consumable invites

* Add UI for generating invite codes

* Add tests

* Display max uses and expiration in invites table, delete invite

* Remove unused column and redundant validator

- Default follows not used, probably bad idea
- InviteCodeValidator is redundant because RegistrationsController
  checks invite code validity

* Add admin setting to disable invites

* Add admin UI for invites, configurable role for invite creation

- Admin UI that lists everyone's invites, always available
- Admin setting min_invite_role to control who can invite people
- Non-admin invite UI only visible if users are allowed to

* Do not remove invites from database, expire them instantly
cobodo pushed a commit to cobodo/mastodon that referenced this pull request Dec 6, 2017
…on#5849)

* i18n: (zh-CN) Add missing translations for multiple PRs.
Related PRs: mastodon#5838 mastodon#5762 mastodon#5835 mastodon#5837 mastodon#5832 mastodon#5823 mastodon#5814 mastodon#5757

* i18n: (zh-CN) Fix translation for mastodon#5823 / mastodon#5835

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Change `发送者` to `作者`

* i18n: (zh-CN) Add missing translations for mastodon#5862

* i18n: (zh-CN) Add missing translation for mastodon#5874

* i18n: (zh-CN) Improve translations for keyboard shortcuts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moderation Administration and moderation tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invite-Only mode for registrations
3 participants