Skip to content

Commit

Permalink
Merge pull request #3270 from manyfold3d/dependabot/bundler/federails…
Browse files Browse the repository at this point in the history
…-0.4.0
  • Loading branch information
dependabot[bot] authored Dec 9, 2024
2 parents d4e41fc + fc04e79 commit c5f0f03
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ gem "better_content_security_policy", "~> 0.1.4"
gem "devise_zxcvbn", "~> 6.0"

gem "ransack", "~> 4.2"
gem "federails", "~> 0.3"
gem "federails", "~> 0.4"
gem "federails-moderation", github: "manyfold3d/federails-moderation"
gem "caber"

Expand Down
21 changes: 11 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.4.0)
date (3.4.1)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand Down Expand Up @@ -232,7 +232,7 @@ GEM
faraday (>= 1, < 3)
faraday-net_http (3.4.0)
net-http (>= 0.5.0)
federails (0.3.0)
federails (0.4.0)
faraday
faraday-follow_redirects
json-ld (>= 3.2.0)
Expand Down Expand Up @@ -320,7 +320,7 @@ GEM
has_scope (>= 0.6)
railties (>= 6.0)
responders (>= 2)
io-console (0.7.2)
io-console (0.8.0)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
Expand All @@ -334,7 +334,7 @@ GEM
thor (>= 0.14, < 2.0)
jsbundling-rails (1.3.1)
railties (>= 6.0.0)
json (2.8.2)
json (2.9.0)
json-canonicalization (1.0.0)
json-jwt (1.16.6)
activesupport (>= 4.2)
Expand Down Expand Up @@ -379,7 +379,7 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
locale (2.1.4)
logger (1.6.1)
logger (1.6.2)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
Expand Down Expand Up @@ -414,7 +414,7 @@ GEM
mysql2 (0.5.6)
nanoid (2.0.0)
nenv (0.3.0)
net-http (0.5.0)
net-http (0.6.0)
uri
net-imap (0.5.1)
date
Expand Down Expand Up @@ -484,7 +484,8 @@ GEM
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
psych (5.2.0)
psych (5.2.1)
date
stringio
public_suffix (6.0.1)
puma (6.5.0)
Expand Down Expand Up @@ -642,7 +643,7 @@ GEM
rubyzip (2.3.2)
scout_apm (5.4.0)
parser
securerandom (0.3.2)
securerandom (0.4.0)
shellany (0.0.1)
shrine (3.6.0)
content_disposition (~> 1.0)
Expand Down Expand Up @@ -734,7 +735,7 @@ GEM
activesupport
faraday (~> 2.0)
faraday-follow_redirects
webrick (1.9.0)
webrick (1.9.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down Expand Up @@ -773,7 +774,7 @@ DEPENDENCIES
erb_lint (~> 0.7.0)
factory_bot
faker (~> 3.5)
federails (~> 0.3)
federails (~> 0.4)
federails-moderation!
ffi-libarchive (~> 1.1)
get_process_mem (~> 1.0)
Expand Down
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
2 changes: 1 addition & 1 deletion app/models/concerns/federails_common.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module FederailsCommon
extend ActiveSupport::Concern
include Federails::Entity
include Federails::ActorEntity

def actor
act = Federails::Actor.find_by(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 c5f0f03

Please sign in to comment.