Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/kb_development' into kbtopic-87-…
Browse files Browse the repository at this point in the history
…follower-subscribe
  • Loading branch information
kmycode committed Nov 7, 2023
2 parents 09426fd + 59f851d commit 2a3eaff
Show file tree
Hide file tree
Showing 70 changed files with 439 additions and 220 deletions.
17 changes: 11 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,11 @@ Rails/Exit:
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfilepath
RSpec/FilePath:
CustomTransform:
ActivityPub: activitypub # Ignore the snake_case due to the amount of files to rename
ActivityPub: activitypub
DeepL: deepl
FetchOEmbedService: fetch_oembed_service
JsonLdHelper: jsonld_helper
OEmbedController: oembed_controller
OStatus: ostatus
NodeInfoController: nodeinfo_controller # NodeInfo isn't snake_cased for any of the instances
Exclude:
- 'spec/config/initializers/rack_attack_spec.rb' # namespaces usually have separate folder
- 'spec/lib/sanitize_config_spec.rb' # namespaces usually have separate folder

# Reason:
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecnamedsubject
Expand All @@ -147,6 +142,16 @@ RSpec/NotToNot:
RSpec/Rails/HttpStatus:
EnforcedStyle: numeric

# Reason: Match overrides from Rspec/FilePath rule above
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecspecfilepathformat
RSpec/SpecFilePathFormat:
CustomTransform:
ActivityPub: activitypub
DeepL: deepl
FetchOEmbedService: fetch_oembed_service
OEmbedController: oembed_controller
OStatus: ostatus

# Reason:
# https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren
Style/ClassAndModuleChildren:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4
# This needs to be bookworm-slim because the Ruby image is built on bookworm-slim
ARG NODE_VERSION="20.8-bookworm-slim"
ARG NODE_VERSION="20.9-bookworm-slim"

FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.2-slim as ruby
FROM node:${NODE_VERSION} as build
Expand Down
17 changes: 8 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ GEM
devise (>= 4.0.0)
rpam2 (~> 4.0)
diff-lcs (1.5.0)
discard (1.2.1)
discard (1.3.0)
activerecord (>= 4.2, < 8)
docile (1.4.0)
domain_name (0.5.20190701)
Expand Down Expand Up @@ -264,7 +264,7 @@ GEM
tzinfo
excon (0.100.0)
fabrication (2.30.0)
faker (3.2.1)
faker (3.2.2)
i18n (>= 1.8.11, < 2)
faraday (1.10.3)
faraday-em_http (~> 1.0)
Expand Down Expand Up @@ -535,7 +535,7 @@ GEM
pundit (2.3.1)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.7.1)
racc (1.7.3)
rack (2.2.8)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
Expand Down Expand Up @@ -650,8 +650,7 @@ GEM
rspec-mocks (~> 3.0)
sidekiq (>= 5, < 8)
rspec-support (3.12.1)
rubocop (1.57.1)
base64 (~> 0.1.1)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -662,11 +661,11 @@ GEM
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.23.1)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
Expand All @@ -675,8 +674,8 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rspec (2.23.2)
rubocop (~> 1.33)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-prof (1.6.3)
Expand Down
24 changes: 13 additions & 11 deletions app/javascript/mastodon/reducers/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,42 @@ const normalizeAccounts = (
return state;
};

