Skip to content

Commit

Permalink
Merge commit '3a2a15c6ea4d4603469861ed9be09da12a122e45' into glitch-s…
Browse files Browse the repository at this point in the history
…oc/merge-upstream

Conflicts:
- `app/views/settings/preferences/appearance/show.html.haml`:
  Conflict because glitch-soc does not have a theme selector here.
  • Loading branch information
ClearlyClaire committed Jun 10, 2023
2 parents 34efd1a + 3a2a15c commit 42a0898
Show file tree
Hide file tree
Showing 66 changed files with 99 additions and 78 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def relationships(**options)
end

def account_params
params.permit(:username, :email, :password, :agreement, :locale, :reason)
params.permit(:username, :email, :password, :agreement, :locale, :reason, :time_zone)
end

def check_enabled_registrations
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/settings/preferences/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ def after_update_redirect_path
end

def user_params
params.require(:user).permit(:locale, chosen_languages: [], settings_attributes: UserSettings.keys)
params.require(:user).permit(:locale, :time_zone, chosen_languages: [], settings_attributes: UserSettings.keys)
end
end
1 change: 1 addition & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Account < ApplicationRecord
:locale,
:shows_application?,
:prefers_noindex?,
:time_zone,
to: :user,
prefix: true,
allow_nil: true
Expand Down
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
# sign_up_ip :inet
# role_id :bigint(8)
# settings :text
# time_zone :string
#

class User < ApplicationRecord
Expand Down Expand Up @@ -99,6 +100,7 @@ class User < ApplicationRecord
validates_with BlacklistedEmailValidator, if: -> { ENV['EMAIL_DOMAIN_LISTS_APPLY_AFTER_CONFIRMATION'] == 'true' || !confirmed? }
validates_with EmailMxValidator, if: :validate_email_dns?
validates :agreement, acceptance: { allow_nil: false, accept: [true, 'true', '1'] }, on: :create
validates :time_zone, inclusion: { in: ActiveSupport::TimeZone.all.map { |tz| tz.tzinfo.name } }, allow_blank: true

# Honeypot/anti-spam fields
attr_accessor :registration_form_time, :website, :confirm_password
Expand Down
2 changes: 1 addition & 1 deletion app/services/app_sign_up_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_access_token!
end

def user_params
@params.slice(:email, :password, :agreement, :locale)
@params.slice(:email, :password, :agreement, :locale, :time_zone)
end

def account_params
Expand Down
2 changes: 1 addition & 1 deletion app/views/notification_mailer/_status.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
= link_to a.remote_url, a.remote_url

%p.status-footer
= link_to l(status.created_at), web_url("@#{status.account.pretty_acct}/#{status.id}")
= link_to l(status.created_at.in_time_zone(time_zone)), web_url("@#{status.account.pretty_acct}/#{status.id}")
2 changes: 1 addition & 1 deletion app/views/notification_mailer/favourite.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%h1= t 'notification_mailer.favourite.title'
%p.lead= t('notification_mailer.favourite.body', name: @account.pretty_acct)

= render 'status', status: @status
= render 'status', status: @status, time_zone: @me.user_time_zone

%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
Expand Down
2 changes: 1 addition & 1 deletion app/views/notification_mailer/mention.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%h1= t 'notification_mailer.mention.title'
%p.lead= t('notification_mailer.mention.body', name: @status.account.pretty_acct)

= render 'status', status: @status
= render 'status', status: @status, time_zone: @me.user_time_zone

%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
Expand Down
2 changes: 1 addition & 1 deletion app/views/notification_mailer/reblog.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%h1= t 'notification_mailer.reblog.title'
%p.lead= t('notification_mailer.reblog.body', name: @account.pretty_acct)

= render 'status', status: @status
= render 'status', status: @status, time_zone: @me.user_time_zone

%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
Expand Down
5 changes: 4 additions & 1 deletion app/views/settings/preferences/appearance/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

= simple_form_for current_user, url: settings_preferences_appearance_path, html: { method: :put, id: 'edit_user' } do |f|
.fields-row
.fields-group
.fields-group.fields-row__column.fields-row__column-6
= f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| native_locale_name(locale) }, selected: I18n.locale, hint: false

