Skip to content

Commit

Permalink
#actor changed to #federails_actor
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Dec 9, 2024
1 parent 899f786 commit fc04e79
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/components/follow_button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def before_render
if @signed_out
@path = @target.is_a?(Federails::Actor) ?
follow_remote_actor_path(@target) :
remote_follow_path(uri: @target.actor.federated_url, name: @target.name)
remote_follow_path(uri: @target.federails_actor.federated_url, name: @target.name)
@method = :post
else
@path = @target.is_a?(Federails::Actor) ?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def new

def create
@report = Federails::Moderation::Report.create report_params.merge({
federails_actor: current_user.actor,
object: @reportable.actor
federails_actor: current_user.federails_actor,
object: @reportable.federails_actor
})
redirect_to(@reportable, notice: t(".success"))
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/activity/creator_added_model_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def perform(model_id)
commenter: model.creator,
comment: I18n.t("jobs.activity.creator_added_model.comment", # rubocop:disable I18n/RailsI18n/DecorateStringFormattingUsingInterpolation
model_name: model.name,
url: model.actor.profile_url,
url: model.federails_actor.profile_url,
tags: model.tag_list.map { |t| "##{t}" }.join(" ")),
sensitive: model.sensitive
)
Expand Down
6 changes: 3 additions & 3 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def to_activitypub_object
].compact.join("\n\n"),
context: Rails.application.routes.url_helpers.url_for([commentable, only_path: false]),
published: created_at&.iso8601,
attributedTo: (commenter&.actor&.respond_to?(:federated_url) ? commenter.actor.federated_url : nil),
attributedTo: (commenter&.federails_actor&.respond_to?(:federated_url) ? commenter.federails_actor.federated_url : nil),
sensitive: sensitive,
to: ["https://www.w3.org/ns/activitystreams#Public"],
cc: [commenter.actor.followers_url],
cc: [commenter.federails_actor.followers_url],
tag: tags
}.compact
end
Expand All @@ -60,7 +60,7 @@ def post_update_activity
def post_activity(action)
if public?
Federails::Activity.create!(
actor: commenter.actor,
actor: commenter.federails_actor,
action: action,
entity: self
)
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/followable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def followers
end

def followed_by?(follower)
actor.followers.include? follower.actor
actor.followers.include? follower.federails_actor
end

