Skip to content

Commit

Permalink
Merge pull request #2992 from manyfold3d/nodeinfo
Browse files Browse the repository at this point in the history
More accurate registration and usage data in nodeinfo
  • Loading branch information
Floppy authored Oct 19, 2024
2 parents 57a05e1 + 197c653 commit 1491167
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GIT

GIT
remote: https://gitlab.com/experimentslabs/federails.git
revision: bfe2192c1c64d619e8dd2e1e5d8d7dee8c4db12f
revision: ce5064916a23fdf4a2bb1991b6610439a33bd37a
branch: main
specs:
federails (0.2.0)
Expand Down Expand Up @@ -732,7 +732,7 @@ GEM
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.7.0)
zeitwerk (2.7.1)
zxcvbn (0.1.10)

PLATFORMS
Expand Down
2 changes: 1 addition & 1 deletion app/models/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Collection < ApplicationRecord
include PublicIDable
include Commentable

acts_as_federails_actor username_field: :public_id, name_field: :name, profile_url_method: :url_for, actor_type: "Group", include_in_user_count: false
acts_as_federails_actor username_field: :public_id, name_field: :name, profile_url_method: :url_for, actor_type: "Group"

has_many :models, dependent: :nullify
has_many :collections, dependent: :nullify
Expand Down
2 changes: 1 addition & 1 deletion app/models/creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Creator < ApplicationRecord
include PublicIDable
include Commentable

acts_as_federails_actor username_field: :slug, name_field: :name, profile_url_method: :url_for, include_in_user_count: false
acts_as_federails_actor username_field: :slug, name_field: :name, profile_url_method: :url_for

has_many :models, dependent: :nullify
validates :name, uniqueness: {case_sensitive: false}
Expand Down
2 changes: 1 addition & 1 deletion app/models/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Model < ApplicationRecord
include PublicIDable
include Commentable

acts_as_federails_actor username_field: :public_id, name_field: :name, profile_url_method: :url_for, actor_type: "Service", include_in_user_count: false
acts_as_federails_actor username_field: :public_id, name_field: :name, profile_url_method: :url_for, actor_type: "Service"

scope :recent, -> { order(created_at: :desc) }

Expand Down
2 changes: 1 addition & 1 deletion app/models/site_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SiteSettings < RailsSettings::Base
field :default_viewer_role, type: :string, default: "member"

def self.registration_enabled?
ENV.fetch("REGISTRATION", false) == "enabled"
Rails.application.config.manyfold_features[:registration]
end

def self.email_configured?
Expand Down
10 changes: 9 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class User < ApplicationRecord
include Follower
include CaberSubject

acts_as_federails_actor username_field: :username, name_field: :username
acts_as_federails_actor username_field: :username, name_field: :username, user_count_method: :user_count

rolify
devise :database_authenticatable,
Expand Down Expand Up @@ -108,6 +108,14 @@ def self.from_omniauth(auth)
user
end

def self.user_count(range)
return User.count if range.nil?

# Updated date isn't a great proxy for activity, but it'll do for now
# We can improve this by using devise trackable to track logins at some point
User.where(updated_at: range).count
end

private

def has_any_role_of?(*args)
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Application < Rails::Application
# Some are automatically enabled in test mode because they impact initialization
config.manyfold_features = {
multiuser: (ENV.fetch("MULTIUSER", nil) == "enabled"),
registration: (ENV.fetch("REGISTRATION", nil) == "enabled"),
federation: (ENV.fetch("FEDERATION", nil) == "enabled"),
demo_mode: (ENV.fetch("DEMO_MODE", nil) == "enabled"),
oidc: ENV.key?("OIDC_CLIENT_ID") && ENV.key?("OIDC_CLIENT_SECRET") && ENV.key?("OIDC_ISSUER")
Expand Down
1 change: 1 addition & 0 deletions config/initializers/federails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
conf.force_ssl = Rails.application.config.force_ssl

conf.enable_discovery = Rails.application.config.manyfold_features[:federation] || Rails.env.test?
conf.open_registrations = Rails.application.config.manyfold_features[:registration]
conf.server_routes_path = "federation"
conf.client_routes_path = "client"

Expand Down

0 comments on commit 1491167

Please sign in to comment.