.fields-group.fields-row__column.fields-row__column-6
= f.input :time_zone, wrapper: :with_label, collection: ActiveSupport::TimeZone.all.map { |tz| ["(GMT#{tz.formatted_offset}) #{tz.name}", tz.tzinfo.name] }, hint: false

- unless I18n.locale == :en
.flash-message.translation-prompt
#{t 'appearance.localization.body'} #{content_tag(:a, t('appearance.localization.guide_link_text'), href: t('appearance.localization.guide_link'), target: '_blank', rel: 'noopener')}
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/appeal_approved.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
%tbody
%tr
%td.column-cell.text-center
%p= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at)
%p= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone))

%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/appeal_approved.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

===

<%= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at) %>
<%= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %>

=> <%= root_url %>
2 changes: 1 addition & 1 deletion app/views/user_mailer/appeal_rejected.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
%tbody
%tr
%td.column-cell.text-center
%p= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at)
%p= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone))

%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/appeal_rejected.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

===

<%= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at) %>
<%= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %>

=> <%= root_url %>
2 changes: 1 addition & 1 deletion app/views/user_mailer/suspicious_sign_in.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
%strong= "#{t('sessions.browser')}:"
%span{ title: @user_agent }= t 'sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: @detection.id.to_s), platform: t("sessions.platforms.#{@detection.platform.id}", default: @detection.platform.id.to_s)
%br/
= l(@timestamp)
= l(@timestamp.in_time_zone(@resource.time_zone))

%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/suspicious_sign_in.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<%= t('sessions.ip') %>: <%= @remote_ip %>
<%= t('sessions.browser') %>: <%= t('sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: "#{@detection.id}"), platform: t("sessions.platforms.#{@detection.platform.id}", default: "#{@detection.platform.id}")) %>
<%= l(@timestamp) %>
<%= l(@timestamp.in_time_zone(@resource.time_zone)) %>

<%= t 'user_mailer.suspicious_sign_in.further_actions_html', action: t('user_mailer.suspicious_sign_in.change_password') %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/warning.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

- unless @statuses.empty?
- @statuses.each_with_index do |status, i|
= render 'notification_mailer/status', status: status, i: i + 1, highlighted: true
= render 'notification_mailer/status', status: status, i: i + 1, highlighted: true, time_zone: @resource.time_zone

%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ en:
usable: Allow posts to use this hashtag
user:
role: Role
time_zone: Time zone
user_role:
color: Badge color
highlighted: Display role as badge on user profiles
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20230605085711_add_time_zone_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddTimeZoneToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :time_zone, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_06_05_085710) do
ActiveRecord::Schema.define(version: 2023_06_05_085711) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -1091,6 +1091,7 @@
t.boolean "skip_sign_in_token"
t.bigint "role_id"
t.text "settings"
t.string "time_zone"
t.index ["account_id"], name: "index_users_on_account_id"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id", where: "(created_by_application_id IS NOT NULL)"
Expand Down
2 changes: 1 addition & 1 deletion spec/fabricators/account_domain_block_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:account_domain_block) do
account
account { Fabricate.build(:account) }
domain 'example.com'
end
4 changes: 2 additions & 2 deletions spec/fabricators/account_moderation_note_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

Fabricator(:account_moderation_note) do
content 'MyText'
account
target_account { Fabricate(:account) }
account { Fabricate.build(:account) }
target_account { Fabricate.build(:account) }
end
4 changes: 2 additions & 2 deletions spec/fabricators/account_note_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator(:account_note) do
account
target_account { Fabricate(:account) }
account { Fabricate.build(:account) }
target_account { Fabricate.build(:account) }
comment 'User note text'
end
2 changes: 1 addition & 1 deletion spec/fabricators/account_stat_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator(:account_stat) do
account
account { Fabricate.build(:account) }
statuses_count '123'
following_count '456'
followers_count '789'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

