Skip to content

Commit

Permalink
add should_federate_method for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Jan 14, 2025
1 parent 4d149f8 commit 1db15ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GIT

GIT
remote: https://gitlab.com/experimentslabs/federails
revision: ee1a65d0a67a39615ecce01a4a7be62b960793ca
revision: e366dc4ff8aa34f7884547180bc94998d320423a
branch: 22-data-binding-for-incoming-outgoing-objects
specs:
federails (0.4.0)
Expand Down
6 changes: 3 additions & 3 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Comment < ApplicationRecord
belongs_to :commentable, polymorphic: true

include Federails::DataEntity
acts_as_federails_data handles: "Note", actor_entity_method: :commenter, url_param: :public_id
acts_as_federails_data handles: "Note", actor_entity_method: :commenter, url_param: :public_id, should_federate_method: :public?

def to_activitypub_object
# Comments become Notes in ActvityPub
Expand All @@ -19,13 +19,13 @@ def to_activitypub_object
}.merge(address_options)
end

private

def public?
Pundit::PolicyFinder.new(commenter.class).policy.new(nil, commenter).show? &&
Pundit::PolicyFinder.new(commentable.class).policy.new(nil, commentable).show?
end

private

def activitypub_tags
return nil unless commentable.respond_to?(:tags)
commentable.tags.pluck(:name).map do |tag|
Expand Down

0 comments on commit 1db15ee

Please sign in to comment.