export const accountsReducer: Reducer<typeof initialState> = (
state = initialState,
action,
) => {
const currentUserId = me;

if (!currentUserId)
function getCurrentUser() {
if (!me)
throw new Error(
'No current user (me) defined when calling `accountsReducer`',
);

return me;
}

export const accountsReducer: Reducer<typeof initialState> = (
state = initialState,
action,
) => {
if (revealAccount.match(action))
return state.setIn([action.payload.id, 'hidden'], false);
else if (importAccounts.match(action))
return normalizeAccounts(state, action.payload.accounts);
else if (followAccountSuccess.match(action))
else if (followAccountSuccess.match(action)) {
return state
.update(
action.payload.relationship.id,
(account) => account?.update('followers_count', (n) => n + 1),
)
.update(
currentUserId,
getCurrentUser(),
(account) => account?.update('following_count', (n) => n + 1),
);
else if (unfollowAccountSuccess.match(action))
} else if (unfollowAccountSuccess.match(action))
return state
.update(
action.payload.relationship.id,
(account) =>
account?.update('followers_count', (n) => Math.max(0, n - 1)),
)
.update(
currentUserId,
getCurrentUser(),
(account) =>
account?.update('following_count', (n) => Math.max(0, n - 1)),
);
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1886,12 +1886,14 @@ a.account__display-name {
&.activate {
& > .icon {
animation: spring-rotate-in 1s linear;
transform-origin: 50% 55%;
}
}

&.deactivate {
& > .icon {
animation: spring-rotate-out 1s linear;
transform-origin: 50% 55%;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/lib/activitypub/parser/status_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def title
end

def created_at
@object['published']&.to_datetime
datetime = @object['published']&.to_datetime
datetime if datetime.present? && (0..9999).cover?(datetime.year)
rescue ArgumentError
nil
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/delivery_failure_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def warning_domains
key.delete_prefix(exhausted_deliveries_key_by(''))
end

domains - UnavailableDomain.all.pluck(:domain)
domains - UnavailableDomain.pluck(:domain)
end

def warning_domains_map(domains = nil)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/feed_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def clear_from_list(list, target_account)
# @param [Account] target_account
# @return [void]
def clear_from_lists(account, target_account)
List.where(account: account).each do |list|
List.where(account: account).find_each do |list|
clear_from_list(list, target_account)
end
end
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def process_items(items)

FeaturedTag.includes(:tag).references(:tag).where(account: @account).where.not(tag: { name: normalized_names }).delete_all

FeaturedTag.includes(:tag).references(:tag).where(account: @account, tag: { name: normalized_names }).each do |featured_tag|
FeaturedTag.includes(:tag).references(:tag).where(account: @account, tag: { name: normalized_names }).find_each do |featured_tag|
featured_tag.update(name: tags.delete(featured_tag.tag.name))
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/activitypub/synchronize_followers_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call(account, partial_collection_url)
private

def remove_unexpected_local_followers!
@account.followers.local.where.not(id: @expected_followers.map(&:id)).each do |unexpected_follower|
@account.followers.local.where.not(id: @expected_followers.map(&:id)).reorder(nil).find_each do |unexpected_follower|
UnfollowService.new.call(unexpected_follower, @account)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/appeal_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create_appeal!
end

def notify_staff!
User.those_who_can(:manage_appeals).includes(:account).each do |u|
User.those_who_can(:manage_appeals).includes(:account).find_each do |u|
AdminMailer.with(recipient: u.account).new_appeal(@appeal).deliver_later if u.allows_appeal_emails?
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/approve_appeal_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def undo_delete_statuses!

def undo_mark_statuses_as_sensitive!
representative_account = Account.representative
@strike.statuses.includes(:media_attachments).each do |status|
@strike.statuses.includes(:media_attachments).find_each do |status|
UpdateStatusService.new.call(status, representative_account.id, sensitive: false) if status.with_media?
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/services/process_hashtags_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ def update_featured_tags!
added_tags = @current_tags - @previous_tags

unless added_tags.empty?
@account.featured_tags.where(tag_id: added_tags.map(&:id)).each do |featured_tag|
@account.featured_tags.where(tag_id: added_tags.map(&:id)).find_each do |featured_tag|
featured_tag.increment(@status.created_at)
end
end

removed_tags = @previous_tags - @current_tags

unless removed_tags.empty?
@account.featured_tags.where(tag_id: removed_tags.map(&:id)).each do |featured_tag|
@account.featured_tags.where(tag_id: removed_tags.map(&:id)).find_each do |featured_tag|
featured_tag.decrement(@status.id)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/remove_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def decrement_references
end

def remove_from_hashtags
@account.featured_tags.where(tag_id: @status.tags.map(&:id)).each do |featured_tag|
@account.featured_tags.where(tag_id: @status.tags.map(&:id)).find_each do |featured_tag|
featured_tag.decrement(@status.id)
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/report_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create_report!
def notify_staff!
return if @report.unresolved_siblings?

User.those_who_can(:manage_reports).includes(:account).each do |u|
User.those_who_can(:manage_reports).includes(:account).find_each do |u|
LocalNotificationWorker.perform_async(u.account_id, @report.id, 'Report', 'admin.report')
AdminMailer.with(recipient: u.account).new_report(@report).deliver_later if u.allows_report_emails?
end
Expand Down
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ module.exports = (api) => {
case 'development':
reactOptions.development = true;
envOptions.debug = true;

// We need Babel to not inject polyfills in dev, as this breaks `preval` files
envOptions.useBuiltIns = false;
envOptions.corejs = undefined;
break;
}

Expand Down
1 change: 0 additions & 1 deletion config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
inflect.acronym 'PubSubHubbub'
inflect.acronym 'ActivityStreams'
inflect.acronym 'JsonLd'
inflect.acronym 'NodeInfo'
inflect.acronym 'Ed25519'
inflect.acronym 'TOC'
inflect.acronym 'RSS'
Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
end

get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
get '.well-known/nodeinfo', to: 'well_known/nodeinfo#index', as: :nodeinfo, defaults: { format: 'json' }
get '.well-known/nodeinfo', to: 'well_known/node_info#index', as: :nodeinfo, defaults: { format: 'json' }
get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
get '.well-known/change-password', to: redirect('/auth/edit')
get '.well-known/proxy', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }

get '/nodeinfo/2.0', to: 'well_known/nodeinfo#show', as: :nodeinfo_schema
get '/nodeinfo/2.0', to: 'well_known/node_info#show', as: :nodeinfo_schema

get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
get 'intent', to: 'intents#show'
Expand Down
8 changes: 5 additions & 3 deletions db/migrate/20160222143943_add_profile_fields_to_accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

class AddProfileFieldsToAccounts < ActiveRecord::Migration[4.2]
def change
add_column :accounts, :note, :text, null: false, default: ''
add_column :accounts, :display_name, :string, null: false, default: ''
add_column :accounts, :uri, :string, null: false, default: ''
change_table :accounts, bulk: true do |t|
t.column :note, :text, null: false, default: ''
t.column :display_name, :string, null: false, default: ''
t.column :uri, :string, null: false, default: ''
end
end
end
6 changes: 4 additions & 2 deletions db/migrate/20160223162837_add_metadata_to_statuses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

class AddMetadataToStatuses < ActiveRecord::Migration[4.2]
def change
add_column :statuses, :in_reply_to_id, :integer, null: true
add_column :statuses, :reblog_of_id, :integer, null: true
change_table(:statuses, bulk: true) do |t|
t.column :in_reply_to_id, :integer, null: true
t.column :reblog_of_id, :integer, null: true
end
end
end
2 changes: 1 addition & 1 deletion db/migrate/20160305115639_add_devise_to_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class AddDeviseToUsers < ActiveRecord::Migration[4.2]
def self.up
change_table(:users) do |t|
change_table(:users, bulk: true) do |t|
## Database authenticatable
t.string :encrypted_password, null: false, default: ''

Expand Down
6 changes: 4 additions & 2 deletions db/migrate/20160314164231_add_owner_to_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

class AddOwnerToApplication < ActiveRecord::Migration[4.2]
def change
add_column :oauth_applications, :owner_id, :integer, null: true
add_column :oauth_applications, :owner_type, :string, null: true
change_table(:oauth_applications, bulk: true) do |t|
t.column :owner_id, :integer, null: true
t.column :owner_type, :string, null: true
end
add_index :oauth_applications, [:owner_id, :owner_type]
end
end
8 changes: 5 additions & 3 deletions db/migrate/20160926213048_remove_owner_from_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

class RemoveOwnerFromApplication < ActiveRecord::Migration[5.0]
def change
remove_index :oauth_applications, [:owner_id, :owner_type]
remove_column :oauth_applications, :owner_id, :integer, null: true
remove_column :oauth_applications, :owner_type, :string, null: true
change_table(:oauth_applications, bulk: true) do |t|
t.remove_index [:owner_id, :owner_type]
t.remove :owner_id, type: :integer, options: { null: true }
t.remove :owner_type, type: :string, options: { null: true }
end
end
end
10 changes: 6 additions & 4 deletions db/migrate/20161003142332_add_confirmable_to_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

class AddConfirmableToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string
change_table(:users, bulk: true) do |t|
t.column :confirmation_token, :string
t.column :confirmed_at, :datetime
t.column :confirmation_sent_at, :datetime
t.column :unconfirmed_email, :string
end
add_index :users, :confirmation_token, unique: true
end
end
Loading

0 comments on commit 2a3eaff

Please sign in to comment.