Fabricator(:account_statuses_cleanup_policy) do
account
account { Fabricate.build(:account) }
end
2 changes: 1 addition & 1 deletion spec/fabricators/account_warning_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator(:account_warning) do
account
account { Fabricate.build(:account) }
target_account(fabricator: :account)
text { Faker::Lorem.paragraph }
action 'suspend'
Expand Down
2 changes: 1 addition & 1 deletion spec/fabricators/admin_action_log_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator('Admin::ActionLog') do
account
account { Fabricate.build(:account) }
action 'MyString'
target nil
end
2 changes: 1 addition & 1 deletion spec/fabricators/backup_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

Fabricator(:backup) do
user
user { Fabricate.build(:user) }
end
4 changes: 2 additions & 2 deletions spec/fabricators/block_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:block) do
account
target_account { Fabricate(:account) }
account { Fabricate.build(:account) }
target_account { Fabricate.build(:account) }
end
4 changes: 2 additions & 2 deletions spec/fabricators/bookmark_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:bookmark) do
account
status
account { Fabricate.build(:account) }
status { Fabricate.build(:status) }
end
2 changes: 1 addition & 1 deletion spec/fabricators/bulk_import_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
imported_items 1
finished_at '2022-11-18 14:55:07'
overwrite false
account
account { Fabricate.build(:account) }
end
2 changes: 1 addition & 1 deletion spec/fabricators/bulk_import_row_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:bulk_import_row) do
bulk_import
bulk_import { Fabricate.build(:bulk_import) }
data ''
end
2 changes: 1 addition & 1 deletion spec/fabricators/canonical_email_block_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Fabricator(:canonical_email_block) do
email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } }
reference_account { Fabricate(:account) }
reference_account { Fabricate.build(:account) }
end
2 changes: 1 addition & 1 deletion spec/fabricators/custom_filter_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator(:custom_filter) do
account
account { Fabricate.build(:account) }
expires_at nil
phrase 'discourse'
context %w(home notifications)
Expand Down
2 changes: 1 addition & 1 deletion spec/fabricators/custom_filter_keyword_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:custom_filter_keyword) do
custom_filter
custom_filter { Fabricate.build(:custom_filter) }
keyword 'discourse'
end
4 changes: 2 additions & 2 deletions spec/fabricators/custom_filter_status_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:custom_filter_status) do
custom_filter
status
custom_filter { Fabricate.build(:custom_filter) }
status { Fabricate.build(:status) }
end
4 changes: 2 additions & 2 deletions spec/fabricators/device_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

Fabricator(:device) do
access_token
account
access_token { Fabricate.build(:access_token) }
account { Fabricate.build(:account) }
device_id { Faker::Number.number(digits: 5) }
name { Faker::App.name }
fingerprint_key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
Expand Down
4 changes: 2 additions & 2 deletions spec/fabricators/encrypted_message_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator(:encrypted_message) do
device
from_account { Fabricate(:account) }
device { Fabricate.build(:device) }
from_account { Fabricate.build(:account) }
from_device_id { Faker::Number.number(digits: 5) }
end
4 changes: 2 additions & 2 deletions spec/fabricators/favourite_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:favourite) do
account
status
account { Fabricate.build(:account) }
status { Fabricate.build(:status) }
end
4 changes: 2 additions & 2 deletions spec/fabricators/featured_tag_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator(:featured_tag) do
account
tag
account { Fabricate.build(:account) }
tag { Fabricate.build(:tag) }
name { sequence(:name) { |i| "Tag#{i}" } }
end
4 changes: 2 additions & 2 deletions spec/fabricators/follow_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:follow) do
account
target_account { Fabricate(:account) }
account { Fabricate.build(:account) }
target_account { Fabricate.build(:account) }
end
4 changes: 2 additions & 2 deletions spec/fabricators/follow_request_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Fabricator(:follow_request) do
account
target_account { Fabricate(:account, locked: true) }
account { Fabricate.build(:account) }
target_account { Fabricate.build(:account, locked: true) }
end
2 changes: 1 addition & 1 deletion spec/fabricators/identity_fabricator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Fabricator(:identity) do
user
user { Fabricate.build(:user) }
provider 'MyString'
uid 'MyString'
end
Loading

0 comments on commit 42a0898

Please sign in to comment.