diff --git a/app/models/ability.rb b/app/models/ability.rb index 5c4c7e6ece..ced37dbdaf 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -85,7 +85,7 @@ def editor_perms obj.annotation.team&.id == @context_team.id end can [:create, :update, :read, :destroy], [Account, Source, TiplineNewsletter, TiplineResource, Feed, FeedTeam], :team_id => @context_team.id - can [:create, :update, :destroy], FeedInvitation, { feed: { team_id: @context_team.id } } + can [:create, :update], FeedInvitation, { feed: { team_id: @context_team.id } } can :destroy, FeedTeam do |obj| obj.team.id == @context_team.id || obj.feed.team.id == @context_team.id end diff --git a/app/models/feed_invitation.rb b/app/models/feed_invitation.rb index 3b983386cc..c7c2ec49fd 100644 --- a/app/models/feed_invitation.rb +++ b/app/models/feed_invitation.rb @@ -18,7 +18,8 @@ def accept!(team_id) end def reject! - self.update_column(:state, :rejected) + # self.update_column(:state, :rejected) + self.destroy! end private diff --git a/lib/check_basic_abilities.rb b/lib/check_basic_abilities.rb index 8b5691d720..5d57449858 100644 --- a/lib/check_basic_abilities.rb +++ b/lib/check_basic_abilities.rb @@ -125,8 +125,8 @@ def extra_perms_for_all_users !(@user.cached_teams & obj.feed.team_ids).empty? end - can :read, FeedInvitation do |obj| - @user.email == obj.email || @user.id == obj.user_id + can [:read, :destroy], FeedInvitation do |obj| + @user.email == obj.email || @user.id == obj.user_id || TeamUser.where(user_id: @user.id, team_id: obj.feed.team_id, role: 'admin').exists? end end