From fc04e79a3723d3a51ad2a97ff9a24bd00beebc27 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 9 Dec 2024 14:19:50 +0000 Subject: [PATCH] #actor changed to #federails_actor --- app/components/follow_button_component.rb | 2 +- app/controllers/reports_controller.rb | 4 ++-- app/jobs/activity/creator_added_model_job.rb | 2 +- app/models/comment.rb | 6 +++--- app/models/concerns/followable.rb | 4 ++-- app/models/concerns/follower.rb | 6 +++--- app/views/activities/_create_actor.html.erb | 2 +- app/views/activities/_create_following.html.erb | 4 ++-- app/views/activities/_update_actor.html.erb | 2 +- app/views/creators/show.html.erb | 2 +- app/views/model_files/show.html.erb | 2 +- app/views/models/show.html.erb | 2 +- app/views/settings/users/show.html.erb | 2 +- .../20241013215000_backfill_activities_after_uuids.rb | 2 +- spec/models/comment_spec.rb | 4 ++-- spec/models/concerns/followable_shared.rb | 6 +++--- spec/requests/webfinger_spec.rb | 10 +++++----- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/components/follow_button_component.rb b/app/components/follow_button_component.rb index e379883ee..40b60eccb 100644 --- a/app/components/follow_button_component.rb +++ b/app/components/follow_button_component.rb @@ -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) ? diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 34eb784c8..b6baeff9f 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -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 diff --git a/app/jobs/activity/creator_added_model_job.rb b/app/jobs/activity/creator_added_model_job.rb index 42c47949d..a385c8449 100644 --- a/app/jobs/activity/creator_added_model_job.rb +++ b/app/jobs/activity/creator_added_model_job.rb @@ -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 ) diff --git a/app/models/comment.rb b/app/models/comment.rb index 4f4f7f8e9..68ae521b0 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 @@ -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 ) diff --git a/app/models/concerns/followable.rb b/app/models/concerns/followable.rb index e7f0ca6ea..6c1731391 100644 --- a/app/models/concerns/followable.rb +++ b/app/models/concerns/followable.rb @@ -17,7 +17,7 @@ def followers end def followed_by?(follower) - actor.followers.include? follower.actor + actor.followers.include? follower.federails_actor end private @@ -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 diff --git a/app/models/concerns/follower.rb b/app/models/concerns/follower.rb index 5742494b8..f36eea858 100644 --- a/app/models/concerns/follower.rb +++ b/app/models/concerns/follower.rb @@ -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 diff --git a/app/views/activities/_create_actor.html.erb b/app/views/activities/_create_actor.html.erb index 2d317cdcf..033933f73 100644 --- a/app/views/activities/_create_actor.html.erb +++ b/app/views/activities/_create_actor.html.erb @@ -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)) %> diff --git a/app/views/activities/_create_following.html.erb b/app/views/activities/_create_following.html.erb index b2c80ef8d..2ed114eec 100644 --- a/app/views/activities/_create_following.html.erb +++ b/app/views/activities/_create_following.html.erb @@ -4,10 +4,10 @@
- <% 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 %> diff --git a/app/views/activities/_update_actor.html.erb b/app/views/activities/_update_actor.html.erb index 2ad92ae57..775681d25 100644 --- a/app/views/activities/_update_actor.html.erb +++ b/app/views/activities/_update_actor.html.erb @@ -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)) %> diff --git a/app/views/creators/show.html.erb b/app/views/creators/show.html.erb index d73e868b2..3aacabb5a 100644 --- a/app/views/creators/show.html.erb +++ b/app/views/creators/show.html.erb @@ -9,7 +9,7 @@
<%= content_tag(:div, class: "text-center") do %> <%= content_tag(:h2) { @creator.name } %> -

@<%= @creator.actor.at_address if SiteSettings.federation_enabled? %>

+

@<%= @creator.federails_actor.at_address if SiteSettings.federation_enabled? %>

<%= render FollowButtonComponent.new(follower: current_user, target: @creator) %> <% end %>
diff --git a/app/views/model_files/show.html.erb b/app/views/model_files/show.html.erb index fa0559d78..3be5a6ef9 100644 --- a/app/views/model_files/show.html.erb +++ b/app/views/model_files/show.html.erb @@ -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" %> diff --git a/app/views/models/show.html.erb b/app/views/models/show.html.erb index 5001c531c..64bc3c686 100644 --- a/app/views/models/show.html.erb +++ b/app/views/models/show.html.erb @@ -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? && !@model.sensitive %> <%= 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 %> diff --git a/app/views/settings/users/show.html.erb b/app/views/settings/users/show.html.erb index 4c860bbab..6d530f61e 100644 --- a/app/views/settings/users/show.html.erb +++ b/app/views/settings/users/show.html.erb @@ -37,7 +37,7 @@ <% if SiteSettings.federation_enabled? %> <%= t("settings.users.index.fediverse_address") %> - <%= @user.actor.at_address %> + <%= @user.federails_actor.at_address %> <% else %> diff --git a/db/data/20241013215000_backfill_activities_after_uuids.rb b/db/data/20241013215000_backfill_activities_after_uuids.rb index c14eff763..7eed52e64 100644 --- a/db/data/20241013215000_backfill_activities_after_uuids.rb +++ b/db/data/20241013215000_backfill_activities_after_uuids.rb @@ -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 diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 754b652a3..d4c6b9814 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -56,7 +56,7 @@ 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 @@ -64,7 +64,7 @@ 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 diff --git a/spec/models/concerns/followable_shared.rb b/spec/models/concerns/followable_shared.rb index 7d5618972..cdbc6fce4 100644 --- a/spec/models/concerns/followable_shared.rb +++ b/spec/models/concerns/followable_shared.rb @@ -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 @@ -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 diff --git a/spec/requests/webfinger_spec.rb b/spec/requests/webfinger_spec.rb index 920344b6c..88a26d0e3 100644 --- a/spec/requests/webfinger_spec.rb +++ b/spec/requests/webfinger_spec.rb @@ -5,7 +5,7 @@ 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 @@ -13,7 +13,7 @@ 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 @@ -27,7 +27,7 @@ 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 @@ -35,11 +35,11 @@ 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