private
Expand All @@ -34,7 +34,7 @@ def followable_post_activity(action)
user = permitted_users.with_permission("own").first || SiteSettings.default_user
return if user.nil?
Federails::Activity.create!(
actor: user.actor,
actor: user.federails_actor,
action: action,
entity: actor,
created_at: updated_at
Expand Down
6 changes: 3 additions & 3 deletions app/models/concerns/follower.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ def follows
end

def follow(target)
following_follows.create(target_actor: target.is_a?(Federails::Actor) ? target : target.actor)
following_follows.create(target_actor: target.is_a?(Federails::Actor) ? target : target.federails_actor)
end

def unfollow(target)
f = actor.follows?(target.actor)
f = actor.follows?(target.federails_actor)
f&.destroy unless f == false
end

def following?(target)
# follows? gives us the relationship or false if it doesn't exist,
# so we turn that into a normal boolean
tgt = target.is_a?(Federails::Actor) ? target : target.actor
tgt = target.is_a?(Federails::Actor) ? target : target.federails_actor
actor&.follows?(tgt)&.is_a?(Federails::Following)
end
end
2 changes: 1 addition & 1 deletion app/views/activities/_create_actor.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%- subject = activity&.actor %>
<%- subject = activity&.federails_actor %>
<%- object = activity&.entity %>
<%- thing = object&.entity %>
<% if thing && !thing.is_a?(User) && (thing.grants_permission_to?(["view", "edit", "own"], current_user) || thing.grants_permission_to?(["view", "edit", "own"], current_user&.roles)) %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/activities/_create_following.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<div class="card-body py-2">
<div class="row">
<div class="col">
<% if follow.actor.entity == current_user %>
<% if follow.federails_actor.entity == current_user %>
You
<% else %>
<%= follow.actor.name %>
<%= follow.federails_actor.name %>
<% end %>
followed
<%= link_to follow.target_actor.name, follow.target_actor.entity %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/activities/_update_actor.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%- subject = activity&.actor %>
<%- subject = activity&.federails_actor %>
<%- object = activity&.entity %>
<%- thing = object&.entity %>
<% if thing && !thing.is_a?(User) && (thing.grants_permission_to?(["view", "edit", "own"], current_user) || thing.grants_permission_to?(["view", "edit", "own"], current_user&.roles)) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/creators/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="col col-auto">
<%= content_tag(:div, class: "text-center") do %>
<%= content_tag(:h2) { @creator.name } %>
<p><small class="text-secondary">@<%= @creator.actor.at_address if SiteSettings.federation_enabled? %></small></p>
<p><small class="text-secondary">@<%= @creator.federails_actor.at_address if SiteSettings.federation_enabled? %></small></p>
<%= render FollowButtonComponent.new(follower: current_user, target: @creator) %>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/model_files/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for :head do %>
<%= tag.meta property: "og:type", content: "website" %>
<%= tag.meta name: "fediverse:creator", content: @file.model.creator.actor.at_address if @file.model.creator %>
<%= tag.meta name: "fediverse:creator", content: @file.model.creator.federails_actor.at_address if @file.model.creator %>
<% end %>

<%= render partial: "breadcrumb" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/models/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= tag.meta property: "og:type", content: "website" %>
<%= tag.meta property: "og:image", content: model_model_file_url(@model, @model.preview_file, format: @model.preview_file.extension) if @model.preview_file&.is_image? && [email protected] %>
<%= tag.meta name: "description", content: truncate(sanitize(@model.notes), length: 80) if @model.notes.present? %>
<%= tag.meta name: "fediverse:creator", content: "@#{@model.creator.actor.at_address}" if @model.creator %>
<%= tag.meta name: "fediverse:creator", content: "@#{@model.creator.federails_actor.at_address}" if @model.creator %>
<% end %>

<% content_for :page_header do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/settings/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<% if SiteSettings.federation_enabled? %>
<tr>
<th><%= t("settings.users.index.fediverse_address") %></th>
<td><%= @user.actor.at_address %></td>
<td><%= @user.federails_actor.at_address %></td>
</tr>
<% else %>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion db/data/20241013215000_backfill_activities_after_uuids.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class BackfillActivitiesAfterUuids < ActiveRecord::Migration[7.1]
def up
Model.unscoped.limit(20).order(created_at: :desc).each do |model|
model.send :post_creation_activity if model.actor&.activities&.empty?
model.send :post_creation_activity if model.federails_actor&.activities&.empty?
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/models/comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@
end

it "includes attribution" do
expect(ap_object[:attributedTo]).to eq commenter.actor.federated_url
expect(ap_object[:attributedTo]).to eq commenter.federails_actor.federated_url
end

it "includes to field" do
expect(ap_object[:to]).to include "https://www.w3.org/ns/activitystreams#Public"
end

it "includes cc field" do
expect(ap_object[:cc]).to include commenter.actor.followers_url
expect(ap_object[:cc]).to include commenter.federails_actor.followers_url
end

it "includes tags appended to content" do
Expand Down
6 changes: 3 additions & 3 deletions spec/models/concerns/followable_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

it "posts an activity" do
entity = create(described_class.to_s.underscore.to_sym)
expect(Federails::Activity.where(entity: entity.actor, action: "Create").count).to eq 1
expect(Federails::Activity.where(entity: entity.federails_actor, action: "Create").count).to eq 1
end
end

Expand All @@ -36,13 +36,13 @@

it "posts an activity after update" do
entity.update caption: "test"
expect(Federails::Activity.where(entity: entity.actor, action: "Update").count).to eq 1
expect(Federails::Activity.where(entity: entity.federails_actor, action: "Update").count).to eq 1
end

it "doesn't post an activity after update if there's already been one recently" do
entity.update caption: "change"
entity.update caption: "change again"
expect(Federails::Activity.where(entity: entity.actor, action: "Update").count).to eq 1
expect(Federails::Activity.where(entity: entity.federails_actor, action: "Update").count).to eq 1
end
end
end
10 changes: 5 additions & 5 deletions spec/requests/webfinger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
let(:creator) { create(:creator) }

before do
get("/.well-known/webfinger?resource=acct:#{creator.actor.at_address}")
get("/.well-known/webfinger?resource=acct:#{creator.federails_actor.at_address}")
end

it "returns a successful response" do
expect(response).to have_http_status :success
end

it "responds with data on the correct user" do
expect(response.parsed_body["links"][0]["href"]).to eq creator.actor.federated_url
expect(response.parsed_body["links"][0]["href"]).to eq creator.federails_actor.federated_url
end
end

Expand All @@ -27,19 +27,19 @@
let(:object) { create(followable) }

before do
get("/.well-known/webfinger?resource=#{object.actor.federated_url}")
get("/.well-known/webfinger?resource=#{object.federails_actor.federated_url}")
end

it "returns a successful response" do
expect(response).to have_http_status :success
end

it "responds with data on the correct #{followable}" do
expect(response.parsed_body["links"][0]["href"]).to eq object.actor.federated_url
expect(response.parsed_body["links"][0]["href"]).to eq object.federails_actor.federated_url
end

it "returns a not found response if item doesn't exist" do
expect { get("/.well-known/webfinger?resource=#{object.actor.federated_url}9999") }.to raise_error(ActiveRecord::RecordNotFound)
expect { get("/.well-known/webfinger?resource=#{object.federails_actor.federated_url}9999") }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
Expand Down

0 comments on commit fc04e79

Please sign in to comment.