Sha256: 7d7c486ce0fceb449526615a2694f25ab055e2e38695ab9c8d243d1769e666ff
Contents?: true
Size: 735 Bytes
Versions: 18
Compression:
Stored size: 735 Bytes
Contents
# frozen_string_literal: true module Thredded class PrivatePostPolicy # @param user [Thredded.user_class] # @param post [Thredded::PrivatePost] def initialize(user, post) @user = user @post = post end def create? @user.thredded_admin? || @post.postable.users.include?(@user) && !@user.thredded_user_detail.blocked? end def read? Thredded::PrivateTopicPolicy.new(@user, @post.postable).read? end def update? @user.thredded_admin? || own_post? end def destroy? !@post.first_post_in_topic? && update? end def anonymous? @user.thredded_anonymous? end private def own_post? @user.id == @post.user_id end end end
Version data entries
18 entries across 18 versions & 2 rubygems