]> cat aescling's git repositories - mastodon.git/commitdiff
Merge branch 'main' into glitch-soc/merge-upstream
authorClaire <claire.github-309c@sitedethib.com>
Tue, 8 Mar 2022 19:22:54 +0000 (20:22 +0100)
committerClaire <claire.github-309c@sitedethib.com>
Tue, 8 Mar 2022 19:22:54 +0000 (20:22 +0100)
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`.

20 files changed:
1  2 
.env.production.sample
app/controllers/follower_accounts_controller.rb
app/controllers/following_accounts_controller.rb
app/controllers/settings/preferences_controller.rb
app/javascript/mastodon/locales/en.json
app/javascript/styles/mastodon/admin.scss
app/javascript/styles/mastodon/components.scss
app/lib/user_settings_decorator.rb
app/models/account.rb
app/models/account_statuses_filter.rb
app/models/status.rb
app/models/user.rb
app/views/directories/index.html.haml
app/views/settings/preferences/other/show.html.haml
app/views/settings/profiles/show.html.haml
config/routes.rb
config/settings.yml
db/schema.rb
spec/controllers/application_controller_spec.rb
spec/models/status_spec.rb

index 7de5e00f40e006aaf392c954b8e4e777395bc907,4fc58072f1d455d4f57157af33c1918097d4e7c9..0df0a8778682d925e3188952103ae61351d24bc7
@@@ -107,185 -58,12 +107,185 @@@ SMTP_SERVER=smtp.mailgun.or
  SMTP_PORT=587
  SMTP_LOGIN=
  SMTP_PASSWORD=
- SMTP_FROM_ADDRESS=notificatons@example.com
+ SMTP_FROM_ADDRESS=notifications@example.com
  
 +
  # File storage (optional)
  # -----------------------
 -S3_ENABLED=true
 -S3_BUCKET=files.example.com
 -AWS_ACCESS_KEY_ID=
 -AWS_SECRET_ACCESS_KEY=
 -S3_ALIAS_HOST=files.example.com
 +# The attachment host must allow cross origin request from WEB_DOMAIN or
 +# LOCAL_DOMAIN if WEB_DOMAIN is not set. For example, the server may have the
 +# following header field:
 +# Access-Control-Allow-Origin: https://192.168.1.123:9000/
 +# -----------------------
 +#S3_ENABLED=true
 +#S3_BUCKET=files.example.com
 +#AWS_ACCESS_KEY_ID=
 +#AWS_SECRET_ACCESS_KEY=
 +#S3_ALIAS_HOST=files.example.com
 +
 +# Swift (optional)
 +# The attachment host must allow cross origin request - see the description
 +# above.
 +# SWIFT_ENABLED=true
 +# SWIFT_USERNAME=
 +# For Keystone V3, the value for SWIFT_TENANT should be the project name
 +# SWIFT_TENANT=
 +# SWIFT_PASSWORD=
 +# Some OpenStack V3 providers require PROJECT_ID (optional)
 +# SWIFT_PROJECT_ID=
 +# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
 +# issues with token rate-limiting during high load.
 +# SWIFT_AUTH_URL=
 +# SWIFT_CONTAINER=
 +# SWIFT_OBJECT_URL=
 +# SWIFT_REGION=
 +# Defaults to 'default'
 +# SWIFT_DOMAIN_NAME=
 +# Defaults to 60 seconds. Set to 0 to disable
 +# SWIFT_CACHE_TTL=
 +
 +# Optional asset host for multi-server setups
 +# The asset host must allow cross origin request from WEB_DOMAIN or LOCAL_DOMAIN
 +# if WEB_DOMAIN is not set. For example, the server may have the
 +# following header field:
 +# Access-Control-Allow-Origin: https://example.com/
 +# CDN_HOST=https://assets.example.com
 +
 +# Optional list of hosts that are allowed to serve media for your instance
 +# This is useful if you include external media in your custom CSS or about page,
 +# or if your data storage provider makes use of redirects to other domains.
 +# EXTRA_DATA_HOSTS=https://data.example1.com|https://data.example2.com
 +
 +# Optional alias for S3 (e.g. to serve files on a custom domain, possibly using Cloudfront or Cloudflare)
 +# S3_ALIAS_HOST=
 +
 +# Streaming API integration
 +# STREAMING_API_BASE_URL=
 +
 +
 +# External authentication (optional)
 +# ----------------------------------
 +# LDAP authentication (optional)
 +# LDAP_ENABLED=true
 +# LDAP_HOST=localhost
 +# LDAP_PORT=389
 +# LDAP_METHOD=simple_tls
 +# LDAP_BASE=
 +# LDAP_BIND_DN=
 +# LDAP_PASSWORD=
 +# LDAP_UID=cn
 +# LDAP_MAIL=mail
 +# LDAP_SEARCH_FILTER=(|(%{uid}=%{email})(%{mail}=%{email}))
 +# LDAP_UID_CONVERSION_ENABLED=true
 +# LDAP_UID_CONVERSION_SEARCH=., -
 +# LDAP_UID_CONVERSION_REPLACE=_
 +
 +# PAM authentication (optional)
 +# PAM authentication uses for the email generation the "email" pam variable
 +# and optional as fallback PAM_DEFAULT_SUFFIX
 +# The pam environment variable "email" is provided by:
 +# https://github.com/devkral/pam_email_extractor
 +# PAM_ENABLED=true
 +# Fallback email domain for email address generation (LOCAL_DOMAIN by default)
 +# PAM_EMAIL_DOMAIN=example.com
 +# Name of the pam service (pam "auth" section is evaluated)
 +# PAM_DEFAULT_SERVICE=rpam
 +# Name of the pam service used for checking if an user can register (pam "account" section is evaluated) (nil (disabled) by default)
 +# PAM_CONTROLLED_SERVICE=rpam
 +
 +# Global OAuth settings (optional) :
 +# If you have only one strategy, you may want to enable this
 +# OAUTH_REDIRECT_AT_SIGN_IN=true
 +
 +# Optional CAS authentication (cf. omniauth-cas) :
 +# CAS_ENABLED=true
 +# CAS_URL=https://sso.myserver.com/
 +# CAS_HOST=sso.myserver.com/
 +# CAS_PORT=443
 +# CAS_SSL=true
 +# CAS_VALIDATE_URL=
 +# CAS_CALLBACK_URL=
 +# CAS_LOGOUT_URL=
 +# CAS_LOGIN_URL=
 +# CAS_UID_FIELD='user'
 +# CAS_CA_PATH=
 +# CAS_DISABLE_SSL_VERIFICATION=false
 +# CAS_UID_KEY='user'
 +# CAS_NAME_KEY='name'
 +# CAS_EMAIL_KEY='email'
 +# CAS_NICKNAME_KEY='nickname'
 +# CAS_FIRST_NAME_KEY='firstname'
 +# CAS_LAST_NAME_KEY='lastname'
 +# CAS_LOCATION_KEY='location'
 +# CAS_IMAGE_KEY='image'
 +# CAS_PHONE_KEY='phone'
 +
 +# Optional SAML authentication (cf. omniauth-saml)
 +# SAML_ENABLED=true
 +# SAML_ACS_URL=http://localhost:3000/auth/auth/saml/callback
 +# SAML_ISSUER=https://example.com
 +# SAML_IDP_SSO_TARGET_URL=https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO
 +# SAML_IDP_CERT=
 +# SAML_IDP_CERT_FINGERPRINT=
 +# SAML_NAME_IDENTIFIER_FORMAT=
 +# SAML_CERT=
 +# SAML_PRIVATE_KEY=
 +# SAML_SECURITY_WANT_ASSERTION_SIGNED=true
 +# SAML_SECURITY_WANT_ASSERTION_ENCRYPTED=true
 +# SAML_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true
 +# SAML_ATTRIBUTES_STATEMENTS_UID="urn:oid:0.9.2342.19200300.100.1.1"
 +# SAML_ATTRIBUTES_STATEMENTS_EMAIL="urn:oid:1.3.6.1.4.1.5923.1.1.1.6"
 +# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241"
 +# SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42"
 +# SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4"
 +# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1"
 +# SAML_ATTRIBUTES_STATEMENTS_VERIFIED=
 +# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL=
 +
 +
 +# Custom settings
 +# ---------------
 +# Various ways to customize Mastodon's behavior
 +# ---------------
 + 
 +# Maximum allowed character count
 +MAX_TOOT_CHARS=500
 +
 +# Maximum number of pinned posts
 +MAX_PINNED_TOOTS=5
 +
 +# Maximum allowed bio characters
 +MAX_BIO_CHARS=500
 +
 +# Maximim number of profile fields allowed
 +MAX_PROFILE_FIELDS=4
 +
 +# Maximum allowed display name characters
 +MAX_DISPLAY_NAME_CHARS=30
 +
 +# Maximum allowed poll options
 +MAX_POLL_OPTIONS=5
 +
 +# Maximum allowed poll option characters
 +MAX_POLL_OPTION_CHARS=100
 +
 +# Maximum image and video/audio upload sizes
 +# Units are in bytes
 +# 1048576 bytes equals 1 megabyte
 +# MAX_IMAGE_SIZE=8388608
 +# MAX_VIDEO_SIZE=41943040
 +
 +# Maximum search results to display
 +# Only relevant when elasticsearch is installed
 +# MAX_SEARCH_RESULTS=20
 +
 +# Maximum custom emoji file sizes
 +# If undefined or smaller than MAX_EMOJI_SIZE, the value
 +# of MAX_EMOJI_SIZE will be used for MAX_REMOTE_EMOJI_SIZE
 +# Units are in bytes
 +MAX_EMOJI_SIZE=51200
 +MAX_REMOTE_EMOJI_SIZE=204800
 +
 +# Optional hCaptcha support
 +# HCAPTCHA_SECRET_KEY=
 +# HCAPTCHA_SITE_KEY=
index d519138cddf0c13cac6a53800f2618a66f53d237,f3f8336c95fc7d6e571a7ce3efa8492656a7c622..f898994ac948f9e1b7cb8ccda857893656b9bfdf
@@@ -13,10 -13,9 +13,10 @@@ class FollowerAccountsController < Appl
    def index
      respond_to do |format|
        format.html do
 +        use_pack 'public'
          expires_in 0, public: true unless user_signed_in?
  
-         next if @account.user_hides_network?
+         next if @account.hide_collections?
  
          follows
        end
index 4b4978fb9acccafe4638577adfbfe86b5417bf30,9d7f4c9bf32c731ab6b889f8d6a8ee7d69d127b2..bc291c9625c802814603a9b6ec84acb903fd57b9
@@@ -13,10 -13,9 +13,10 @@@ class FollowingAccountsController < App
    def index
      respond_to do |format|
        format.html do
 +        use_pack 'public'
          expires_in 0, public: true unless user_signed_in?
  
-         next if @account.user_hides_network?
+         next if @account.hide_collections?
  
          follows
        end
index dfe2ae2e501129bd5edaf9b450c2b29b79dc8288,c7492700cd6b7ba6a45e69954debbe8627d74a63..1fddd087b23151ac587742472a30623895177164
@@@ -46,10 -45,8 +46,9 @@@ class Settings::PreferencesController 
        :setting_reduce_motion,
        :setting_disable_swiping,
        :setting_system_font_ui,
 +      :setting_system_emoji_font,
        :setting_noindex,
-       :setting_hide_network,
 -      :setting_theme,
 +      :setting_hide_followers_count,
        :setting_aggregate_reblogs,
        :setting_show_application,
        :setting_advanced_layout,
index 581101782f70b69b4065ef4d7aa8f5ffadd82b0e,de054e403eeaa72d38e470913e15f253c950f03a..d8015e50dcd0c3f888ea6330ef47d122e8610691
@@@ -30,12 -29,8 +30,11 @@@ class UserSettingsDecorato
      user.settings['reduce_motion']       = reduce_motion_preference if change?('setting_reduce_motion')
      user.settings['disable_swiping']     = disable_swiping_preference if change?('setting_disable_swiping')
      user.settings['system_font_ui']      = system_font_ui_preference if change?('setting_system_font_ui')
 +    user.settings['system_emoji_font']   = system_emoji_font_preference if change?('setting_system_emoji_font')
      user.settings['noindex']             = noindex_preference if change?('setting_noindex')
-     user.settings['hide_followers_count']= hide_followers_count_preference if change?('setting_hide_followers_count')
 -    user.settings['theme']               = theme_preference if change?('setting_theme')
 +    user.settings['flavour']             = flavour_preference if change?('setting_flavour')
 +    user.settings['skin']                = skin_preference if change?('setting_skin')
 +    user.settings['hide_network']        = hide_network_preference if change?('setting_hide_network')
      user.settings['aggregate_reblogs']   = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
      user.settings['show_application']    = show_application_preference if change?('setting_show_application')
      user.settings['advanced_layout']     = advanced_layout_preference if change?('setting_advanced_layout')
      boolean_cast_setting 'setting_noindex'
    end
  
-   def hide_followers_count_preference
-     boolean_cast_setting 'setting_hide_followers_count'
-   end
 -  def show_application_preference
 -    boolean_cast_setting 'setting_show_application'
 +  def flavour_preference
 +    settings['setting_flavour']
 +  end
 +
 +  def skin_preference
 +    settings['setting_skin']
    end
  
 -  def theme_preference
 -    settings['setting_theme']
 +  def hide_network_preference
 +    boolean_cast_setting 'setting_hide_network'
 +  end
 +
 +  def show_application_preference
 +    boolean_cast_setting 'setting_show_application'
    end
  
    def default_language_preference
Simple merge
index 0000000000000000000000000000000000000000,211f414787fe22d5c57917285916b3b7d2c330a6..556aee032e4f1888e61d3c8656442771ed89b893
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,134 +1,134 @@@
 -      account.statuses.where(visibility: %i(public unlisted))
+ # frozen_string_literal: true
+ class AccountStatusesFilter
+   KEYS = %i(
+     pinned
+     tagged
+     only_media
+     exclude_replies
+     exclude_reblogs
+   ).freeze
+   attr_reader :params, :account, :current_account
+   def initialize(account, current_account, params = {})
+     @account         = account
+     @current_account = current_account
+     @params          = params
+   end
+   def results
+     scope = initial_scope
+     scope.merge!(pinned_scope)     if pinned?
+     scope.merge!(only_media_scope) if only_media?
+     scope.merge!(no_replies_scope) if exclude_replies?
+     scope.merge!(no_reblogs_scope) if exclude_reblogs?
+     scope.merge!(hashtag_scope)    if tagged?
+     scope
+   end
+   private
+   def initial_scope
+     if suspended?
+       Status.none
+     elsif anonymous?
++      account.statuses.not_local_only.where(visibility: %i(public unlisted))
+     elsif author?
+       account.statuses.all # NOTE: #merge! does not work without the #all
+     elsif blocked?
+       Status.none
+     else
+       filtered_scope
+     end
+   end
+   def filtered_scope
+     scope = account.statuses.left_outer_joins(:mentions)
+     scope.merge!(scope.where(visibility: follower? ? %i(public unlisted private) : %i(public unlisted)).or(scope.where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id]))
+     scope.merge!(filtered_reblogs_scope) if reblogs_may_occur?
+     scope
+   end
+   def filtered_reblogs_scope
+     Status.left_outer_joins(:reblog).where(reblog_of_id: nil).or(Status.where.not(reblogs_statuses: { account_id: current_account.excluded_from_timeline_account_ids }))
+   end
+   def only_media_scope
+     Status.joins(:media_attachments).merge(account.media_attachments.reorder(nil)).group(Status.arel_table[:id])
+   end
+   def no_replies_scope
+     Status.without_replies
+   end
+   def no_reblogs_scope
+     Status.without_reblogs
+   end
+   def pinned_scope
+     account.pinned_statuses.group(Status.arel_table[:id], StatusPin.arel_table[:created_at])
+   end
+   def hashtag_scope
+     tag = Tag.find_normalized(params[:tagged])
+     if tag
+       Status.tagged_with(tag.id)
+     else
+       Status.none
+     end
+   end
+   def suspended?
+     account.suspended?
+   end
+   def anonymous?
+     current_account.nil?
+   end
+   def author?
+     current_account.id == account.id
+   end
+   def blocked?
+     account.blocking?(current_account) || (current_account.domain.present? && account.domain_blocking?(current_account.domain))
+   end
+   def follower?
+     current_account.following?(account)
+   end
+   def reblogs_may_occur?
+     !exclude_reblogs? && !only_media? && !tagged?
+   end
+   def pinned?
+     truthy_param?(:pinned)
+   end
+   def only_media?
+     truthy_param?(:only_media)
+   end
+   def exclude_replies?
+     truthy_param?(:exclude_replies)
+   end
+   def exclude_reblogs?
+     truthy_param?(:exclude_reblogs)
+   end
+   def tagged?
+     params[:tagged].present?
+   end
+   def truthy_param?(key)
+     ActiveModel::Type::Boolean.new.cast(params[key])
+   end
+ end
Simple merge
index 77685ad027bfdebba9a49c6c23d49a23142e0b75,146bdcd2a9498f967b4af9b5019838a6ee975caa..f657f1b278a772753739eb162da0807ecf6399eb
@@@ -125,11 -125,11 +125,11 @@@ class User < ApplicationRecor
  
    has_many :session_activations, dependent: :destroy
  
 -  delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
 -           :reduce_motion, :system_font_ui, :noindex, :theme, :display_media,
 +  delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
-            :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
++           :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_followers_count,
             :expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
             :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
 -           :disable_swiping,
 +           :disable_swiping, :default_content_type, :system_emoji_font,
             to: :settings, prefix: :setting, allow_nil: false
  
    attr_reader :invite_code, :sign_in_token_attempt
      settings.notification_emails['trending_tag']
    end
  
-   def hides_network?
-     @hides_network ||= settings.hide_network
-   end
 +  def allows_trending_links_review_emails?
 +    settings.notification_emails['trending_link']
 +  end
 +
 +  def allows_trending_statuses_review_emails?
 +    settings.notification_emails['trending_status']
 +  end
 +
    def aggregates_reblogs?
      @aggregates_reblogs ||= settings.aggregate_reblogs
    end
index d5509f9464e93afda192f559c87af2acc021ca93,2b338115bdd79b322bd3f7d387b8b8550b1638c8..2ac700fe68045ea91081d5e1d31540eea8046a2f
              .display-name
                %bdi
                  %strong.emojify.p-name= display_name(account, custom_emojify: true)
-               %span= acct(account)
-           .directory__card__bar__relationship.account__relationship
-             = minimal_account_action_button(account)
-         .directory__card__extra
-           .account__header__content.emojify= Formatter.instance.simplified_format(account, custom_emojify: true)
-         .directory__card__extra
-           .accounts-table__count
-             = friendly_number_to_human account.statuses_count
-             %small= t('accounts.posts', count: account.statuses_count).downcase
-           .accounts-table__count
-             = hide_followers_count?(account) ? '-' : (friendly_number_to_human account.followers_count)
-             %small= t('accounts.followers', count: account.followers_count).downcase
-           .accounts-table__count
-             - if account.last_status_at.present?
-               %time.time-ago{ datetime: account.last_status_at.to_date.iso8601, title: l(account.last_status_at.to_date) }= l account.last_status_at.to_date
-             - else
-               = t('accounts.never_active')
-             %small= t('accounts.last_active')
+               %span
+                 = acct(account)
+                 = fa_icon('lock') if account.locked?
+         - if account.note.present?
+           .account-card__bio.emojify
+             = Formatter.instance.simplified_format(account, custom_emojify: true)
+         - else
+           .flex-spacer
+         .account-card__actions
+           .account-card__counters
+             .account-card__counters__item
+               = friendly_number_to_human account.statuses_count
+               %small= t('accounts.posts', count: account.statuses_count).downcase
+             .account-card__counters__item
 -              = friendly_number_to_human account.followers_count
++              = hide_followers_count?(account) ? '-' : (friendly_number_to_human account.followers_count)
+               %small= t('accounts.followers', count: account.followers_count).downcase
+             .account-card__counters__item
+               = friendly_number_to_human account.following_count
+               %small= t('accounts.following', count: account.following_count).downcase
+           .account-card__actions__button
+             = account_action_button(account)
  
    = paginate @accounts
Simple merge
index 1f366d7d11843e4d0a681b1c2023289d5da84fcf,06dd2b3f3e3a7172356220f6aa0023b442841059..51016d322065f9c1b21c08f63b987f346b33c57a
@@@ -13,14 -13,12 +13,13 @@@ defaults: &default
    profile_directory: true
    closed_registrations_message: ''
    open_deletion: true
 +  timeline_preview: false
    min_invite_role: 'admin'
 -  timeline_preview: true
    show_staff_badge: true
    default_sensitive: false
-   hide_network: false
    unfollow_modal: false
    boost_modal: false
 +  favourite_modal: false
    delete_modal: true
    auto_play_gif: false
    display_media: 'default'
diff --cc db/schema.rb
Simple merge
Simple merge