diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-03-08 20:22:54 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-03-08 20:22:54 +0100 |
commit | 1fbd1fa5c4ad5fcfef8af0c76f04e06f39aadd33 (patch) | |
tree | 1647c091e5d45d1d8dc20e6b25b3a588c2f8aa1b /db/migrate | |
parent | f03148f441d8dfc1856451c4faa00b5e26b6e199 (diff) | |
parent | 8f6c67bfdeddd1c2c1085067e3dc549fb53f6ff4 (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/controllers/settings/preferences_controller.rb`: Conflicts due to us having more user settings and upstream dropping `hide_network` (to replace it with an account attribute, properly migrated). Dropped `hide_network` like upstream. - `app/lib/user_settings_decorator.rb`: Conflicts due to us having more user settings and upstream dropping `hide_network` (to replace it with an account attribute, properly migrated). Dropped `hide_network` like upstream. - `app/models/status.rb`: Conflict because of slight change in how glitch-soc handles the scope to filter out local-only posts for anonymous viewers. Took upstream's changes and re-applied glitch-soc's change. - `app/models/user.rb`: Conflicts due to us having more user settings and upstream dropping `hide_network` (to replace it with an account attribute, properly migrated). Dropped `hide_network` like upstream. - `app/views/directories/index.html.haml`: Conflict because upstream redesigned that page while glitch-soc had a minor change to support hiding the number of followers. Ported glitch-soc's change on top of upstream's redesign. Additional changes: - `app/models/account_statuses_filter.rb`: See change to `app/models/status.rb`.
Diffstat (limited to 'db/migrate')
3 files changed, 41 insertions, 4 deletions
diff --git a/db/migrate/20170920032311_fix_reblogs_in_feeds.rb b/db/migrate/20170920032311_fix_reblogs_in_feeds.rb index bcd4b9137..4ab68e8f3 100644 --- a/db/migrate/20170920032311_fix_reblogs_in_feeds.rb +++ b/db/migrate/20170920032311_fix_reblogs_in_feeds.rb @@ -16,7 +16,7 @@ class FixReblogsInFeeds < ActiveRecord::Migration[5.1] # is once again set to the reblogging status' ID, and the value # is set to the reblogged status' ID). This is safe for Redis' # float conversion because in this reblog tracking zset, we only - # need the rebloggging status' ID to be able to stop tracking + # need the reblogging status' ID to be able to stop tracking # entries after they have gotten too far down the feed, which # does not require an exact value. diff --git a/db/migrate/20180608213548_reject_following_blocked_users.rb b/db/migrate/20180608213548_reject_following_blocked_users.rb index 302db6b68..78f8df538 100644 --- a/db/migrate/20180608213548_reject_following_blocked_users.rb +++ b/db/migrate/20180608213548_reject_following_blocked_users.rb @@ -22,13 +22,13 @@ class RejectFollowingBlockedUsers < ActiveRecord::Migration[5.2] follows.each do |follow| blocked_account = follow.account - followed_acccount = follow.target_account + followed_account = follow.target_account next follow.destroy! if blocked_account.local? - reject_follow_json = Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new(follow, serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).as_json).sign!(followed_acccount)) + reject_follow_json = Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new(follow, serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).as_json).sign!(followed_account)) - ActivityPub::DeliveryWorker.perform_async(reject_follow_json, followed_acccount, blocked_account.inbox_url) + ActivityPub::DeliveryWorker.perform_async(reject_follow_json, followed_account, blocked_account.inbox_url) follow.destroy! end diff --git a/db/migrate/20220304195405_migrate_hide_network_preference.rb b/db/migrate/20220304195405_migrate_hide_network_preference.rb new file mode 100644 index 000000000..102ee46d6 --- /dev/null +++ b/db/migrate/20220304195405_migrate_hide_network_preference.rb @@ -0,0 +1,37 @@ +class MigrateHideNetworkPreference < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + # Dummy classes, to make migration possible across version changes + class Account < ApplicationRecord + has_one :user, inverse_of: :account + scope :local, -> { where(domain: nil) } + end + + class User < ApplicationRecord + belongs_to :account + end + + def up + Account.reset_column_information + + Setting.unscoped.where(thing_type: 'User', var: 'hide_network').find_each do |setting| + account = User.find(setting.thing_id).account + + ApplicationRecord.transaction do + account.update(hide_collections: setting.value) + setting.delete + end + rescue ActiveRecord::RecordNotFound + next + end + end + + def down + Account.local.where(hide_collections: true).includes(:user).find_each do |account| + ApplicationRecord.transaction do + Setting.create(thing_type: 'User', thing_id: account.user.id, var: 'hide_network', value: account.hide_collections?) + account.update(hide_collections: nil) + end + end + end +end |