<commit_before>module Ability::Membership
  def initialize(user)
    super(user)

    can [:update], ::Membership do |membership|
      membership.user_id == user.id || membership.group.admins.exists?(user.id)
    end

    can [:make_admin], ::Membership do |membership|
      membership.group.admins.exists?(user.id) ||
      (user_is_member_of?(membership.group_id) && membership.user == user && membership.group.admin_memberships.count == 0) ||
      (user_is_admin_of?(membership.group.parent_id) && user == membership.user)
    end

    can :resend, ::Membership do |membership|
      !membership.accepted_at? && user == membership.inviter
    end

    can [:remove_admin, :destroy], ::Membership do |membership|
      (membership.user == user ||
       user_is_admin_of?(membership.group_id) ||
       (membership.inviter == user && !membership.accepted_at?))
    end
  end
end<commit_msg>server side permission for resend invitation<commit_after>module Ability::Membership
  def initialize(user)
    super(user)

    can [:update], ::Membership do |membership|
      membership.user_id == user.id || membership.group.admins.exists?(user.id)
    end

    can [:make_admin], ::Membership do |membership|
      membership.group.admins.exists?(user.id) ||
      (user_is_member_of?(membership.group_id) && membership.user == user && membership.group.admin_memberships.count == 0) ||
      (user_is_admin_of?(membership.group.parent_id) && user == membership.user)
    end

    can :resend, ::Membership do |membership|
      !membership.accepted_at? && user_is_admin_of?(membership.group_id)
    end

    can [:remove_admin, :destroy], ::Membership do |membership|
      (membership.user == user ||
       user_is_admin_of?(membership.group_id) ||
       (membership.inviter == user && !membership.accepted_at?))
    end
  end
end
{'fraction_non_alphanumeric': 0.13802509547190397, 'fraction_numerical': 0.0010911074740861974, 'mean_word_length': 3.8518518518518516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2740589', 'n_tokens_mistral': 602, 'n_tokens_neox': 600, 'n_words': 109}