闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
973 B

  1. # frozen_string_literal: true
  2. module Admin
  3. class InvitesController < BaseController
  4. def index
  5. authorize :invite, :index?
  6. @invites = filtered_invites.includes(user: :account).page(params[:page])
  7. @invite = Invite.new
  8. end
  9. def create
  10. authorize :invite, :create?
  11. @invite = Invite.new(resource_params)
  12. @invite.user = current_user
  13. if @invite.save
  14. redirect_to admin_invites_path
  15. else
  16. @invites = Invite.page(params[:page])
  17. render :index
  18. end
  19. end
  20. def destroy
  21. @invite = Invite.find(params[:id])
  22. authorize @invite, :destroy?
  23. @invite.expire!
  24. redirect_to admin_invites_path
  25. end
  26. private
  27. def resource_params
  28. params.require(:invite).permit(:max_uses, :expires_in)
  29. end
  30. def filtered_invites
  31. InviteFilter.new(filter_params).results
  32. end
  33. def filter_params
  34. params.permit(:available, :expired)
  35. end
  36. end
  37. end