Compare commits

...

12 Commits

Author SHA1 Message Date
Matt Jankowski
560a144c97
Merge 4393bd395a into c442589593 2025-07-10 08:06:40 +00:00
Matt Jankowski
c442589593
Use ActiveModel::Attributes in FollowLimitable concern (#35327)
Some checks failed
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Bundler Audit / security (push) Has been cancelled
CSS Linting / lint (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
2025-07-10 07:40:56 +00:00
renovate[bot]
28633a504a
chore(deps): update dependency json-schema to v5.2.1 (#35337)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-10 07:38:07 +00:00
Matt Jankowski
ad78701b6f
Mark private methods in AnnualReport::TopStatuses (#35256) 2025-07-10 07:35:40 +00:00
Matt Jankowski
1496488771
Add Status#not_replying_to_account scope for annual report classes (#35257) 2025-07-10 07:35:04 +00:00
renovate[bot]
dd3d958e75
fix(deps): update dependency core-js to v3.44.0 (#35284)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-10 07:23:54 +00:00
github-actions[bot]
b363a3651d
New Crowdin Translations (automated) (#35335)
Co-authored-by: GitHub Actions <noreply@github.com>
2025-07-10 07:23:27 +00:00
renovate[bot]
86645fc14c
chore(deps): update dependency rubocop to v1.78.0 (#35289)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-10 07:23:23 +00:00
Matt Jankowski
f9beecb343
Improve Accounts CLI prune spec (#35302) 2025-07-10 07:23:09 +00:00
Matt Jankowski
4ecfbd3920
Add Status.only_polls (and without polls) scope (#35330) 2025-07-10 07:13:22 +00:00
Claire
a315934314
Fix styling of external log-in button (#35320) 2025-07-10 06:56:40 +00:00
Matt Jankowski
4393bd395a Convert to doorkeeper ORM mixin style for OAuth models 2025-07-03 18:28:24 -04:00
69 changed files with 355 additions and 226 deletions

View File

@ -365,7 +365,7 @@ GEM
json-ld-preloaded (3.3.1)
json-ld (~> 3.3)
rdf (~> 3.3)
json-schema (5.1.1)
json-schema (5.2.1)
addressable (~> 2.8)
bigdecimal (~> 3.1)
jsonapi-renderer (0.2.2)
@ -761,7 +761,7 @@ GEM
rspec-mocks (~> 3.0)
sidekiq (>= 5, < 9)
rspec-support (3.13.4)
rubocop (1.77.0)
rubocop (1.78.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)

View File

@ -4,7 +4,7 @@ class Api::V1::AppsController < Api::BaseController
skip_before_action :require_authenticated_user!
def create
@app = Doorkeeper::Application.create!(application_options)
@app = OAuth::Application.create!(application_options)
render json: @app, serializer: REST::CredentialApplicationSerializer
end

View File

@ -17,7 +17,7 @@ class OAuth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
def destroy
Web::PushSubscription.unsubscribe_for(params[:id], current_resource_owner)
Doorkeeper::Application.find_by(id: params[:id])&.close_streaming_sessions(current_resource_owner)
OAuth::Application.find_by(id: params[:id])&.close_streaming_sessions(current_resource_owner)
super
end

View File

@ -10,7 +10,7 @@ class Settings::ApplicationsController < Settings::BaseController
def show; end
def new
@application = Doorkeeper::Application.new(
@application = OAuth::Application.new(
redirect_uri: Doorkeeper.configuration.native_redirect_uri,
scopes: 'profile'
)
@ -59,6 +59,6 @@ class Settings::ApplicationsController < Settings::BaseController
end
def application_params
params.expect(doorkeeper_application: [:name, :redirect_uri, :website, scopes: []])
params.expect(oauth_application: [:name, :redirect_uri, :website, scopes: []])
end
end

View File

@ -66,7 +66,7 @@ module ApplicationHelper
def provider_sign_in_link(provider)
label = Devise.omniauth_configs[provider]&.strategy&.display_name.presence || I18n.t("auth.providers.#{provider}", default: provider.to_s.chomp('_oauth2').capitalize)
link_to label, omniauth_authorize_path(:user, provider), class: "button button-#{provider}", method: :post
link_to label, omniauth_authorize_path(:user, provider), class: "btn button-#{provider}", method: :post
end
def locale_direction

View File

@ -386,7 +386,7 @@
"follow_suggestions.similar_to_recently_followed_longer": "Minder om profiler, du har fulgt for nylig",
"follow_suggestions.view_all": "Vis alle",
"follow_suggestions.who_to_follow": "Hvem, som skal følges",
"followed_tags": "Hashtag, som følges",
"followed_tags": "Hashtags, som følges",
"footer.about": "Om",
"footer.directory": "Profiloversigt",
"footer.get_app": "Hent appen",
@ -560,7 +560,7 @@
"navigation_bar.favourites": "Favoritter",
"navigation_bar.filters": "Skjulte ord",
"navigation_bar.follow_requests": "Følgeanmodninger",
"navigation_bar.followed_tags": "Hashtag, som følges",
"navigation_bar.followed_tags": "Hashtags, som følges",
"navigation_bar.follows_and_followers": "Følges og følgere",
"navigation_bar.import_export": "Import og eksport",
"navigation_bar.lists": "Lister",

View File

@ -569,6 +569,7 @@
"notification.admin.sign_up.name_and_others": "{name} eta {count, plural, one {erabiltzaile # gehiago} other {# erabiltzaile gehiago}} erregistratu dira",
"notification.favourite": "{name}(e)k zure bidalketa gogoko du",
"notification.favourite.name_and_others_with_link": "{name} eta <a>{count, plural, one {erabiltzaile # gehiagok} other {# erabiltzaile gehiagok}}</a> zure bidalketa gogoko dute",
"notification.favourite_pm": "{name}-ek zure aipamen pribatua gogokoetan jarri du",
"notification.follow": "{name}(e)k jarraitzen dizu",
"notification.follow_request": "{name}(e)k zu jarraitzeko eskaera egin du",
"notification.follow_request.name_and_others": "{name} eta {count, plural, one {erabiltzaile # gehiagok} other {# erabiltzaile gehiagok}} zu jarraitzeko eskaera egin dute",
@ -902,5 +903,7 @@
"video.hide": "Ezkutatu bideoa",
"video.pause": "Pausatu",
"video.play": "Jo",
"video.unmute": "Soinua ezarri",
"video.volume_down": "Bolumena jaitsi",
"video.volume_up": "Bolumena Igo"
}

View File

@ -356,6 +356,7 @@
"hashtag.counter_by_accounts": "{count, plural, one {{counter} partisipante} other {{counter} partisipantes}}",
"hashtag.counter_by_uses": "{count, plural, one {{counter} publikasyon} other {{counter} publikasyones}}",
"hashtag.counter_by_uses_today": "{count, plural, one {{counter} publikasyon} other {{counter} publikasyones}} oy",
"hashtag.feature": "Avalia en profil",
"hashtag.follow": "Sige etiketa",
"hashtag.mute": "Silensia #{hashtag}",
"hashtag.unfeature": "No avalia en profil",
@ -390,6 +391,7 @@
"interaction_modal.title.reblog": "Repartaja publikasyon de {name}",
"interaction_modal.title.reply": "Arisponde a publikasyon de {name}",
"interaction_modal.title.vote": "Vota en la anketa de {name}",
"interaction_modal.username_prompt": "Por enshemplo {example}",
"intervals.full.days": "{number, plural, one {# diya} other {# diyas}}",
"intervals.full.hours": "{number, plural, one {# ora} other {# oras}}",
"intervals.full.minutes": "{number, plural, one {# minuto} other {# minutos}}",
@ -442,6 +444,7 @@
"lists.delete": "Efasa lista",
"lists.done": "Fecho",
"lists.edit": "Edita lista",
"lists.list_name": "Nombre de lista",
"lists.new_list_name": "Nombre de mueva lista",
"lists.replies_policy.followed": "Kualseker utilizador segido",
"lists.replies_policy.list": "Miembros de la lista",
@ -738,6 +741,7 @@
"status.reblogs.empty": "Ainda nadie tiene repartajado esta publikasyon. Kuando algien lo aga, se amostrara aki.",
"status.redraft": "Efasa i eskrive de muevo",
"status.remove_bookmark": "Kita markador",
"status.remove_favourite": "Kita de los favoritos",
"status.replied_in_thread": "Arispondo en filo",
"status.replied_to": "Arispondio a {name}",
"status.reply": "Arisponde",
@ -758,6 +762,7 @@
"subscribed_languages.save": "Guadra trokamientos",
"subscribed_languages.target": "Troka linguas abonadas para {target}",
"tabs_bar.home": "Linya prinsipala",
"tabs_bar.menu": "Menu",
"tabs_bar.notifications": "Avizos",
"tabs_bar.publish": "Mueva publikasyon",
"tabs_bar.search": "Bushkeda",

View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
module AccessGrantExtension
extend ActiveSupport::Concern
included do
scope :expired, -> { where.not(expires_in: nil).where('created_at + MAKE_INTERVAL(secs => expires_in) < NOW()') }
scope :revoked, -> { where.not(revoked_at: nil).where(revoked_at: ...Time.now.utc) }
end
end

View File

@ -1,29 +0,0 @@
# frozen_string_literal: true
module AccessTokenExtension
extend ActiveSupport::Concern
included do
include Redisable
has_many :web_push_subscriptions, class_name: 'Web::PushSubscription', inverse_of: :access_token
after_commit :push_to_streaming_api
scope :expired, -> { where.not(expires_in: nil).where('created_at + MAKE_INTERVAL(secs => expires_in) < NOW()') }
scope :not_revoked, -> { where(revoked_at: nil) }
scope :revoked, -> { where.not(revoked_at: nil).where(revoked_at: ...Time.now.utc) }
end
def revoke(clock = Time)
update(revoked_at: clock.now.utc)
end
def update_last_used(request, clock = Time)
update(last_used_at: clock.now.utc, last_used_ip: request.remote_ip)
end
def push_to_streaming_api
redis.publish("timeline:access_token:#{id}", Oj.dump(event: :kill)) if revoked? || destroyed?
end
end

View File

@ -28,7 +28,7 @@ class AnnualReport::Archetype < AnnualReport::Source
end
def polls_count
@polls_count ||= report_statuses.where.not(poll_id: nil).count
@polls_count ||= report_statuses.only_polls.count
end
def reblogs_count
@ -36,7 +36,7 @@ class AnnualReport::Archetype < AnnualReport::Source
end
def replies_count
@replies_count ||= report_statuses.where.not(in_reply_to_id: nil).where.not(in_reply_to_account_id: @account.id).count
@replies_count ||= report_statuses.where.not(in_reply_to_id: nil).not_replying_to_account(@account).count
end
def standalone_count

View File

@ -18,7 +18,7 @@ class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
private
def commonly_interacted_with_accounts
report_statuses.where.not(in_reply_to_account_id: @account.id).group(:in_reply_to_account_id).having(minimum_interaction_count).order(count_all: :desc).limit(SET_SIZE).count
report_statuses.not_replying_to_account(@account).group(:in_reply_to_account_id).having(minimum_interaction_count).order(count_all: :desc).limit(SET_SIZE).count
end
def minimum_interaction_count

View File

@ -2,20 +2,44 @@
class AnnualReport::TopStatuses < AnnualReport::Source
def generate
top_reblogs = base_scope.order(reblogs_count: :desc).first&.id
top_favourites = base_scope.where.not(id: top_reblogs).order(favourites_count: :desc).first&.id
top_replies = base_scope.where.not(id: [top_reblogs, top_favourites]).order(replies_count: :desc).first&.id
{
top_statuses: {
by_reblogs: top_reblogs&.to_s,
by_favourites: top_favourites&.to_s,
by_replies: top_replies&.to_s,
by_reblogs: status_identifier(most_reblogged_status),
by_favourites: status_identifier(most_favourited_status),
by_replies: status_identifier(most_replied_status),
},
}
end
private
def status_identifier(status)
status.id.to_s if status.present?
end
def most_reblogged_status
base_scope
.order(reblogs_count: :desc)
.first
end
def most_favourited_status
base_scope
.excluding(most_reblogged_status)
.order(favourites_count: :desc)
.first
end
def most_replied_status
base_scope
.excluding(most_reblogged_status, most_favourited_status)
.order(replies_count: :desc)
.first
end
def base_scope
report_statuses.public_visibility.joins(:status_stat)
report_statuses
.public_visibility
.joins(:status_stat)
end
end

View File

@ -6,7 +6,7 @@ class AnnualReport::TypeDistribution < AnnualReport::Source
type_distribution: {
total: report_statuses.count,
reblogs: report_statuses.only_reblogs.count,
replies: report_statuses.where.not(in_reply_to_id: nil).where.not(in_reply_to_account_id: @account.id).count,
replies: report_statuses.where.not(in_reply_to_id: nil).not_replying_to_account(@account).count,
standalone: report_statuses.without_replies.without_reblogs.count,
},
}

View File

@ -1,49 +0,0 @@
# frozen_string_literal: true
module ApplicationExtension
extend ActiveSupport::Concern
APP_NAME_LIMIT = 60
APP_REDIRECT_URI_LIMIT = 2_000
APP_WEBSITE_LIMIT = 2_000
included do
include Redisable
has_many :created_users, class_name: 'User', foreign_key: 'created_by_application_id', inverse_of: :created_by_application
validates :name, length: { maximum: APP_NAME_LIMIT }
validates :redirect_uri, length: { maximum: APP_REDIRECT_URI_LIMIT }
validates :website, url: true, length: { maximum: APP_WEBSITE_LIMIT }, if: :website?
# The relationship used between Applications and AccessTokens is using
# dependent: delete_all, which means the ActiveRecord callback in
# AccessTokenExtension is not run, so instead we manually announce to
# streaming that these tokens are being deleted.
before_destroy :close_streaming_sessions, prepend: true
end
def confirmation_redirect_uri
redirect_uri.lines.first.strip
end
def redirect_uris
# Doorkeeper stores the redirect_uri value as a newline delimeted list in
# the database:
redirect_uri.split
end
def close_streaming_sessions(resource_owner = nil)
# TODO: #28793 Combine into a single topic
payload = Oj.dump(event: :kill)
scope = access_tokens
scope = scope.where(resource_owner_id: resource_owner.id) unless resource_owner.nil?
scope.in_batches do |tokens|
redis.pipelined do |pipeline|
tokens.ids.each do |id|
pipeline.publish("timeline:access_token:#{id}", payload)
end
end
end
end
end

View File

@ -9,12 +9,12 @@ class Vacuum::AccessTokensVacuum
private
def vacuum_revoked_access_tokens!
Doorkeeper::AccessToken.expired.in_batches.delete_all
Doorkeeper::AccessToken.revoked.in_batches.delete_all
OAuth::AccessToken.expired.in_batches.delete_all
OAuth::AccessToken.revoked.in_batches.delete_all
end
def vacuum_revoked_access_grants!
Doorkeeper::AccessGrant.expired.in_batches.delete_all
Doorkeeper::AccessGrant.revoked.in_batches.delete_all
OAuth::AccessGrant.expired.in_batches.delete_all
OAuth::AccessGrant.revoked.in_batches.delete_all
end
end

View File

@ -161,7 +161,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
end
def without_poll_scope
Status.where(poll_id: nil)
Status.without_polls
end
def without_popular_scope

View File

@ -4,14 +4,8 @@ module FollowLimitable
extend ActiveSupport::Concern
included do
validates_with FollowLimitValidator, on: :create, unless: :bypass_follow_limit?
end
validates_with FollowLimitValidator, on: :create, unless: :bypass_follow_limit
def bypass_follow_limit=(value)
@bypass_follow_limit = value
end
def bypass_follow_limit?
@bypass_follow_limit
attribute :bypass_follow_limit, :boolean, default: false
end
end

7
app/models/oauth.rb Normal file
View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
module OAuth
def self.table_name_prefix
'oauth_'
end
end

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
class OAuth::AccessGrant < ApplicationRecord
include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant
scope :expired, -> { where.not(expires_in: nil).where('created_at + MAKE_INTERVAL(secs => expires_in) < NOW()') }
scope :revoked, -> { where.not(revoked_at: nil).where(revoked_at: ...Time.now.utc) }
end

View File

@ -0,0 +1,29 @@
# frozen_string_literal: true
class OAuth::AccessToken < ApplicationRecord
include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken
include Redisable
has_many :web_push_subscriptions, class_name: 'Web::PushSubscription', inverse_of: :access_token, dependent: nil
scope :expired, -> { where.not(expires_in: nil).where('created_at + MAKE_INTERVAL(secs => expires_in) < NOW()') }
scope :not_revoked, -> { where(revoked_at: nil) }
scope :revoked, -> { where.not(revoked_at: nil).where(revoked_at: ...Time.now.utc) }
after_commit :push_to_streaming_api
def revoke(clock = Time)
update(revoked_at: clock.now.utc)
end
def update_last_used(request, clock = Time)
update(last_used_at: clock.now.utc, last_used_ip: request.remote_ip)
end
private
def push_to_streaming_api
redis.publish("timeline:access_token:#{id}", Oj.dump(event: :kill)) if revoked? || destroyed?
end
end

View File

@ -0,0 +1,44 @@
# frozen_string_literal: true
class OAuth::Application < ApplicationRecord
include ::Doorkeeper::Orm::ActiveRecord::Mixins::Application
APP_NAME_LIMIT = 60
APP_REDIRECT_URI_LIMIT = 2_000
APP_WEBSITE_LIMIT = 2_000
include Redisable
has_many :created_users, class_name: 'User', foreign_key: :created_by_application_id, inverse_of: :created_by_application, dependent: nil
validates :name, length: { maximum: APP_NAME_LIMIT }
validates :redirect_uri, length: { maximum: APP_REDIRECT_URI_LIMIT }
validates :website, url: true, length: { maximum: APP_WEBSITE_LIMIT }, if: :website?
before_destroy :close_streaming_sessions, prepend: true
def confirmation_redirect_uri
redirect_uri.lines.first.strip
end
def redirect_uris
# The redirect_uri value is stored as a newline delimited list
redirect_uri.split
end
# The association between `Application` and `AccessToken` uses a setting of
# `dependent: delete_all` which means the callbacks in `AccessToken` are not
# run. Instead, announce to streaming that these tokens are being deleted.
def close_streaming_sessions(resource_owner = nil)
payload = Oj.dump(event: :kill)
scope = access_tokens
scope = scope.where(resource_owner_id: resource_owner.id) unless resource_owner.nil?
scope.in_batches do |tokens|
redis.pipelined do |pipeline|
tokens.ids.each do |id|
pipeline.publish("timeline:access_token:#{id}", payload)
end
end
end
end
end

View File

@ -32,7 +32,7 @@ class Report < ApplicationRecord
rate_limit by: :account, family: :reports
belongs_to :account
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
belongs_to :application, class_name: 'OAuth::Application', optional: true
with_options class_name: 'Account' do
belongs_to :target_account

View File

@ -19,7 +19,7 @@ class SessionActivation < ApplicationRecord
include BrowserDetection
belongs_to :user, inverse_of: :session_activations
belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', dependent: :destroy, optional: true
belongs_to :access_token, class_name: 'OAuth::AccessToken', dependent: :destroy, optional: true
belongs_to :web_push_subscription, class_name: 'Web::PushSubscription', dependent: :destroy, optional: true
delegate :token,
@ -61,12 +61,12 @@ class SessionActivation < ApplicationRecord
private
def assign_access_token
self.access_token = Doorkeeper::AccessToken.create!(access_token_attributes)
self.access_token = OAuth::AccessToken.create!(access_token_attributes)
end
def access_token_attributes
{
application_id: Doorkeeper::Application.find_by(superapp: true)&.id,
application_id: OAuth::Application.find_by(superapp: true)&.id,
resource_owner_id: user_id,
scopes: DEFAULT_SCOPES.join(' '),
expires_in: Doorkeeper.configuration.access_token_expires_in,

View File

@ -64,7 +64,7 @@ class Status < ApplicationRecord
update_index('statuses', :proper)
update_index('public_statuses', :proper)
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
belongs_to :application, class_name: 'OAuth::Application', optional: true
belongs_to :account, inverse_of: :statuses
belongs_to :in_reply_to_account, class_name: 'Account', optional: true
@ -121,7 +121,10 @@ class Status < ApplicationRecord
scope :without_replies, -> { not_reply.or(reply_to_account) }
scope :not_reply, -> { where(reply: false) }
scope :only_reblogs, -> { where.not(reblog_of_id: nil) }
scope :only_polls, -> { where.not(poll_id: nil) }
scope :without_polls, -> { where(poll_id: nil) }
scope :reply_to_account, -> { where(arel_table[:in_reply_to_account_id].eq arel_table[:account_id]) }
scope :not_replying_to_account, ->(account) { where.not(in_reply_to_account: account) }
scope :without_reblogs, -> { where(statuses: { reblog_of_id: nil }) }
scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) }
scope :not_excluded_by_account, ->(account) { where.not(account_id: account.excluded_from_timeline_account_ids) }

View File

@ -83,11 +83,11 @@ class User < ApplicationRecord
belongs_to :account, inverse_of: :user
belongs_to :invite, counter_cache: :uses, optional: true
belongs_to :created_by_application, class_name: 'Doorkeeper::Application', optional: true
belongs_to :created_by_application, class_name: 'OAuth::Application', optional: true
belongs_to :role, class_name: 'UserRole', optional: true
accepts_nested_attributes_for :account
has_many :applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: nil
has_many :applications, class_name: 'OAuth::Application', as: :owner, dependent: nil
has_many :backups, inverse_of: :user, dependent: nil
has_many :invites, inverse_of: :user, dependent: nil
has_many :markers, inverse_of: :user, dependent: :destroy
@ -303,7 +303,7 @@ class User < ApplicationRecord
end
def applications_last_used
Doorkeeper::AccessToken
OAuth::AccessToken
.where(resource_owner_id: id)
.where.not(last_used_at: nil)
.group(:application_id)
@ -314,7 +314,7 @@ class User < ApplicationRecord
def token_for_app(app)
return nil if app.nil? || app.owner != self
Doorkeeper::AccessToken.find_or_create_by(application_id: app.id, resource_owner_id: id) do |t|
OAuth::AccessToken.find_or_create_by(application_id: app.id, resource_owner_id: id) do |t|
t.scopes = app.scopes
t.expires_in = Doorkeeper.configuration.access_token_expires_in
t.use_refresh_token = Doorkeeper.configuration.refresh_token_enabled?
@ -368,9 +368,9 @@ class User < ApplicationRecord
end
def revoke_access!
Doorkeeper::AccessGrant.by_resource_owner(self).touch_all(:revoked_at)
OAuth::AccessGrant.by_resource_owner(self).touch_all(:revoked_at)
Doorkeeper::AccessToken.by_resource_owner(self).in_batches do |batch|
OAuth::AccessToken.by_resource_owner(self).in_batches do |batch|
batch.touch_all(:revoked_at)
Web::PushSubscription.where(access_token_id: batch).delete_all

View File

@ -18,7 +18,7 @@
class Web::PushSubscription < ApplicationRecord
belongs_to :user
belongs_to :access_token, class_name: 'Doorkeeper::AccessToken'
belongs_to :access_token, class_name: 'OAuth::AccessToken'
has_one :session_activation, foreign_key: 'web_push_subscription_id', inverse_of: :web_push_subscription, dependent: nil
@ -42,7 +42,7 @@ class Web::PushSubscription < ApplicationRecord
class << self
def unsubscribe_for(application_id, resource_owner)
access_token_ids = Doorkeeper::AccessToken.where(application_id: application_id, resource_owner_id: resource_owner.id).not_revoked.pluck(:id)
access_token_ids = OAuth::AccessToken.where(application_id: application_id, resource_owner_id: resource_owner.id).not_revoked.pluck(:id)
where(access_token_id: access_token_ids).delete_all
end
end

View File

@ -27,7 +27,7 @@ class AppSignUpService < BaseService
end
def create_access_token!
@access_token = Doorkeeper::AccessToken.create!(
@access_token = OAuth::AccessToken.create!(
application: @app,
resource_owner_id: @user.id,
scopes: @app.scopes,

View File

@ -26,7 +26,7 @@ class PostStatusService < BaseService
# @option [String] :scheduled_at
# @option [Hash] :poll Optional poll to attach
# @option [Enumerable] :media_ids Optional array of media IDs to attach
# @option [Doorkeeper::Application] :application
# @option [OAuth::Application] :application
# @option [String] :idempotency Optional idempotency key
# @option [Boolean] :with_rate_limit
# @option [Enumerable] :allowed_mentions Optional array of expected mentioned account IDs, raises `UnexpectedMentionsError` if unexpected accounts end up in mentions

View File

@ -21,7 +21,7 @@ class PublishScheduledStatusWorker
def options_with_objects(options)
options.tap do |options_hash|
options_hash[:application] = Doorkeeper::Application.find(options_hash.delete(:application_id)) if options[:application_id]
options_hash[:application] = OAuth::Application.find(options_hash.delete(:application_id)) if options[:application_id]
options_hash[:thread] = Status.find(options_hash.delete(:in_reply_to_id)) if options_hash[:in_reply_to_id]
end
end

View File

@ -20,7 +20,7 @@ class Scheduler::IpCleanupScheduler
SessionActivation.where(updated_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(ip: nil)
User.where(current_sign_in_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(sign_up_ip: nil)
LoginActivity.where(created_at: ...IP_RETENTION_PERIOD.ago).in_batches.destroy_all
Doorkeeper::AccessToken.where(last_used_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(last_used_ip: nil)
OAuth::AccessToken.where(last_used_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(last_used_ip: nil)
end
def clean_expired_ip_blocks!

View File

@ -117,9 +117,6 @@ module Mastodon
end
config.to_prepare do
Doorkeeper::Application.include ApplicationExtension
Doorkeeper::AccessGrant.include AccessGrantExtension
Doorkeeper::AccessToken.include AccessTokenExtension
Devise::FailureApp.include AbstractController::Callbacks
Devise::FailureApp.include Localized
end

View File

@ -4,6 +4,10 @@ Doorkeeper.configure do
# Change the ORM that doorkeeper will use (needs plugins)
orm :active_record
access_grant_class 'OAuth::AccessGrant'
access_token_class 'OAuth::AccessToken'
application_class 'OAuth::Application'
# This block will be called to check whether the resource owner is authenticated or not.
resource_owner_authenticator do
current_user || redirect_to(new_user_session_url)

View File

@ -1347,7 +1347,7 @@ da:
your_appeal_rejected: Din appel er afvist
edit_profile:
basic_information: Oplysninger
hint_html: "<strong>Tilpas hvad folk ser på din offentlige profil og ved siden af dine indlæg.</strong> Andre personer vil mere sandsynligt følge dig tilbage og interagere med dig, når du har en udfyldt profil og et profilbillede."
hint_html: "<strong>Tilpas, hvad folk ser på din offentlige profil og ved siden af dine indlæg.</strong> Andre personer er mere tilbøjelige til at følge dig tilbage og interagere med dig, når du har en udfyldt profil og et profilbillede."
other: Andre
emoji_styles:
auto: Auto

View File

@ -1944,7 +1944,7 @@ de:
contrast: Mastodon (Hoher Kontrast)
default: Mastodon (Dunkel)
mastodon-light: Mastodon (Hell)
system: Automatisch (mit System synchronisieren)
system: Automatisch (wie Betriebssystem)
time:
formats:
default: "%d. %b %Y, %H:%M Uhr"

View File

@ -467,8 +467,11 @@ eu:
fasp:
debug:
callbacks:
created_at: Sortua hemen
delete: Ezabatu
ip: IP helbidea
request_body: Eskaeraren edukia
title: Atzera-deiak araztu
providers:
active: Aktibo
base_url: Oinarrizko URL-a
@ -822,6 +825,7 @@ eu:
destroyed_msg: Guneko igoera ongi ezabatu da!
software_updates:
critical_update: Kritikoa — mesedez, eguneratu azkar
description: Gomendagarria da Mastodon instalazioa eguneratuta mantentzea azken konponketa eta funtzioez baliatzeko. Gainera, batzuetan ezinbestekoa da Mastodon garaiz eguneratzea segurtasun arazoak saihesteko. Arrazoi hauengatik, Mastodonek 30 minuturo eguneratzeak egiaztatzen ditu, eta zure posta elektroniko bidezko jakinarazpenen lehentasunen arabera jakinaraziko dizu.
documentation_link: Informazio gehiago
release_notes: Bertsio oharrak
title: Eguneraketak eskuragarri

View File

@ -1851,6 +1851,8 @@ fr-CA:
limit: Vous avez déjà épinglé le nombre maximum de messages
ownership: Vous ne pouvez pas épingler un message ne vous appartenant pas
reblog: Un partage ne peut pas être épinglé
quote_policies:
followers: Abonné·e·s et utilisateur·trice·s mentionné·e·s
title: "%{name}: « %{quote} »"
visibilities:
direct: Direct
@ -1904,6 +1906,8 @@ fr-CA:
does_not_match_previous_name: ne correspond pas au nom précédent
terms_of_service:
title: Conditions d'utilisation
terms_of_service_interstitial:
title: Les conditions d'utilisation de %{domain} ont changées
themes:
contrast: Mastodon (Contraste élevé)
default: Mastodon (Sombre)

View File

@ -1851,6 +1851,8 @@ fr:
limit: Vous avez déjà épinglé le nombre maximum de messages
ownership: Vous ne pouvez pas épingler un message ne vous appartenant pas
reblog: Un partage ne peut pas être épinglé
quote_policies:
followers: Abonné·e·s et utilisateur·trice·s mentionné·e·s
title: "%{name}: « %{quote} »"
visibilities:
direct: Direct
@ -1904,6 +1906,8 @@ fr:
does_not_match_previous_name: ne correspond pas au nom précédent
terms_of_service:
title: Conditions d'utilisation
terms_of_service_interstitial:
title: Les conditions d'utilisation de %{domain} ont changées
themes:
contrast: Mastodon (Contraste élevé)
default: Mastodon (Sombre)

View File

@ -1406,6 +1406,10 @@ ga:
basic_information: Eolas bunúsach
hint_html: "<strong>Saincheap a bhfeiceann daoine ar do phróifíl phoiblí agus in aice le do phostálacha.</strong> Is dóichí go leanfaidh daoine eile ar ais tú agus go n-idirghníomhóidh siad leat nuair a bhíonn próifíl líonta agus pictiúr próifíle agat."
other: Eile
emoji_styles:
auto: Uath
native: Dúchasach
twemoji: Twemoji
errors:
'400': Bhí an t-iarratas a chuir tú isteach neamhbhailí nó míchumtha.
'403': Níl cead agat an leathanach seo a fheiceáil.

View File

@ -1351,6 +1351,10 @@ it:
basic_information: Informazioni di base
hint_html: "<strong>Personalizza ciò che le persone vedono sul tuo profilo pubblico e accanto ai tuoi post.</strong> È più probabile che altre persone ti seguano e interagiscano con te quando hai un profilo compilato e un'immagine del profilo."
other: Altro
emoji_styles:
auto: Automatico
native: Nativo
twemoji: Twemoji
errors:
'400': La richiesta che hai inviato non è valida o non è corretta.
'403': Non sei autorizzato a visualizzare questa pagina.

View File

@ -186,6 +186,7 @@ lad:
create_domain_block: Kriya bloko de domeno
create_email_domain_block: Kriya bloko de domeno de posta
create_ip_block: Kriya regla de IP
create_relay: Kriya relevo
create_unavailable_domain: Kriya domeno no desponivle
create_user_role: Kriya rolo
demote_user: Degrada utilizador
@ -197,6 +198,7 @@ lad:
destroy_email_domain_block: Efasa bloko de domeno de posta
destroy_instance: Efasa domeno
destroy_ip_block: Efasa regla de IP
destroy_relay: Efasa relevo
destroy_status: Efasa publikasyon
destroy_unavailable_domain: Efasa domeno no desponivle
destroy_user_role: Efasa rolo
@ -205,6 +207,7 @@ lad:
disable_sign_in_token_auth_user: Inkapasita la autentifikasyon por token de posta elektronika para el utilizador
disable_user: Inkapasita utilizador
enable_custom_emoji: Kapasita emoji personalizados
enable_relay: Aktiva relevo
enable_sign_in_token_auth_user: Kapasita la autentifikasyon por token de posta para el utilizador
enable_user: Kapasita utilizador
memorialize_account: Transforma en kuento komemorativo
@ -229,6 +232,7 @@ lad:
update_custom_emoji: Aktualiza emoji personalizado
update_domain_block: Aktualiza bloko de domeno
update_ip_block: Aktualiza regla de IP
update_report: Aktualiza raporto
update_status: Aktualiza publikasyon
update_user_role: Aktualiza rolo
actions:
@ -466,10 +470,13 @@ lad:
fasp:
debug:
callbacks:
created_at: Kriyado en
delete: Efasa
ip: Adreso IP
providers:
active: Aktivo
delete: Efasa
finish_registration: Finaliza enrejistrasyon
name: Nombre
registrations:
confirm: Konfirma
@ -542,6 +549,12 @@ lad:
all: Todos
limited: Limitado
title: Moderasyon
moderation_notes:
create: Adjusta nota de moderasyon
created_msg: Nota de moderasyon de sirvidor kriyada kon sukseso!
description_html: Ve i desha notas a otros moderadores i a tu yo futuro
destroyed_msg: Nota de moderasyon de sirvidor efasada kon sukseso!
title: Notas de moderasyon
private_comment: Komento privado
public_comment: Komento publiko
purge: Purga
@ -748,6 +761,7 @@ lad:
title: Rolos
rules:
add_new: Adjusta regla
add_translation: Adjusta traduksyon
delete: Efasa
description_html: Aunke la majorita afirma aver meldado i estar de akodro kon los terminos de servisyo, la djente normalmente no los melda asta dempues de ke surja algun problema. <strong>Az ke sea mas kolay ver las normas de tu sirvidor de un vistazo estipulándolas en una lista de puntos.</strong> Aprova ke kada norma sea corta i kolay, ama sin estar divididas en munchos puntos.
edit: Edita regla
@ -920,6 +934,9 @@ lad:
updated_msg: Konfigurasyon de etiketas aktualizada kon sukseso
terms_of_service:
changelog: Ke troko
current: Aktual
generates:
action: Djenera
history: Istorya
live: En bivo
publish: Publika
@ -1245,6 +1262,10 @@ lad:
basic_information: Enformasyon bazika
hint_html: "<strong>Personaliza lo ke la djente ve en tu profil publiko i kon tus publikasyones.</strong> Es mas probavle ke otras personas te sigan i enteraktuen kontigo kuando kompletas tu profil i foto."
other: Otros
emoji_styles:
auto: Otomatiko
native: Nativo
twemoji: Twemoji
errors:
'400': La solisitasyon ke enviates no fue valida o fue malformada.
'403': No tienes permiso para ver esta pajina.

View File

@ -583,7 +583,7 @@ nl:
created_msg: Aanmaken van servermoderatie-opmerking geslaagd!
description_html: Opmerkingen bekijken, en voor jezelf en andere moderatoren achterlaten
destroyed_msg: Verwijderen van servermoderatie-opmerking geslaagd!
placeholder: Informatie over deze server, genomen acties of iets anders die jou kunnen helpen om deze server in de toekomst te moderen.
placeholder: Informatie over deze server, genomen acties of iets anders die jou kunnen helpen om deze server in de toekomst te modereren.
title: Moderatie-opmerkingen
private_comment: Privé-opmerking
public_comment: Openbare opmerking

View File

@ -61,7 +61,7 @@ da:
setting_display_media_default: Skjul medier med sensitiv-markering
setting_display_media_hide_all: Skjul altid medier
setting_display_media_show_all: Vis altid medier
setting_emoji_style: Hvordan emojis skal vises. "Auto" vil forsøge at bruge indbyggede emojis, men skifter tilbage til Twemoji for ældre browsere.
setting_emoji_style: Hvordan emojis skal vises. "Auto" vil forsøge at bruge indbyggede emojis, men skifter tilbage til Twemoji i ældre webbrowsere.
setting_system_scrollbars_ui: Gælder kun for computerwebbrowsere baseret på Safari og Chrome
setting_use_blurhash: Gradienter er baseret på de skjulte grafikelementers farver, men slører alle detaljer
setting_use_pending_items: Skjul tidslinjeopdateringer bag et klik i stedet for brug af auto-feedrulning

View File

@ -61,7 +61,7 @@ de:
setting_display_media_default: Medien mit Inhaltswarnung ausblenden
setting_display_media_hide_all: Medien immer ausblenden
setting_display_media_show_all: Medien mit Inhaltswarnung immer anzeigen
setting_emoji_style: Darstellung von Emojis. „Automatisch“ verwendet native Emojis, für ältere Browser jedoch Twemoji.
setting_emoji_style: 'Wie Emojis dargestellt werden: „Automatisch“ verwendet native Emojis, für veraltete Browser wird jedoch Twemoji verwendet.'
setting_system_scrollbars_ui: Betrifft nur Desktop-Browser, die auf Chrome oder Safari basieren
setting_use_blurhash: Der Farbverlauf basiert auf den Farben der ausgeblendeten Medien, verschleiert aber jegliche Details
setting_use_pending_items: Neue Beiträge hinter einem Klick verstecken, anstatt automatisch zu scrollen
@ -248,7 +248,7 @@ de:
setting_missing_alt_text_modal: Bestätigungsdialog anzeigen, bevor Medien ohne Bildbeschreibung veröffentlicht werden
setting_reduce_motion: Bewegung in Animationen verringern
setting_system_font_ui: Standardschriftart des Browsers verwenden
setting_system_scrollbars_ui: Bildlaufleiste des Systems verwenden
setting_system_scrollbars_ui: Bildlaufleiste des Betriebssystems verwenden
setting_theme: Design
setting_trends: Heutige Trends anzeigen
setting_unfollow_modal: Bestätigungsdialog beim Entfolgen eines Profils anzeigen

View File

@ -61,6 +61,7 @@ ga:
setting_display_media_default: Folaigh meáin atá marcáilte mar íogair
setting_display_media_hide_all: Folaigh meáin i gcónaí
setting_display_media_show_all: Taispeáin meáin i gcónaí
setting_emoji_style: Conas emojis a thaispeáint. Déanfaidh "Auto" iarracht emoji dúchasacha a úsáid, ach titeann sé ar ais go Twemoji le haghaidh seanbhrabhsálaithe.
setting_system_scrollbars_ui: Ní bhaineann sé ach le brabhsálaithe deisce bunaithe ar Safari agus Chrome
setting_use_blurhash: Tá grádáin bunaithe ar dhathanna na n-amharcanna ceilte ach cuireann siad salach ar aon mhionsonraí
setting_use_pending_items: Folaigh nuashonruithe amlíne taobh thiar de chlic seachas an fotha a scrollú go huathoibríoch
@ -244,6 +245,7 @@ ga:
setting_display_media_default: Réamhshocrú
setting_display_media_hide_all: Cuir uile i bhfolach
setting_display_media_show_all: Taispeáin uile
setting_emoji_style: Stíl Emoji
setting_expand_spoilers: Méadaigh postálacha atá marcáilte le rabhaidh inneachair i gcónaí
setting_hide_network: Folaigh do ghraf sóisialta
setting_missing_alt_text_modal: Taispeáin dialóg deimhnithe sula bpostálann tú meán gan alt téacs

View File

@ -61,6 +61,7 @@ it:
setting_display_media_default: Nascondi media segnati come sensibili
setting_display_media_hide_all: Nascondi sempre tutti i media
setting_display_media_show_all: Mostra sempre i media segnati come sensibili
setting_emoji_style: Come visualizzare gli emoji. "Automatico" proverà a usare gli emoji nativi, ma per i browser più vecchi ricorrerà a Twemoji.
setting_system_scrollbars_ui: Si applica solo ai browser desktop basati su Safari e Chrome
setting_use_blurhash: I gradienti sono basati sui colori delle immagini nascoste ma offuscano tutti i dettagli
setting_use_pending_items: Fare clic per mostrare i nuovi messaggi invece di aggiornare la timeline automaticamente
@ -241,6 +242,7 @@ it:
setting_display_media_default: Predefinita
setting_display_media_hide_all: Nascondi tutti
setting_display_media_show_all: Mostra tutti
setting_emoji_style: Stile emoji
setting_expand_spoilers: Espandi sempre post con content warning
setting_hide_network: Nascondi la tua rete
setting_missing_alt_text_modal: Chiedi di confermare prima di pubblicare media senza testo alternativo

View File

@ -61,7 +61,7 @@ nl:
setting_display_media_default: Als gevoelig gemarkeerde media verbergen
setting_display_media_hide_all: Media altijd verbergen
setting_display_media_show_all: Media altijd tonen
setting_emoji_style: Waarmee moeten emojis worden weergegeven. "Auto" probeert de systeemeigen emojis te gebruiken, maar valt terug op Twemoji voor oudere webbrowsers.
setting_emoji_style: Waarmee moeten emojis worden weergegeven. Auto probeert de systeemeigen emojis te gebruiken, maar valt terug op Twemoji voor oudere webbrowsers.
setting_system_scrollbars_ui: Alleen van toepassing op desktopbrowsers gebaseerd op Safari en Chrome
setting_use_blurhash: Wazige kleurovergangen zijn gebaseerd op de kleuren van de verborgen media, waarmee elk detail verdwijnt
setting_use_pending_items: De tijdlijn wordt bijgewerkt door op het aantal nieuwe items te klikken, in plaats van dat deze automatisch wordt bijgewerkt

View File

@ -234,6 +234,7 @@ uk:
setting_display_media_default: За промовчанням
setting_display_media_hide_all: Сховати всі
setting_display_media_show_all: Показати всі
setting_emoji_style: Стиль емодзі
setting_expand_spoilers: Завжди розгортати дописи з попередженнями про вміст
setting_hide_network: Сховати вашу мережу
setting_missing_alt_text_modal: Запитувати перед розміщенням медіа без альтернативного тексту

View File

@ -1338,6 +1338,9 @@ uk:
basic_information: Основна інформація
hint_html: "<strong>Налаштуйте те, що люди бачитимуть у вашому загальнодоступному профілі та поруч із вашими дописами.</strong> Інші люди з більшою ймовірністю підпишуться на вас та взаємодіятимуть з вами, якщо у вас є заповнений профіль та зображення профілю."
other: Інше
emoji_styles:
auto: Авто
native: Рідний
errors:
'400': Ваш запит був недійсним або неправильним.
'403': У Вас немає доступу до перегляду даної сторінки.

View File

@ -1,3 +1,3 @@
# frozen_string_literal: true
Doorkeeper::Application.create_with(name: 'Web', redirect_uri: Doorkeeper.configuration.native_redirect_uri, scopes: 'read write follow push').find_or_create_by(superapp: true)
OAuth::Application.create_with(name: 'Web', redirect_uri: Doorkeeper.configuration.native_redirect_uri, scopes: 'read write follow push').find_or_create_by(superapp: true)

View File

@ -134,12 +134,12 @@ namespace :tests do
exit(1)
end
unless Doorkeeper::Application.find(2)[:scopes] == 'write:accounts profile'
unless OAuth::Application.find(2)[:scopes] == 'write:accounts profile'
puts 'Application OAuth scopes not rewritten as expected'
exit(1)
end
unless Doorkeeper::Application.find(2).access_tokens.first[:scopes] == 'write:accounts profile'
unless OAuth::Application.find(2).access_tokens.first[:scopes] == 'write:accounts profile'
puts 'OAuth access token scopes not rewritten as expected'
exit(1)
end

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe OAuth::AuthorizationsController do
render_views
let(:app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: 'http://localhost/', scopes: 'read') }
let(:app) { OAuth::Application.create!(name: 'test', redirect_uri: 'http://localhost/', scopes: 'read') }
describe 'GET #new' do
subject do
@ -34,7 +34,7 @@ RSpec.describe OAuth::AuthorizationsController do
context 'when app is already authorized' do
before do
Doorkeeper::AccessToken.find_or_create_for(
OAuth::AccessToken.find_or_create_for(
application: app,
resource_owner: user.id,
scopes: app.scopes,

View File

@ -55,7 +55,7 @@ RSpec.describe OAuth::AuthorizedApplicationsController do
it 'revokes access tokens for the application and removes subscriptions and sends kill payload to streaming' do
post :destroy, params: { id: application.id }
expect(Doorkeeper::AccessToken.where(application: application).first.revoked_at)
expect(OAuth::AccessToken.where(application: application).first.revoked_at)
.to_not be_nil
expect(Web::PushSubscription.where(user: user).count)
.to eq(0)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
Fabricator :access_grant, from: 'Doorkeeper::AccessGrant' do
Fabricator :access_grant, from: OAuth::AccessGrant do
application
resource_owner_id { Fabricate(:user).id }
expires_in 3_600

View File

@ -1,3 +1,3 @@
# frozen_string_literal: true
Fabricator :access_token, from: 'Doorkeeper::AccessToken'
Fabricator :access_token, from: OAuth::AccessToken

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
Fabricator(:application, from: Doorkeeper::Application) do
Fabricator(:application, from: OAuth::Application) do
name 'Example'
website 'http://example.com'
redirect_uri 'http://example.com/callback'

View File

@ -1288,49 +1288,64 @@ RSpec.describe Mastodon::CLI::Accounts do
describe '#prune' do
let(:action) { :prune }
let!(:local_account) { Fabricate(:account) }
let!(:bot_account) { Fabricate(:account, bot: true, domain: 'example.com') }
let!(:group_account) { Fabricate(:account, actor_type: 'Group', domain: 'example.com') }
let!(:mentioned_account) { Fabricate(:account, domain: 'example.com') }
let!(:prunable_accounts) do
Fabricate.times(2, :account, domain: 'example.com', bot: false, suspended_at: nil, silenced_at: nil)
end
let(:viable_attrs) { { domain: 'example.com', bot: false, suspended: false, silenced: false } }
let!(:local_account) { Fabricate(:account) }
let!(:bot_account) { Fabricate(:account, bot: true, domain: 'example.com') }
let!(:group_account) { Fabricate(:account, actor_type: 'Group', domain: 'example.com') }
let!(:account_mentioned) { Fabricate(:account, viable_attrs) }
let!(:account_with_favourite) { Fabricate(:account, viable_attrs) }
let!(:account_with_status) { Fabricate(:account, viable_attrs) }
let!(:account_with_follow) { Fabricate(:account, viable_attrs) }
let!(:account_targeted_follow) { Fabricate(:account, viable_attrs) }
let!(:account_with_block) { Fabricate(:account, viable_attrs) }
let!(:account_targeted_block) { Fabricate(:account, viable_attrs) }
let!(:account_targeted_mute) { Fabricate(:account, viable_attrs) }
let!(:account_targeted_report) { Fabricate(:account, viable_attrs) }
let!(:account_with_follow_request) { Fabricate(:account, viable_attrs) }
let!(:account_targeted_follow_request) { Fabricate(:account, viable_attrs) }
let!(:prunable_accounts) { Fabricate.times(2, :account, viable_attrs) }
before do
Fabricate(:mention, account: mentioned_account, status: Fabricate(:status, account: Fabricate(:account)))
Fabricate :mention, account: account_mentioned, status: Fabricate(:status, account: Fabricate(:account))
Fabricate :favourite, account: account_with_favourite
Fabricate :status, account: account_with_status
Fabricate :follow, account: account_with_follow
Fabricate :follow, target_account: account_targeted_follow
Fabricate :block, account: account_with_block
Fabricate :block, target_account: account_targeted_block
Fabricate :mute, target_account: account_targeted_mute
Fabricate :report, target_account: account_targeted_report
Fabricate :follow_request, account: account_with_follow_request
Fabricate :follow_request, target_account: account_targeted_follow_request
stub_parallelize_with_progress!
end
def expect_prune_remote_accounts_without_interaction
prunable_account_ids = prunable_accounts.pluck(:id)
expect(Account.where(id: prunable_account_ids).count).to eq(0)
end
it 'displays a successful message and handles accounts correctly' do
expect { subject }
.to output_results("OK, pruned #{prunable_accounts.size} accounts")
expect_prune_remote_accounts_without_interaction
expect_not_prune_local_accounts
expect_not_prune_bot_accounts
expect_not_prune_group_accounts
expect_not_prune_mentioned_accounts
expect(prunable_account_records)
.to have_attributes(count: eq(0))
expect(Account.all)
.to include(local_account)
.and include(bot_account)
.and include(group_account)
.and include(account_mentioned)
.and include(account_with_favourite)
.and include(account_with_status)
.and include(account_with_follow)
.and include(account_targeted_follow)
.and include(account_with_block)
.and include(account_targeted_block)
.and include(account_targeted_mute)
.and include(account_targeted_report)
.and include(account_with_follow_request)
.and include(account_targeted_follow_request)
.and not_include(prunable_accounts.first)
.and not_include(prunable_accounts.last)
end
def expect_not_prune_local_accounts
expect(Account.exists?(id: local_account.id)).to be(true)
end
def expect_not_prune_bot_accounts
expect(Account.exists?(id: bot_account.id)).to be(true)
end
def expect_not_prune_group_accounts
expect(Account.exists?(id: group_account.id)).to be(true)
end
def expect_not_prune_mentioned_accounts
expect(Account.exists?(id: mentioned_account.id)).to be true
def prunable_account_records
Account.where(id: prunable_accounts.pluck(:id))
end
context 'with --dry-run option' do

View File

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Doorkeeper::AccessGrant do
RSpec.describe OAuth::AccessGrant do
describe 'Validations' do
subject { Fabricate :access_grant }

View File

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Doorkeeper::AccessToken do
RSpec.describe OAuth::AccessToken do
describe 'Associations' do
it { is_expected.to have_many(:web_push_subscriptions).class_name('Web::PushSubscription').inverse_of(:access_token) }
end

View File

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Doorkeeper::Application do
RSpec.describe OAuth::Application do
describe 'Associations' do
it { is_expected.to have_many(:created_users).class_name('User').inverse_of(:created_by_application).with_foreign_key(:created_by_application_id) }
end

View File

@ -191,6 +191,19 @@ RSpec.describe Status do
end
end
describe '.not_replying_to_account' do
let(:account) { Fabricate :account }
let!(:status_from_account) { Fabricate :status, account: account }
let!(:reply_to_account_status) { Fabricate :status, thread: status_from_account }
let!(:reply_to_other) { Fabricate :status, thread: Fabricate(:status) }
it 'returns records not in reply to provided account' do
expect(described_class.not_replying_to_account(account))
.to not_include(reply_to_account_status)
.and include(reply_to_other)
end
end
describe '#untrusted_favourites_count' do
before do
alice.update(domain: 'example.com')
@ -363,6 +376,28 @@ RSpec.describe Status do
end
end
describe '.only_polls' do
let!(:poll_status) { Fabricate :status, poll: Fabricate(:poll) }
let!(:no_poll_status) { Fabricate :status }
it 'returns the expected statuses' do
expect(described_class.only_polls)
.to include(poll_status)
.and not_include(no_poll_status)
end
end
describe '.without_polls' do
let!(:poll_status) { Fabricate :status, poll: Fabricate(:poll) }
let!(:no_poll_status) { Fabricate :status }
it 'returns the expected statuses' do
expect(described_class.without_polls)
.to not_include(poll_status)
.and include(no_poll_status)
end
end
describe '.tagged_with' do
let(:tag_cats) { Fabricate(:tag, name: 'cats') }
let(:tag_dogs) { Fabricate(:tag, name: 'dogs') }

View File

@ -439,7 +439,7 @@ RSpec.describe User do
it 'creates and returns a persisted token' do
expect { user.token_for_app(app) }
.to change(Doorkeeper::AccessToken.where(resource_owner_id: user.id, application: app), :count).by(1)
.to change(OAuth::AccessToken.where(resource_owner_id: user.id, application: app), :count).by(1)
end
end
@ -449,7 +449,7 @@ RSpec.describe User do
it 'returns a persisted token' do
expect(user.token_for_app(app))
.to be_a(Doorkeeper::AccessToken)
.to be_a(OAuth::AccessToken)
.and eq(token)
end
end
@ -531,7 +531,7 @@ RSpec.describe User do
end
def remove_active_user_tokens
change { Doorkeeper::AccessToken.active_for(user).count }.to(0)
change { OAuth::AccessToken.active_for(user).count }.to(0)
end
def remove_user_web_subscriptions

View File

@ -31,7 +31,7 @@ RSpec.describe 'Apps' do
expect(response.content_type)
.to start_with('application/json')
app = Doorkeeper::Application.find_by(name: client_name)
app = OAuth::Application.find_by(name: client_name)
expect(app).to be_present
expect(app.scopes.to_s).to eq scopes
@ -64,7 +64,7 @@ RSpec.describe 'Apps' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(Doorkeeper::Application.find_by(name: client_name)).to be_present
expect(OAuth::Application.find_by(name: client_name)).to be_present
expect(response.parsed_body)
.to include(
@ -84,7 +84,7 @@ RSpec.describe 'Apps' do
expect(response.content_type)
.to start_with('application/json')
app = Doorkeeper::Application.find_by(name: client_name)
app = OAuth::Application.find_by(name: client_name)
expect(app).to be_present
expect(app.scopes.to_s).to eq 'read'
@ -117,12 +117,12 @@ RSpec.describe 'Apps' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(Doorkeeper::Application.find_by(name: client_name).scopes.to_s).to eq 'read'
expect(OAuth::Application.find_by(name: client_name).scopes.to_s).to eq 'read'
end
end
context 'with a too-long name' do
let(:client_name) { 'a' * Doorkeeper::Application::APP_NAME_LIMIT * 2 }
let(:client_name) { 'a' * OAuth::Application::APP_NAME_LIMIT * 2 }
it 'returns http unprocessable entity' do
subject
@ -134,7 +134,7 @@ RSpec.describe 'Apps' do
end
context 'with a too-long website' do
let(:website) { "https://foo.bar/#{'a' * Doorkeeper::Application::APP_WEBSITE_LIMIT * 2}" }
let(:website) { "https://foo.bar/#{'a' * OAuth::Application::APP_WEBSITE_LIMIT * 2}" }
it 'returns http unprocessable entity' do
subject
@ -146,7 +146,7 @@ RSpec.describe 'Apps' do
end
context 'with a too-long redirect_uri' do
let(:redirect_uris) { "https://app.example/#{'a' * Doorkeeper::Application::APP_REDIRECT_URI_LIMIT * 2}" }
let(:redirect_uris) { "https://app.example/#{'a' * OAuth::Application::APP_REDIRECT_URI_LIMIT * 2}" }
it 'returns http unprocessable entity' do
subject
@ -180,7 +180,7 @@ RSpec.describe 'Apps' do
expect(response.content_type)
.to start_with('application/json')
app = Doorkeeper::Application.find_by(name: client_name)
app = OAuth::Application.find_by(name: client_name)
expect(app).to be_present
expect(app.redirect_uri).to eq redirect_uris
@ -204,7 +204,7 @@ RSpec.describe 'Apps' do
expect(response.content_type)
.to start_with('application/json')
app = Doorkeeper::Application.find_by(name: client_name)
app = OAuth::Application.find_by(name: client_name)
expect(app).to be_present
expect(app.redirect_uri).to eq redirect_uris.join "\n"
@ -276,7 +276,7 @@ RSpec.describe 'Apps' do
expect(response.content_type)
.to start_with('application/json')
app = Doorkeeper::Application.find_by(name: client_name)
app = OAuth::Application.find_by(name: client_name)
expect(app).to be_present
expect(app.website).to eq website

View File

@ -169,7 +169,7 @@ RSpec.describe 'Caching behavior' do
let(:alice) { Account.find_by(username: 'alice') }
let(:user) { User.find_by(email: 'user@host.example') }
let(:token) { Doorkeeper::AccessToken.find_by(resource_owner_id: user.id) }
let(:token) { OAuth::AccessToken.find_by(resource_owner_id: user.id) }
before_all do
alice = Fabricate(:account, username: 'alice')

View File

@ -25,7 +25,7 @@ RSpec.describe 'Settings / Exports' do
let(:params) do
{
doorkeeper_application: {
oauth_application: {
name: 'My New App',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
website: 'http://google.com',
@ -36,13 +36,13 @@ RSpec.describe 'Settings / Exports' do
it 'supports passing scope values as string' do
expect { subject }
.to change(Doorkeeper::Application, :count).by(1)
.to change(OAuth::Application, :count).by(1)
expect(response)
.to redirect_to(settings_applications_path)
end
it 'gracefully handles invalid nested params' do
post settings_applications_path(doorkeeper_application: 'invalid')
post settings_applications_path(oauth_application: 'invalid')
expect(response)
.to have_http_status(400)
@ -53,7 +53,7 @@ RSpec.describe 'Settings / Exports' do
let(:application) { Fabricate :application, owner: user }
it 'gracefully handles invalid nested params' do
put settings_application_path(application.id, doorkeeper_application: 'invalid')
put settings_application_path(application.id, oauth_application: 'invalid')
expect(response)
.to have_http_status(400)

View File

@ -68,7 +68,7 @@ RSpec.describe 'Auth Passwords' do
end
def user_token_count
Doorkeeper::AccessToken
OAuth::AccessToken
.active_for(user)
.count
end

View File

@ -7,7 +7,7 @@ RSpec.describe 'Using OAuth from an external app' do
subject { visit "/oauth/authorize?#{params.to_query}" }
let(:client_app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: about_url(host: Rails.application.config.x.local_domain), scopes: 'read') }
let(:client_app) { OAuth::Application.create!(name: 'test', redirect_uri: about_url(host: Rails.application.config.x.local_domain), scopes: 'read') }
let(:params) do
{ client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read' }
end
@ -264,7 +264,7 @@ RSpec.describe 'Using OAuth from an external app' do
end
def user_has_grant_with_client_app?
Doorkeeper::AccessGrant
OAuth::AccessGrant
.exists?(
application: client_app,
resource_owner_id: user.id

View File

@ -34,7 +34,7 @@ RSpec.describe 'Settings applications page' do
fill_in_form
expect { submit_form }
.to change(Doorkeeper::Application, :count).by(1)
.to change(OAuth::Application, :count).by(1)
expect(page)
.to have_content(I18n.t('doorkeeper.applications.index.title'))
.and have_content('My new app')
@ -47,7 +47,7 @@ RSpec.describe 'Settings applications page' do
visit new_settings_application_path
expect { submit_form }
.to not_change(Doorkeeper::Application, :count)
.to not_change(OAuth::Application, :count)
expect(page)
.to have_content("can't be blank")
end
@ -60,9 +60,9 @@ RSpec.describe 'Settings applications page' do
fill_in I18n.t('activerecord.attributes.doorkeeper/application.redirect_uri'),
with: 'urn:ietf:wg:oauth:2.0:oob'
check 'read', id: :doorkeeper_application_scopes_read
check 'write', id: :doorkeeper_application_scopes_write
check 'follow', id: :doorkeeper_application_scopes_follow
check 'read', id: :oauth_application_scopes_read
check 'write', id: :oauth_application_scopes_write
check 'follow', id: :oauth_application_scopes_follow
end
def submit_form
@ -76,12 +76,12 @@ RSpec.describe 'Settings applications page' do
fill_in form_app_name_label,
with: 'My new app name with a new value'
check 'push', id: :doorkeeper_application_scopes_push
check 'push', id: :oauth_application_scopes_push
submit_form
expect(page)
.to have_content('My new app name with a new value')
.and have_checked_field('push', id: :doorkeeper_application_scopes_push)
.and have_checked_field('push', id: :oauth_application_scopes_push)
end
it 'does not update with wrong values' do
@ -110,7 +110,7 @@ RSpec.describe 'Settings applications page' do
visit settings_applications_path
expect { destroy_application }
.to change(Doorkeeper::Application, :count).by(-1)
.to change(OAuth::Application, :count).by(-1)
expect(page)
.to have_no_content(application.name)
expect(redis_pipeline_stub)

View File

@ -6032,9 +6032,9 @@ __metadata:
linkType: hard
"core-js@npm:^3.30.2, core-js@npm:^3.41.0":
version: 3.43.0
resolution: "core-js@npm:3.43.0"
checksum: 10c0/9d4ad66296e60380777de51d019b5c3e6cce023b7999750a5094f9a4b0ea53bf3600beb4ef11c56548f2c8791d43d4056e270d1cf55ba87273011aa7d4597871
version: 3.44.0
resolution: "core-js@npm:3.44.0"
checksum: 10c0/759bf3dc5f75068e9425dddf895fd5531c38794a11ea1c2b65e5ef7c527fe3652d59e8c287e574a211af9bab3c057c5c3fa6f6a773f4e142af895106efad38a4
languageName: node
linkType: hard