diff --git a/app/controllers/api/v1/groups/accounts_controller.rb b/app/controllers/api/v1/groups/accounts_controller.rb index e09b21e2..e36d891a 100644 --- a/app/controllers/api/v1/groups/accounts_controller.rb +++ b/app/controllers/api/v1/groups/accounts_controller.rb @@ -20,6 +20,11 @@ class Api::V1::Groups::AccountsController < Api::BaseController authorize @group, :join? @group.accounts << current_account + + if current_user.allows_group_in_home_feed? + current_user.force_regeneration! + end + render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships end @@ -34,6 +39,11 @@ class Api::V1::Groups::AccountsController < Api::BaseController authorize @group, :leave? GroupAccount.where(group: @group, account_id: current_account.id).destroy_all + + if current_user.allows_group_in_home_feed? + current_user.force_regeneration! + end + render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships end diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 36d86a81..8b7dbac8 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -9,6 +9,7 @@ class Settings::PreferencesController < Settings::BaseController def update user_settings.update(user_settings_params.to_h) + current_user.force_regeneration! if current_user.update(user_params) I18n.locale = current_user.locale diff --git a/app/models/status.rb b/app/models/status.rb index 940f82a7..6ca0c40d 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -283,7 +283,13 @@ class Status < ApplicationRecord end def as_home_timeline(account) - where(account: [account] + account.following).or(where(group: account.groups)).where(visibility: [:public, :unlisted, :private]) + query = where(account: [account] + account.following) + + if account.user.allows_group_in_home_feed? + query = query.or(where(group: account.groups)) + end + + query.where(visibility: [:public, :unlisted, :private]) end def as_group_timeline(group) diff --git a/app/models/user.rb b/app/models/user.rb index d35372f5..67841fcd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -213,6 +213,10 @@ class User < ApplicationRecord @shows_application ||= settings.show_application end + def allows_group_in_home_feed? + settings.group_in_home_feed + end + def token_for_app(a) return nil if a.nil? || a.owner != self Doorkeeper::AccessToken @@ -270,6 +274,10 @@ class User < ApplicationRecord setting_display_media == 'hide_all' end + def force_regeneration! + Redis.current.set("account:#{account_id}:regeneration", true) + end + protected def send_devise_notification(notification, *args)