From 3b1f9bf4cbc047321f7fb8886cacad2a35de51b9 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 17:43:20 +0100 Subject: [PATCH 01/74] Remove legacy cropping feature --- .../retrospring/features/settings/crop.ts | 61 ------------------- .../retrospring/features/settings/index.ts | 5 +- 2 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 app/javascript/retrospring/features/settings/crop.ts diff --git a/app/javascript/retrospring/features/settings/crop.ts b/app/javascript/retrospring/features/settings/crop.ts deleted file mode 100644 index c30e3e5f..00000000 --- a/app/javascript/retrospring/features/settings/crop.ts +++ /dev/null @@ -1,61 +0,0 @@ -import Croppr from 'croppr'; - -const readImage = (file, callback) => callback((window.URL || window.webkitURL).createObjectURL(file)); - -export function profilePictureChangeHandler(event: Event): void { - const input = event.target as HTMLInputElement; - - const cropControls = document.querySelector('#profile-picture-crop-controls'); - cropControls.classList.toggle('d-none'); - - if (input.files && input.files[0]) { - readImage(input.files[0], (src) => { - const updateValues = (data) => { - document.querySelector('#profile_picture_x').value = data.x; - document.querySelector('#profile_picture_y').value = data.y; - document.querySelector('#profile_picture_w').value = data.width; - document.querySelector('#profile_picture_h').value = data.height; - } - - const cropper = document.querySelector('#profile-picture-cropper'); - cropper.src = src; - - new Croppr(cropper, { - aspectRatio: 1, - startSize: [100, 100, '%'], - onCropStart: updateValues, - onCropMove: updateValues, - onCropEnd: updateValues - }); - }); - } -} - -export function profileHeaderChangeHandler(event: Event): void { - const input = event.target as HTMLInputElement; - - const cropControls = document.querySelector('#profile-header-crop-controls'); - cropControls.classList.toggle('d-none'); - - if (input.files && input.files[0]) { - readImage(input.files[0], (src) => { - const updateValues = (data) => { - document.querySelector('#profile_header_x').value = data.x; - document.querySelector('#profile_header_y').value = data.y; - document.querySelector('#profile_header_w').value = data.width; - document.querySelector('#profile_header_h').value = data.height; - } - - const cropper = document.querySelector('#profile-header-cropper'); - cropper.src = src; - - new Croppr(cropper, { - aspectRatio: 7/30, - startSize: [100, 100, '%'], - onCropStart: updateValues, - onCropMove: updateValues, - onCropEnd: updateValues - }); - }); - } -} \ No newline at end of file diff --git a/app/javascript/retrospring/features/settings/index.ts b/app/javascript/retrospring/features/settings/index.ts index ad6b214e..5ea4bb2d 100644 --- a/app/javascript/retrospring/features/settings/index.ts +++ b/app/javascript/retrospring/features/settings/index.ts @@ -1,11 +1,8 @@ import registerEvents from "utilities/registerEvents"; -import { profileHeaderChangeHandler, profilePictureChangeHandler } from "./crop"; import { userSubmitHandler } from "./password"; export default (): void => { registerEvents([ - { type: 'submit', target: document.querySelector('#edit_user'), handler: userSubmitHandler }, - { type: 'change', target: document.querySelector('#user_profile_picture[type=file]'), handler: profilePictureChangeHandler }, - { type: 'change', target: document.querySelector('#user_profile_header[type=file]'), handler: profileHeaderChangeHandler } + { type: 'submit', target: document.querySelector('#edit_user'), handler: userSubmitHandler } ]); } From 96ed2c864c966981bcb6158bcfc4c1bc280e8964 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 17:43:40 +0100 Subject: [PATCH 02/74] Add Stimulus cropper controller --- .../controllers/cropper_controller.ts | 49 +++++++++++++++++++ .../retrospring/initializers/stimulus.ts | 2 + 2 files changed, 51 insertions(+) create mode 100644 app/javascript/retrospring/controllers/cropper_controller.ts diff --git a/app/javascript/retrospring/controllers/cropper_controller.ts b/app/javascript/retrospring/controllers/cropper_controller.ts new file mode 100644 index 00000000..269d0066 --- /dev/null +++ b/app/javascript/retrospring/controllers/cropper_controller.ts @@ -0,0 +1,49 @@ +import { Controller } from '@hotwired/stimulus'; +import Croppr from 'croppr'; + +export default class extends Controller { + static targets = ['input', 'controls', 'cropper', 'x', 'y', 'w', 'h']; + + declare readonly inputTarget: HTMLInputElement; + declare readonly controlsTarget: HTMLElement; + declare readonly cropperTarget: HTMLImageElement; + declare readonly xTarget: HTMLInputElement; + declare readonly yTarget: HTMLInputElement; + declare readonly wTarget: HTMLInputElement; + declare readonly hTarget: HTMLInputElement; + + static values = { + aspectRatio: String + }; + + declare readonly aspectRatioValue: string; + + readImage(file, callback) { + callback((window.URL || window.webkitURL).createObjectURL(file)); + } + + updateValues(data) { + this.xTarget.value = data.x; + this.yTarget.value = data.y; + this.wTarget.value = data.width; + this.hTarget.value = data.height; + } + + change() { + this.controlsTarget.classList.toggle('d-none'); + + if (this.inputTarget.files && this.inputTarget.files[0]) { + this.readImage(this.inputTarget.files[0], (src) => { + this.cropperTarget.src = src; + + new Croppr(this.cropperTarget, { + aspectRatio: parseFloat(this.aspectRatioValue), + startSize: [100, 100, '%'], + onCropStart: this.updateValues.bind(this), + onCropMove: this.updateValues.bind(this), + onCropEnd: this.updateValues.bind(this) + }); + }); + } + } +} diff --git a/app/javascript/retrospring/initializers/stimulus.ts b/app/javascript/retrospring/initializers/stimulus.ts index 3af6306c..64ba1a50 100644 --- a/app/javascript/retrospring/initializers/stimulus.ts +++ b/app/javascript/retrospring/initializers/stimulus.ts @@ -7,6 +7,7 @@ import FormatPopupController from "retrospring/controllers/format_popup_controll import CollapseController from "retrospring/controllers/collapse_controller"; import ThemeController from "retrospring/controllers/theme_controller"; import CapabilitiesController from "retrospring/controllers/capabilities_controller"; +import CropperController from "retrospring/controllers/cropper_controller"; /** * This module sets up Stimulus and our controllers @@ -23,6 +24,7 @@ export default function (): void { window['Stimulus'].register('character-count', CharacterCountController); window['Stimulus'].register('character-count-warning', CharacterCountWarningController); window['Stimulus'].register('collapse', CollapseController); + window['Stimulus'].register('cropper', CropperController); window['Stimulus'].register('format-popup', FormatPopupController); window['Stimulus'].register('theme', ThemeController); } From 6a361e69db2db434a6ef946069514c4bf2c62915 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 17:44:08 +0100 Subject: [PATCH 03/74] Wire up cropper controller in profile settings --- app/views/settings/profile/edit.html.haml | 50 ++++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/app/views/settings/profile/edit.html.haml b/app/views/settings/profile/edit.html.haml index 7cd29926..f19a4a32 100644 --- a/app/views/settings/profile/edit.html.haml +++ b/app/views/settings/profile/edit.html.haml @@ -2,36 +2,38 @@ .card-body = bootstrap_form_for(current_user, url: settings_profile_picture_path, html: { multipart: true }, method: :patch, data: { turbo: false }) do |f| - .d-flex#profile-picture-media - .flex-shrink-0 - %img.avatar-lg.me-3{ src: current_user.profile_picture.url(:medium) } - .flex-grow-1 - = f.file_field :profile_picture, accept: APP_CONFIG[:accepted_image_formats].join(",") + %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "1"}} + .d-flex#profile-picture-media + .flex-shrink-0 + %img.avatar-lg.me-3{ src: current_user.profile_picture.url(:medium) } + .flex-grow-1 + = f.file_field :profile_picture, accept: APP_CONFIG[:accepted_image_formats].join(","), data: { cropper_target: "input", action: "cropper#change" } - .row.d-none#profile-picture-crop-controls - .col-sm-10.col-md-8 - %strong= t(".adjust.profile_picture") - %img#profile-picture-cropper{ src: current_user.profile_picture.url(:medium) } + .row.d-none#profile-picture-crop-controls{ data: { cropper_target: "controls" } } + .col-sm-10.col-md-8 + %strong= t(".adjust.profile_picture") + %img#profile-picture-cropper{ src: current_user.profile_picture.url(:medium), data: { cropper_target: "cropper" } } - .row.mb-2#profile-header-media - .col-xs-12.col-md-6 - %img.mw-100.me-3{ src: current_user.profile_header.url(:mobile) } - .col-xs-12.col-md-6.mt-3.mt-sm-0.ps-3.pe-3 - = f.file_field :profile_header, accept: APP_CONFIG[:accepted_image_formats].join(",") + - %i[profile_picture_x profile_picture_y profile_picture_w profile_picture_h].each do |attrib| + = f.hidden_field attrib, id: attrib, data: { cropper_target: attrib.to_s.split("_").last } - .row.d-none#profile-header-crop-controls - .col-sm-10.col-md-8 - %strong= t(".adjust.profile_header") - %img#profile-header-cropper{ src: current_user.profile_header.url(:web) } + %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "0.23"}} + .row.mb-2#profile-header-media + .col-xs-12.col-md-6 + %img.mw-100.me-3{ src: current_user.profile_header.url(:mobile) } + .col-xs-12.col-md-6.mt-3.mt-sm-0.ps-3.pe-3 + = f.file_field :profile_header, accept: APP_CONFIG[:accepted_image_formats].join(","), data: { cropper_target: "input", action: "cropper#change" } + + .row.d-none#profile-header-crop-controls{ data: { cropper_target: "controls" } } + .col-sm-10.col-md-8 + %strong= t(".adjust.profile_header") + %img#profile-header-cropper{ src: current_user.profile_header.url(:web), data: { cropper_target: "cropper" } } + + - %i[profile_header_x profile_header_y profile_header_w profile_header_h].each do |attrib| + = f.hidden_field attrib, id: attrib, data: { cropper_target: attrib.to_s.split("_").last } = f.check_box :show_foreign_themes - - %i[profile_picture_x profile_picture_y profile_picture_w profile_picture_h].each do |attrib| - = f.hidden_field attrib, id: attrib - - - %i[profile_header_x profile_header_y profile_header_w profile_header_h].each do |attrib| - = f.hidden_field attrib, id: attrib - = f.primary t(".submit_picture") .card .card-body From f0df18ce871a51022bd8ce36133bb984afb0224a Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 17:48:53 +0100 Subject: [PATCH 04/74] Remove unused IDs on profile crop elements --- app/views/settings/profile/edit.html.haml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/settings/profile/edit.html.haml b/app/views/settings/profile/edit.html.haml index f19a4a32..ad75dd65 100644 --- a/app/views/settings/profile/edit.html.haml +++ b/app/views/settings/profile/edit.html.haml @@ -3,31 +3,31 @@ = bootstrap_form_for(current_user, url: settings_profile_picture_path, html: { multipart: true }, method: :patch, data: { turbo: false }) do |f| %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "1"}} - .d-flex#profile-picture-media + .d-flex .flex-shrink-0 %img.avatar-lg.me-3{ src: current_user.profile_picture.url(:medium) } .flex-grow-1 = f.file_field :profile_picture, accept: APP_CONFIG[:accepted_image_formats].join(","), data: { cropper_target: "input", action: "cropper#change" } - .row.d-none#profile-picture-crop-controls{ data: { cropper_target: "controls" } } + .row.d-none{ data: { cropper_target: "controls" } } .col-sm-10.col-md-8 %strong= t(".adjust.profile_picture") - %img#profile-picture-cropper{ src: current_user.profile_picture.url(:medium), data: { cropper_target: "cropper" } } + %img{ src: current_user.profile_picture.url(:medium), data: { cropper_target: "cropper" } } - %i[profile_picture_x profile_picture_y profile_picture_w profile_picture_h].each do |attrib| = f.hidden_field attrib, id: attrib, data: { cropper_target: attrib.to_s.split("_").last } %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "0.23"}} - .row.mb-2#profile-header-media + .row.mb-2 .col-xs-12.col-md-6 %img.mw-100.me-3{ src: current_user.profile_header.url(:mobile) } .col-xs-12.col-md-6.mt-3.mt-sm-0.ps-3.pe-3 = f.file_field :profile_header, accept: APP_CONFIG[:accepted_image_formats].join(","), data: { cropper_target: "input", action: "cropper#change" } - .row.d-none#profile-header-crop-controls{ data: { cropper_target: "controls" } } + .row.d-none{ data: { cropper_target: "controls" } } .col-sm-10.col-md-8 %strong= t(".adjust.profile_header") - %img#profile-header-cropper{ src: current_user.profile_header.url(:web), data: { cropper_target: "cropper" } } + %img{ src: current_user.profile_header.url(:web), data: { cropper_target: "cropper" } } - %i[profile_header_x profile_header_y profile_header_w profile_header_h].each do |attrib| = f.hidden_field attrib, id: attrib, data: { cropper_target: attrib.to_s.split("_").last } From fe156a38d33efbb4b86430c96324ba5c7c6d402d Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 17:58:23 +0100 Subject: [PATCH 05/74] Appease the dog overlords --- .../retrospring/controllers/cropper_controller.ts | 6 +++--- app/views/settings/profile/edit.html.haml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/retrospring/controllers/cropper_controller.ts b/app/javascript/retrospring/controllers/cropper_controller.ts index 269d0066..921e328c 100644 --- a/app/javascript/retrospring/controllers/cropper_controller.ts +++ b/app/javascript/retrospring/controllers/cropper_controller.ts @@ -18,18 +18,18 @@ export default class extends Controller { declare readonly aspectRatioValue: string; - readImage(file, callback) { + readImage(file: File, callback: (string) => void): void { callback((window.URL || window.webkitURL).createObjectURL(file)); } - updateValues(data) { + updateValues(data: Record): void { this.xTarget.value = data.x; this.yTarget.value = data.y; this.wTarget.value = data.width; this.hTarget.value = data.height; } - change() { + change(): void { this.controlsTarget.classList.toggle('d-none'); if (this.inputTarget.files && this.inputTarget.files[0]) { diff --git a/app/views/settings/profile/edit.html.haml b/app/views/settings/profile/edit.html.haml index ad75dd65..32721590 100644 --- a/app/views/settings/profile/edit.html.haml +++ b/app/views/settings/profile/edit.html.haml @@ -2,7 +2,7 @@ .card-body = bootstrap_form_for(current_user, url: settings_profile_picture_path, html: { multipart: true }, method: :patch, data: { turbo: false }) do |f| - %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "1"}} + %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "1" } } .d-flex .flex-shrink-0 %img.avatar-lg.me-3{ src: current_user.profile_picture.url(:medium) } @@ -17,7 +17,7 @@ - %i[profile_picture_x profile_picture_y profile_picture_w profile_picture_h].each do |attrib| = f.hidden_field attrib, id: attrib, data: { cropper_target: attrib.to_s.split("_").last } - %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "0.23"}} + %div{ data: { controller: "cropper", cropper_aspect_ratio_value: "0.23" } } .row.mb-2 .col-xs-12.col-md-6 %img.mw-100.me-3{ src: current_user.profile_header.url(:mobile) } From b99e1b03de2841c7302e2c13c5e433faa3dd4245 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Mon, 23 Jan 2023 12:25:48 +0100 Subject: [PATCH 06/74] notifications: only update all new notifications --- app/views/layouts/notifications.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/notifications.html.haml b/app/views/layouts/notifications.html.haml index d7c87e7e..dceb6d47 100644 --- a/app/views/layouts/notifications.html.haml +++ b/app/views/layouts/notifications.html.haml @@ -8,5 +8,5 @@ .d-block.d-sm-none= render "shared/links" :ruby - Notification.for(current_user).update_all(new: false) + Notification.for(current_user).where(new: true).update_all(new: false) parent_layout 'base' From a0a7f4e1248c7a21c91cb74975c69b3e36bf410b Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 23 Jan 2023 23:36:38 +0100 Subject: [PATCH 07/74] Add raised-text and raised-accent-text theme variables --- app/assets/stylesheets/_variables.scss | 2 ++ app/assets/stylesheets/overrides/_card.scss | 2 ++ app/helpers/theme_helper.rb | 2 ++ app/javascript/retrospring/utilities/theme.ts | 2 ++ app/views/settings/theme/edit.html.haml | 11 ++++++++--- config/locales/activerecord.en.yml | 2 ++ ...23214851_add_raised_and_accent_text_to_themes.rb | 13 +++++++++++++ db/schema.rb | 6 ++++-- 8 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20230123214851_add_raised_and_accent_text_to_themes.rb diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 54e661ab..26508487 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -125,6 +125,8 @@ $spacers: map-merge($rs-spacers, $spacers); --muted-text: 108, 117, 125; --input-text: 0, 0, 0; --input-placeholder: 108, 117, 125; + --raised-text: 0, 0, 0; + --raised-accent-text: 0, 0, 0; --turbolinks-progress-color: #a58adc; // --primary lightened by 25% } diff --git a/app/assets/stylesheets/overrides/_card.scss b/app/assets/stylesheets/overrides/_card.scss index 969f7876..5bbe85ee 100644 --- a/app/assets/stylesheets/overrides/_card.scss +++ b/app/assets/stylesheets/overrides/_card.scss @@ -4,6 +4,7 @@ margin-bottom: map.get($spacers, 3); box-shadow: $box-shadow-sm; background-color: var(--raised-bg); + color: RGB(var(--raised-text)); p:last-child { margin-bottom: 0; @@ -17,4 +18,5 @@ .card-header, .card-footer { background-color: var(--raised-accent); + color: RGB(var(--raised-accent-text)); } diff --git a/app/helpers/theme_helper.rb b/app/helpers/theme_helper.rb index 3b3cf1e9..c618b212 100644 --- a/app/helpers/theme_helper.rb +++ b/app/helpers/theme_helper.rb @@ -17,7 +17,9 @@ module ThemeHelper "light_color" => "light", "light_text" => "light-text", "raised_background" => %w[raised-bg raised-bg-rgb], + "raised_text" => "raised-text", "raised_accent" => %w[raised-accent raised-accent-rgb], + "raised_accent_text"=> "raised-accent-text", "background_color" => "background", "body_text" => "body-text", "input_color" => "input-bg", diff --git a/app/javascript/retrospring/utilities/theme.ts b/app/javascript/retrospring/utilities/theme.ts index 7ee601b8..e96da245 100644 --- a/app/javascript/retrospring/utilities/theme.ts +++ b/app/javascript/retrospring/utilities/theme.ts @@ -14,7 +14,9 @@ export const THEME_MAPPING = { 'light_color': 'light', 'light_text': 'light-text', 'raised_background': 'raised-bg', + 'raised_text': 'raised-text', 'raised_accent': 'raised-accent', + 'raised_accent_text': 'raised-accent-text', 'background_color': 'background', 'body_text': 'body-text', 'input_color': 'input-bg', diff --git a/app/views/settings/theme/edit.html.haml b/app/views/settings/theme/edit.html.haml index 060c3ebf..cd1c5132 100644 --- a/app/views/settings/theme/edit.html.haml +++ b/app/views/settings/theme/edit.html.haml @@ -93,7 +93,7 @@ .row .col-sm-6 - = f.text_field :input_placeholder, class: "color", data: { default: 0x6C757D, theme_target: "color" } + = f.text_field :input_placeholder, class: "color", data: { default: 0x6C757D, theme_target: "color", action: "theme#updatePreview" } .col-sm-6 .form-group %label.form-label Example Input @@ -105,9 +105,14 @@ .row .col-sm-6 - = f.text_field :raised_background, class: "color", data: { default: 0xFFFFFF, theme_target: "color" } + = f.text_field :raised_background, class: "color", data: { default: 0xFFFFFF, theme_target: "color", action: "theme#updatePreview" } .col-sm-6 - = f.text_field :raised_accent, class: "color", data: { default: 0xF7F7F7, theme_target: "color" } + = f.text_field :raised_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" } + .row + .col-sm-6 + = f.text_field :raised_accent, class: "color", data: { default: 0xF7F7F7, theme_target: "color", action: "theme#updatePreview" } + .col-sm-6 + = f.text_field :raised_accent_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" } .card-footer %p= t(".raised.accent.example") .card diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index c14e12b4..2b1b178e 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -49,7 +49,9 @@ en: primary_color: "Primary colour" primary_text: "Primary text colour" raised_accent: "Raised accent colour" + raised_accent_text: "Raised accent text colour" raised_background: "Raised background colour" + raised_text: "Raised text colour" success_color: "Success colour" success_text: "Success text colour" warning_color: "Warning colour" diff --git a/db/migrate/20230123214851_add_raised_and_accent_text_to_themes.rb b/db/migrate/20230123214851_add_raised_and_accent_text_to_themes.rb new file mode 100644 index 00000000..596b0858 --- /dev/null +++ b/db/migrate/20230123214851_add_raised_and_accent_text_to_themes.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddRaisedAndAccentTextToThemes < ActiveRecord::Migration[6.1] + def up + add_column :themes, :raised_text, :integer, default: 0x000000, null: false + add_column :themes, :raised_accent_text, :integer, default: 0x000000, null: false + end + + def down + remove_column :themes, :raised_text + remove_column :themes, :raised_accent_text + end +end diff --git a/db/schema.rb b/db/schema.rb index 45b1005d..d95c380d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_01_08_114333) do +ActiveRecord::Schema.define(version: 2023_01_23_214851) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -181,7 +181,7 @@ ActiveRecord::Schema.define(version: 2023_01_08_114333) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" - t.index ["resource_type", "resource_id"], name: "index_roles_on_resource" + t.index ["resource_type", "resource_id"], name: "index_roles_on_resource_type_and_resource_id" end create_table "rpush_apps", force: :cascade do |t| @@ -301,6 +301,8 @@ ActiveRecord::Schema.define(version: 2023_01_08_114333) do t.integer "light_color", default: 16316922 t.integer "light_text", default: 0 t.integer "input_placeholder", default: 7107965, null: false + t.integer "raised_text", default: 0, null: false + t.integer "raised_accent_text", default: 0, null: false t.index ["user_id", "created_at"], name: "index_themes_on_user_id_and_created_at" end From 58705fffba417db7210c36500487ab7b448c3196 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 24 Jan 2023 15:54:41 +0100 Subject: [PATCH 08/74] mark notifications as "read" in the controller and when you see them this makes it behave a bit more like the inbox --- app/controllers/notifications_controller.rb | 7 +++++++ app/views/layouts/notifications.html.haml | 1 - spec/controllers/notifications_controller_spec.rb | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 6f6f0e91..0655c3c3 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -3,6 +3,8 @@ class NotificationsController < ApplicationController before_action :authenticate_user! + after_action :mark_notifications_as_read, only: %i[index] + TYPE_MAPPINGS = { "answer" => Notification::QuestionAnswered.name, "comment" => Notification::Commented.name, @@ -25,6 +27,11 @@ class NotificationsController < ApplicationController private + def mark_notifications_as_read + # using .dup to not modify @notifications -- useful in tests + @notifications&.dup&.update_all(new: false) + end + def cursored_notifications_for(type:, last_id:, size: nil) cursor_params = { last_id: last_id, size: size }.compact diff --git a/app/views/layouts/notifications.html.haml b/app/views/layouts/notifications.html.haml index dceb6d47..08d8ad1d 100644 --- a/app/views/layouts/notifications.html.haml +++ b/app/views/layouts/notifications.html.haml @@ -8,5 +8,4 @@ .d-block.d-sm-none= render "shared/links" :ruby - Notification.for(current_user).where(new: true).update_all(new: false) parent_layout 'base' diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index f89db5fb..bcae9a8d 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -33,5 +33,9 @@ describe NotificationsController do expect(response).to render_template(:index) expect(controller.instance_variable_get(:@notifications)).to have_attributes(size: 2) end + + it "marks notifications as read" do + expect { subject }.to change { Notification.for(user).where(new: true).count }.from(2).to(0) + end end end From 8cd0d481c8ca1d9fcf51a589905658c1e62b77be Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 24 Jan 2023 15:57:34 +0100 Subject: [PATCH 09/74] bruh --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 0655c3c3..4f2dfdeb 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -29,7 +29,7 @@ class NotificationsController < ApplicationController def mark_notifications_as_read # using .dup to not modify @notifications -- useful in tests - @notifications&.dup&.update_all(new: false) + @notifications&.dup&.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations end def cursored_notifications_for(type:, last_id:, size: nil) From adaa4a4314577f7d971190f6abf5c3558feb6bc5 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Thu, 26 Jan 2023 12:08:40 +0100 Subject: [PATCH 10/74] Only pass cached requests through service worker --- public/service_worker.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/service_worker.js b/public/service_worker.js index 3735a89b..8662f085 100644 --- a/public/service_worker.js +++ b/public/service_worker.js @@ -47,6 +47,9 @@ self.addEventListener('install', function (event) { }); self.addEventListener('fetch', function (event) { + const url = new URL(event.request.url); + if (event.request.method !== 'GET' || !OFFLINE_CACHE_PATHS.includes(url.pathname)) return; + event.respondWith( (async () => { try { From 9a5ce13cfde6ae96c58d68f2de7dc51888adc875 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Fri, 27 Jan 2023 16:16:34 +0100 Subject: [PATCH 11/74] re-add removed remove_stale rake task --- Rakefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Rakefile b/Rakefile index 20c3349e..17ba7dcf 100644 --- a/Rakefile +++ b/Rakefile @@ -51,6 +51,15 @@ namespace :justask do # rubocop:disable Metrics/BlockLength user.remove_role :moderator puts "#{user.screen_name} is no longer a moderator." end + + desc "Removes users whose accounts haven't been verified for over 3 months." + task remove_stale: :environment do + puts "Removing stale users…" + removed = User.where(confirmed_at: nil) + .where("confirmation_sent_at < ?", DateTime.now.utc - 3.months) + .destroy_all.count + puts "Removed #{removed} users" + end end namespace :db do From 420627f3adae872ac4902eccc12003c6703b16b1 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 27 Jan 2023 17:28:13 +0100 Subject: [PATCH 12/74] Bump version to 2023.0127.0 --- lib/retrospring/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/retrospring/version.rb b/lib/retrospring/version.rb index 824e5dc3..f35b16f9 100644 --- a/lib/retrospring/version.rb +++ b/lib/retrospring/version.rb @@ -17,7 +17,7 @@ module Retrospring def month = 1 - def day = 23 + def day = 27 def patch = 0 From 3e3501d201ee4edc6dfa82b26a681d8109b9cb16 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Fri, 27 Jan 2023 20:31:38 +0100 Subject: [PATCH 13/74] inbox: update inbox entries in controller --- app/controllers/inbox_controller.rb | 7 +++++++ app/views/layouts/inbox.html.haml | 1 - spec/controllers/inbox_controller_spec.rb | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 19c6a70d..48cc5675 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -3,6 +3,8 @@ class InboxController < ApplicationController before_action :authenticate_user! + after_action :mark_inbox_entries_as_read, only: %i[show] + def show find_author find_inbox_entries @@ -77,4 +79,9 @@ class InboxController < ApplicationController .joins(:question) .where(questions: { user: @author_user, author_is_anonymous: false }) end + + def mark_inbox_entries_as_read + # using .dup to not modify @inbox -- useful in tests + @inbox&.dup&.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations + end end diff --git a/app/views/layouts/inbox.html.haml b/app/views/layouts/inbox.html.haml index b54b82b5..cb931773 100644 --- a/app/views/layouts/inbox.html.haml +++ b/app/views/layouts/inbox.html.haml @@ -9,6 +9,5 @@ = render 'shared/links' :ruby - @inbox.update_all(new: false) provide(:title, generate_title('Inbox')) parent_layout 'base' diff --git a/spec/controllers/inbox_controller_spec.rb b/spec/controllers/inbox_controller_spec.rb index 6cb2e128..bc0ba2ad 100644 --- a/spec/controllers/inbox_controller_spec.rb +++ b/spec/controllers/inbox_controller_spec.rb @@ -58,6 +58,10 @@ describe InboxController, type: :controller do end end + it "updates the inbox entry status" do + expect { subject }.to change { inbox_entry.reload.new? }.from(true).to(false) + end + context "when requested the turbo stream format" do subject { get :show, format: :turbo_stream } From b8b86b069d632285ff1fc78f020c5393130359e7 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 27 Jan 2023 23:08:12 +0100 Subject: [PATCH 14/74] Cache headers for web app manifest based on user theme --- app/controllers/manifests_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/manifests_controller.rb b/app/controllers/manifests_controller.rb index 966f6164..1a66ff85 100644 --- a/app/controllers/manifests_controller.rb +++ b/app/controllers/manifests_controller.rb @@ -3,7 +3,13 @@ class ManifestsController < ApplicationController include ThemeHelper + skip_before_action :banned? + skip_before_action :find_active_announcements + def show + expires_in 1.day + return if fresh_when current_user&.theme + render json: { name: APP_CONFIG["site_name"], description: t("about.index.subtitle"), @@ -12,17 +18,19 @@ class ManifestsController < ApplicationController display: "standalone", categories: %w[social], lang: I18n.locale, - shortcuts: [ - webapp_shortcut(inbox_url, t("navigation.inbox"), "inbox") - ], + shortcuts:, icons: webapp_icons, - theme_color: theme_color, + theme_color:, background_color: mobile_theme_color } end private + def shortcuts = [ + webapp_shortcut(inbox_url, t("navigation.inbox"), "inbox") + ] + def webapp_shortcut(url, name, icon_name) { name: name, From a34a30349e329b9aec1acfde2bc18215025635e5 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 27 Jan 2023 23:16:01 +0100 Subject: [PATCH 15/74] Use `skip_before_action` instead of redefining action in `AjaxController` --- app/controllers/ajax_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/ajax_controller.rb b/app/controllers/ajax_controller.rb index f6718de0..f5cc4ecd 100644 --- a/app/controllers/ajax_controller.rb +++ b/app/controllers/ajax_controller.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class AjaxController < ApplicationController + skip_before_action :find_active_announcements before_action :build_response after_action :return_response @@ -92,10 +93,6 @@ class AjaxController < ApplicationController return_response end - def find_active_announcements - # We do not need announcements here - end - private def build_response From f6392b8ca6fa6fb64f03f7221cb45ffd0ef55b5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 28 Jan 2023 01:21:40 +0000 Subject: [PATCH 16/74] Bump sanitize from 6.0.0 to 6.0.1 Bumps [sanitize](https://github.com/rgrove/sanitize) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/rgrove/sanitize/releases) - [Changelog](https://github.com/rgrove/sanitize/blob/main/HISTORY.md) - [Commits](https://github.com/rgrove/sanitize/compare/v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: sanitize dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index c7e221d6..28e75168 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -437,7 +437,7 @@ GEM ruby-vips (2.1.4) ffi (~> 1.12) rubyzip (2.3.2) - sanitize (6.0.0) + sanitize (6.0.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) sassc (2.4.0) From d45c6af8533dc7617fcb6d278b3d5b7cfc11c7c5 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 11:08:16 +0100 Subject: [PATCH 17/74] Remove page parameter from `user/friends` redirects --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 68958f72..7dca9c1a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -157,14 +157,14 @@ Rails.application.routes.draw do get "/@:username/q/:id", to: "question#show", as: :question get "/@:username/followers", to: "user#followers", as: :show_user_followers get "/@:username/followings", to: "user#followings", as: :show_user_followings - get "/@:username/friends", to: redirect("/@%{username}/followings/p/%{page}") + get "/@:username/friends", to: redirect("/@%{username}/followings") get "/@:username/questions", to: "user#questions", as: :show_user_questions get "/:username", to: "user#show", as: :user_alt get "/:username/a/:id", to: "answer#show", as: :answer_alt get "/:username/q/:id", to: "question#show", as: :question_alt get "/:username/followers", to: "user#followers", as: :show_user_followers_alt get "/:username/followings", to: "user#followings", as: :show_user_followings_alt - get "/:username/friends", to: redirect("/%{username}/followings/p/%{page}") + get "/:username/friends", to: redirect("/%{username}/followings") get "/:username/questions", to: "user#questions", as: :show_user_questions_alt get "/feedback/consent", to: "feedback#consent", as: "feedback_consent" From 6e3bc40c5721533c4405b17431e73814c4e60b63 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 18:48:14 +0100 Subject: [PATCH 18/74] Move marking follow notifications as read to an after action --- app/controllers/user_controller.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 79be3630..ed054b8d 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -3,20 +3,13 @@ class UserController < ApplicationController before_action :set_user before_action :hidden_social_graph_redirect, only: %i[followers followings] + after_action :mark_notification_as_read, only: %i[show] def show @answers = @user.cursored_answers(last_id: params[:last_id]) @answers_last_id = @answers.map(&:id).min @more_data_available = !@user.cursored_answers(last_id: @answers_last_id, size: 1).count.zero? - if user_signed_in? - notif = Notification.where(target_type: "Relationship", target_id: @user.active_follow_relationships.where(target_id: current_user.id).pluck(:id), recipient_id: current_user.id, new: true).first - unless notif.nil? - notif.new = false - notif.save - end - end - respond_to do |format| format.html format.turbo_stream @@ -66,6 +59,18 @@ class UserController < ApplicationController private + def mark_notification_as_read + return unless user_signed_in? + + Notification + .where( + target_type: "Relationship", + target_id: @user.active_follow_relationships.where(target_id: current_user.id).pluck(:id), + recipient_id: current_user.id, + new: true + ).update(new: false) + end + def set_user @user = User.where("LOWER(screen_name) = ?", params[:username].downcase).includes(:profile).first! end From e9c397a01350dfc53fd5fced64183596a7d84225 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 19:02:13 +0100 Subject: [PATCH 19/74] Replace `@title` and `@type` ivars --- app/controllers/user_controller.rb | 14 ++++---------- app/views/user/show_follow.html.haml | 6 +++--- app/views/user/show_follow.turbo_stream.haml | 4 ++-- config/locales/views.en.yml | 4 ++++ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index ed054b8d..ad94a2d1 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -17,36 +17,30 @@ class UserController < ApplicationController end def followers - @title = "Followers" @relationships = @user.cursored_follower_relationships(last_id: params[:last_id]) @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero? @users = @relationships.map(&:source) - @type = :follower respond_to do |format| - format.html { render "show_follow" } - format.turbo_stream { render "show_follow" } + format.html { render "show_follow", locals: { type: :follower } } + format.turbo_stream { render "show_follow", locals: { type: :follower } } end end def followings - @title = "Following" @relationships = @user.cursored_following_relationships(last_id: params[:last_id]) @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero? @users = @relationships.map(&:target) - @type = :friend respond_to do |format| - format.html { render "show_follow" } - format.turbo_stream { render "show_follow" } + format.html { render "show_follow", locals: { type: :friend } } + format.turbo_stream { render "show_follow", locals: { type: :friend } } end end def questions - @title = "Questions" - @questions = @user.cursored_questions(author_is_anonymous: false, direct: direct_param, last_id: params[:last_id]) @questions_last_id = @questions.map(&:id).min @more_data_available = !@user.cursored_questions(author_is_anonymous: false, direct: direct_param, last_id: @questions_last_id, size: 1).count.zero? diff --git a/app/views/user/show_follow.html.haml b/app/views/user/show_follow.html.haml index fd341619..bcd981f0 100644 --- a/app/views/user/show_follow.html.haml +++ b/app/views/user/show_follow.html.haml @@ -1,15 +1,15 @@ .row.row-cols-1.row-cols-sm-2.row-cols-md-3#users - @users.each do |user| .col.pb-3 - = render 'shared/userbox', user: user, type: @type + = render 'shared/userbox', user:, type: - if @more_data_available .d-flex.justify-content-center.justify-content-sm-start#paginator - = button_to t("voc.load"), @type == :follower ? show_user_followers_path(@user) : show_user_followings_path(@user), + = button_to t("voc.load"), type == :follower ? show_user_followers_path(@user) : show_user_followings_path(@user), class: "btn btn-light", method: :get, params: { last_id: @relationships_last_id }, form: { data: { turbo_stream: true } } -- provide(:title, user_title(@user, 'friends and followers')) +- provide(:title, t(".title.#{type}", user: @user.profile.safe_name)) - parent_layout 'user/profile' diff --git a/app/views/user/show_follow.turbo_stream.haml b/app/views/user/show_follow.turbo_stream.haml index d36b3b2f..013d730a 100644 --- a/app/views/user/show_follow.turbo_stream.haml +++ b/app/views/user/show_follow.turbo_stream.haml @@ -1,11 +1,11 @@ = turbo_stream.append "users" do - @users.each do |user| .col.pb-3 - = render 'shared/userbox', user: user, type: @type + = render 'shared/userbox', user:, type: = turbo_stream.update "paginator" do - if @more_data_available - = button_to t("voc.load"), @type == :follower ? show_user_followers_path(@user) : show_user_followings_path(@user), + = button_to t("voc.load"), type == :follower ? show_user_followers_path(@user) : show_user_followings_path(@user), class: "btn btn-light", method: :get, params: { last_id: @relationships_last_id }, diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 6cc8aca5..295f8aab 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -651,6 +651,10 @@ en: index: title: "Questions from %{author_identifier}" user: + show_follow: + title: + follower: "%{user}'s followers" + friend: "%{user}'s followings" actions: view_inbox: "View inbox" privilege: "Check %{user}'s privileges" From ff866f88efbc3896b3c69c6e62b4b6bb54190caf Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 19:09:03 +0100 Subject: [PATCH 20/74] Appease the dog overlords --- app/views/user/show_follow.html.haml | 4 ++-- app/views/user/show_follow.turbo_stream.haml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/user/show_follow.html.haml b/app/views/user/show_follow.html.haml index bcd981f0..364d5dcf 100644 --- a/app/views/user/show_follow.html.haml +++ b/app/views/user/show_follow.html.haml @@ -1,7 +1,7 @@ .row.row-cols-1.row-cols-sm-2.row-cols-md-3#users - @users.each do |user| .col.pb-3 - = render 'shared/userbox', user:, type: + = render "shared/userbox", user:, type: - if @more_data_available .d-flex.justify-content-center.justify-content-sm-start#paginator @@ -12,4 +12,4 @@ form: { data: { turbo_stream: true } } - provide(:title, t(".title.#{type}", user: @user.profile.safe_name)) -- parent_layout 'user/profile' +- parent_layout "user/profile" diff --git a/app/views/user/show_follow.turbo_stream.haml b/app/views/user/show_follow.turbo_stream.haml index 013d730a..7719340e 100644 --- a/app/views/user/show_follow.turbo_stream.haml +++ b/app/views/user/show_follow.turbo_stream.haml @@ -1,7 +1,7 @@ = turbo_stream.append "users" do - @users.each do |user| .col.pb-3 - = render 'shared/userbox', user:, type: + = render "shared/userbox", user:, type: = turbo_stream.update "paginator" do - if @more_data_available From 8dd49d3a8c1c0b4c408f5530a80fa0c8ef8e0fd7 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 28 Jan 2023 19:17:04 +0100 Subject: [PATCH 21/74] Remove author search handler --- app/javascript/retrospring/features/inbox/author.ts | 6 ------ app/javascript/retrospring/features/inbox/index.ts | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 app/javascript/retrospring/features/inbox/author.ts diff --git a/app/javascript/retrospring/features/inbox/author.ts b/app/javascript/retrospring/features/inbox/author.ts deleted file mode 100644 index 456b0ed5..00000000 --- a/app/javascript/retrospring/features/inbox/author.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function authorSearchHandler(event: Event): void { - event.preventDefault(); - - const author = document.querySelector('#author')?.value; - window.location.href = `/inbox/${encodeURIComponent(author)}`; -} \ No newline at end of file diff --git a/app/javascript/retrospring/features/inbox/index.ts b/app/javascript/retrospring/features/inbox/index.ts index 4235dc15..02206e9a 100644 --- a/app/javascript/retrospring/features/inbox/index.ts +++ b/app/javascript/retrospring/features/inbox/index.ts @@ -6,8 +6,7 @@ import { deleteAllAuthorQuestionsHandler, deleteAllQuestionsHandler } from './de export default (): void => { registerEvents([ { type: 'click', target: '#ib-delete-all', handler: deleteAllQuestionsHandler, global: true }, - { type: 'click', target: '#ib-delete-all-author', handler: deleteAllAuthorQuestionsHandler, global: true }, - { type: 'submit', target: '#author-form', handler: authorSearchHandler, global: true } + { type: 'click', target: '#ib-delete-all-author', handler: deleteAllAuthorQuestionsHandler, global: true } ]); registerInboxEntryEvents(); From 6c25594b88b68eea1b442c8b2553718380731717 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 28 Jan 2023 19:18:02 +0100 Subject: [PATCH 22/74] Get the username of the currently searched author correctly --- app/javascript/retrospring/features/inbox/delete.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/javascript/retrospring/features/inbox/delete.ts b/app/javascript/retrospring/features/inbox/delete.ts index 6595af0b..c93534b2 100644 --- a/app/javascript/retrospring/features/inbox/delete.ts +++ b/app/javascript/retrospring/features/inbox/delete.ts @@ -62,6 +62,7 @@ export function deleteAllQuestionsHandler(event: Event): void { export function deleteAllAuthorQuestionsHandler(event: Event): void { const button = event.target as Element; const count = button.getAttribute('data-ib-count'); + const urlSearchParams = new URLSearchParams(window.location.search); swal({ title: I18n.translate('frontend.inbox.confirm_all.title', { count: count }), @@ -75,7 +76,7 @@ export function deleteAllAuthorQuestionsHandler(event: Event): void { }, (returnValue) => { if (returnValue === null) return false; - post(`/ajax/delete_all_inbox/${location.pathname.split('/')[2]}`) + post(`/ajax/delete_all_inbox/${urlSearchParams.get('author')}`) .then(async response => { const data = await response.json; @@ -89,4 +90,4 @@ export function deleteAllAuthorQuestionsHandler(event: Event): void { showErrorNotification(I18n.translate('frontend.error.message')); }); }); -} \ No newline at end of file +} From 32ba17ac72f2971a3470dfc16f88f22fb3b8b2f2 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 21:17:08 +0100 Subject: [PATCH 23/74] Eager load profiles in paginators --- app/models/user/answer_methods.rb | 3 ++- app/models/user/inbox_methods.rb | 3 ++- app/models/user/timeline_methods.rb | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/user/answer_methods.rb b/app/models/user/answer_methods.rb index 172997d2..e40eb82b 100644 --- a/app/models/user/answer_methods.rb +++ b/app/models/user/answer_methods.rb @@ -5,10 +5,11 @@ module User::AnswerMethods define_cursor_paginator :cursored_answers, :ordered_answers + # @return [ActiveRecord::Relation] List of a user's answers def ordered_answers answers .order(:created_at) .reverse_order - .includes(comments: [:user, :smiles], question: [:user], smiles: [:user]) + .includes(comments: %i[user smiles], question: { user: :profile }, smiles: [:user]) end end diff --git a/app/models/user/inbox_methods.rb b/app/models/user/inbox_methods.rb index dea2fb36..1d961ce2 100644 --- a/app/models/user/inbox_methods.rb +++ b/app/models/user/inbox_methods.rb @@ -5,9 +5,10 @@ module User::InboxMethods define_cursor_paginator :cursored_inbox, :ordered_inbox + # @return [ActiveRecord::Relation] the user's inbox entries def ordered_inbox inboxes - .includes(:question, :user) + .includes(:question, user: :profile) .order(:created_at) .reverse_order end diff --git a/app/models/user/timeline_methods.rb b/app/models/user/timeline_methods.rb index 38f1e560..a0fa8c55 100644 --- a/app/models/user/timeline_methods.rb +++ b/app/models/user/timeline_methods.rb @@ -5,8 +5,12 @@ module User::TimelineMethods define_cursor_paginator :cursored_timeline, :timeline - # @return [Array] the users' timeline + # @return [ActiveRecord::Relation] the user's timeline def timeline - Answer.where("user_id in (?) OR user_id = ?", following_ids, id).order(:created_at).reverse_order.includes(comments: %i[user smiles], question: [:user], user: [:profile], smiles: [:user]) + Answer + .where("user_id in (?) OR user_id = ?", following_ids, id) + .order(:created_at) + .reverse_order + .includes(comments: %i[user smiles], question: { user: :profile }, user: [:profile], smiles: [:user]) end end From ab1b034cfbaa3cef962021e35a9f0e11640ff95a Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 21:17:25 +0100 Subject: [PATCH 24/74] Add type hints for paginators --- app/models/user/question_methods.rb | 1 + app/models/user/relationship_methods.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/models/user/question_methods.rb b/app/models/user/question_methods.rb index 0ff0db4f..e2281810 100644 --- a/app/models/user/question_methods.rb +++ b/app/models/user/question_methods.rb @@ -5,6 +5,7 @@ module User::QuestionMethods define_cursor_paginator :cursored_questions, :ordered_questions + # @return [ActiveRecord::Relation] List of questions sent by the user def ordered_questions(author_is_anonymous: nil, direct: nil) questions .where({ author_is_anonymous:, direct: }.compact) diff --git a/app/models/user/relationship_methods.rb b/app/models/user/relationship_methods.rb index faf56ef0..b70bb578 100644 --- a/app/models/user/relationship_methods.rb +++ b/app/models/user/relationship_methods.rb @@ -6,10 +6,12 @@ module User::RelationshipMethods define_cursor_paginator :cursored_following_relationships, :ordered_following_relationships define_cursor_paginator :cursored_follower_relationships, :ordered_follower_relationships + # @return [ActiveRecord::Relation] List of the user's following relationships def ordered_following_relationships active_follow_relationships.reverse_order.includes(target: [:profile]) end + # @return [ActiveRecord::Relation] List of the user's follower relationships def ordered_follower_relationships passive_follow_relationships.reverse_order.includes(source: [:profile]) end From 3e2b65d7b84fa367fe3977e5d87516daf5a04f34 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 21:42:25 +0100 Subject: [PATCH 25/74] Move fetching of services to controller to avoid n+1 queries --- app/controllers/inbox_controller.rb | 17 ++++++++++------- app/views/inbox/_entry.html.haml | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 48cc5675..016e00c1 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -8,16 +8,12 @@ class InboxController < ApplicationController def show find_author find_inbox_entries - - if @author_user && @inbox_count.zero? - # rubocop disabled because of a false positive - flash[:info] = t(".author.info", author: @author) # rubocop:disable Rails/ActionControllerFlashBeforeRender - redirect_to inbox_path(last_id: params[:last_id]) - end + check_for_empty_filter @delete_id = find_delete_id - + @services = current_user.services @disabled = true if @inbox.empty? + respond_to do |format| format.html format.turbo_stream do @@ -50,6 +46,13 @@ class InboxController < ApplicationController private + def check_for_empty_filter + return unless @author_user && @inbox_count.zero? + + flash[:info] = t(".author.info", author: @author) + redirect_to inbox_path(last_id: params[:last_id]) + end + def find_author return if params[:author].blank? diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.html.haml index e761af4f..1b41cb7c 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.html.haml @@ -40,9 +40,9 @@ = render "shared/format_link" .card-footer.d-none{ id: "ib-options-#{i.id}" } %h4= t(".sharing.heading") - - if current_user.services.count.positive? + - if @services.count.positive? .row - - current_user.services.each do |service| + - @services.each do |service| .col-md-3.col-sm-4.col-xs-6 %label %input{ type: "checkbox", name: "ib-share", checked: :checked, data: { ib_id: i.id, service: service.provider } } From 7d5104d09df99b90205d0a8101674cd8a1479646 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:10:14 +0100 Subject: [PATCH 26/74] Filter out user-facing errors from Sentry --- config/initializers/sentry.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 1f4a12af..639ded81 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -8,4 +8,13 @@ Sentry.init do |config| # of transactions for performance monitoring. # We recommend adjusting this value in production config.traces_sample_rate = 0.25 + + config.before_send do |event, hint| + if hint[:exception].is_a?(Errors::Base) + # These are used for user-facing errors, not when something goes wrong + nil + end + + event + end end From da9a170e67e0adc02a8d66a25b4f1f58d7d49d51 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:14:02 +0100 Subject: [PATCH 27/74] Set event fingerprint for exceptions relating to external services --- config/initializers/sentry.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 639ded81..caf6e2d9 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -9,12 +9,21 @@ Sentry.init do |config| # We recommend adjusting this value in production config.traces_sample_rate = 0.25 + exception_fingerprints = { + Excon::Error::ServiceUnavailable => 'external-service', + Twitter::Error::InternalServerError => 'external-service', + } config.before_send do |event, hint| if hint[:exception].is_a?(Errors::Base) # These are used for user-facing errors, not when something goes wrong nil end + exception_class = hint[:exception].class.name + if exception_fingerprints.key?(exception_class) + event.fingerprint = [exception_fingerprints[hint[:exception].class.name]] + end + event end end From 272b98c95447ac8f599df066215831558e571121 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:18:43 +0100 Subject: [PATCH 28/74] `before_send` should be assigned a lambda --- config/initializers/sentry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index caf6e2d9..2b107267 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -13,7 +13,7 @@ Sentry.init do |config| Excon::Error::ServiceUnavailable => 'external-service', Twitter::Error::InternalServerError => 'external-service', } - config.before_send do |event, hint| + config.before_send = lambda do |event, hint| if hint[:exception].is_a?(Errors::Base) # These are used for user-facing errors, not when something goes wrong nil From 367e2f4b92a92e9ddc28ac64d20b6881706e0c0d Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:24:05 +0100 Subject: [PATCH 29/74] Use a local instead of an ivar for passing services into views --- app/controllers/inbox_controller.rb | 6 +++--- app/views/inbox/_entry.html.haml | 4 ++-- app/views/inbox/show.html.haml | 2 +- app/views/inbox/show.turbo_stream.haml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 016e00c1..389411c4 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -11,13 +11,13 @@ class InboxController < ApplicationController check_for_empty_filter @delete_id = find_delete_id - @services = current_user.services @disabled = true if @inbox.empty? + services = current_user.services respond_to do |format| - format.html + format.html { render "show", locals: { services: } } format.turbo_stream do - render "show", layout: false, status: :see_other + render "show", locals: { services: }, layout: false, status: :see_other # rubocop disabled as just flipping a flag doesn't need to have validations to be run @inbox.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.html.haml index 1b41cb7c..f630d80c 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.html.haml @@ -40,9 +40,9 @@ = render "shared/format_link" .card-footer.d-none{ id: "ib-options-#{i.id}" } %h4= t(".sharing.heading") - - if @services.count.positive? + - if services.count.positive? .row - - @services.each do |service| + - services.each do |service| .col-md-3.col-sm-4.col-xs-6 %label %input{ type: "checkbox", name: "ib-share", checked: :checked, data: { ib_id: i.id, service: service.provider } } diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.html.haml index 5c5de4e4..fd14f7fe 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.html.haml @@ -1,6 +1,6 @@ #entries - @inbox.each do |i| - = render "inbox/entry", i: + = render "inbox/entry", services: , i: - if @inbox.empty? %p.empty= t(".empty") diff --git a/app/views/inbox/show.turbo_stream.haml b/app/views/inbox/show.turbo_stream.haml index fffc48fc..ce09c7da 100644 --- a/app/views/inbox/show.turbo_stream.haml +++ b/app/views/inbox/show.turbo_stream.haml @@ -1,6 +1,6 @@ = turbo_stream.append "entries" do - @inbox.each do |i| - = render "inbox/entry", i: + = render "inbox/entry", services:, i: = turbo_stream.update "paginator" do - if @more_data_available From 354407cd79e2bad4fba60a57dec0a05bc40360d4 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:29:41 +0100 Subject: [PATCH 30/74] Use next to return out of `before_send` --- config/initializers/sentry.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 2b107267..62fdaf9e 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -14,10 +14,8 @@ Sentry.init do |config| Twitter::Error::InternalServerError => 'external-service', } config.before_send = lambda do |event, hint| - if hint[:exception].is_a?(Errors::Base) - # These are used for user-facing errors, not when something goes wrong - nil - end + # These are used for user-facing errors, not when something goes wrong + next if hint[:exception].is_a?(Errors::Base) exception_class = hint[:exception].class.name if exception_fingerprints.key?(exception_class) From 9ef6e8fdc1309a95ea2490f217085920b5467695 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:30:03 +0100 Subject: [PATCH 31/74] Use class instead of class name for matching exception types --- config/initializers/sentry.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 62fdaf9e..1124fc37 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -17,9 +17,9 @@ Sentry.init do |config| # These are used for user-facing errors, not when something goes wrong next if hint[:exception].is_a?(Errors::Base) - exception_class = hint[:exception].class.name + exception_class = hint[:exception].class if exception_fingerprints.key?(exception_class) - event.fingerprint = [exception_fingerprints[hint[:exception].class.name]] + event.fingerprint = [exception_fingerprints[exception_class]] end event From 87894d1e95a922e49ae4a96081ccd523df446b15 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:42:14 +0100 Subject: [PATCH 32/74] Move empty filter check back into show action --- app/controllers/inbox_controller.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 389411c4..ff23f8c6 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -5,10 +5,16 @@ class InboxController < ApplicationController after_action :mark_inbox_entries_as_read, only: %i[show] - def show + def show # rubocop:disable Metrics/MethodLength, Metrics/AbcSize find_author find_inbox_entries - check_for_empty_filter + + if @author_user && @inbox_count.zero? + # rubocop disabled because of a false positive + flash[:info] = t(".author.info", author: @author) # rubocop:disable Rails/ActionControllerFlashBeforeRender + redirect_to inbox_path(last_id: params[:last_id]) + return + end @delete_id = find_delete_id @disabled = true if @inbox.empty? @@ -46,13 +52,6 @@ class InboxController < ApplicationController private - def check_for_empty_filter - return unless @author_user && @inbox_count.zero? - - flash[:info] = t(".author.info", author: @author) - redirect_to inbox_path(last_id: params[:last_id]) - end - def find_author return if params[:author].blank? From 96659befeaea6af4c70da60048e50b6ac197676b Mon Sep 17 00:00:00 2001 From: Karina Kwiatek <6197148+raccube@users.noreply.github.com> Date: Sun, 29 Jan 2023 00:46:52 +0100 Subject: [PATCH 33/74] Appease the dog overlords Co-authored-by: Georg Gadinger --- app/views/inbox/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.html.haml index fd14f7fe..94d7d883 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.html.haml @@ -1,6 +1,6 @@ #entries - @inbox.each do |i| - = render "inbox/entry", services: , i: + = render "inbox/entry", services:, i: - if @inbox.empty? %p.empty= t(".empty") From a59bc3ef922b2724407dec5d85489cc83a5f13e4 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sun, 29 Jan 2023 19:19:35 +0100 Subject: [PATCH 34/74] typoed_email_validator: add new endings to the typo list --- app/validators/typoed_email_validator.rb | 1 + spec/models/user_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/validators/typoed_email_validator.rb b/app/validators/typoed_email_validator.rb index cf323bc9..5cc07cff 100644 --- a/app/validators/typoed_email_validator.rb +++ b/app/validators/typoed_email_validator.rb @@ -19,6 +19,7 @@ class TypoedEmailValidator < ActiveModel::EachValidator gmaile.com gmaill.com gmali.com + gmaul.com gnail.com hotamil.com hotmai.com diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 64df9de4..af65a555 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -93,6 +93,7 @@ RSpec.describe User, type: :model do include_examples "invalid email", "fritz.fantom@gmaile.com" include_examples "invalid email", "fritz.fantom@gmaill.com" include_examples "invalid email", "fritz.fantom@gmali.com" + include_examples "invalid email", "fritz.fantom@gmaul.com" include_examples "invalid email", "fritz.fantom@gnail.com" include_examples "invalid email", "fritz.fantom@hotamil.com" include_examples "invalid email", "fritz.fantom@hotmai.com" From ab6e8270dfc04eb2ccfccc9fd2f9642f090c7698 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Jan 2023 20:44:09 +0100 Subject: [PATCH 35/74] Allow new fields in ThemeController --- app/controllers/settings/theme_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/settings/theme_controller.rb b/app/controllers/settings/theme_controller.rb index 14d6457b..f37131f1 100644 --- a/app/controllers/settings/theme_controller.rb +++ b/app/controllers/settings/theme_controller.rb @@ -17,6 +17,7 @@ class Settings::ThemeController < ApplicationController dark_color dark_text light_color light_text raised_background raised_accent + raised_text raised_accent_text background_color body_text muted_text input_color input_text input_placeholder From 520d77bb448efa06ebf63703f5dda02e4f1ed202 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Jan 2023 20:44:40 +0100 Subject: [PATCH 36/74] Let relevant style overrides use the new raised text colors --- app/assets/stylesheets/components/_notifications.scss | 2 +- app/assets/stylesheets/overrides/_dropdown.scss | 9 +++++---- app/assets/stylesheets/overrides/_list-group.scss | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/components/_notifications.scss b/app/assets/stylesheets/components/_notifications.scss index 53fa696e..14b3f443 100644 --- a/app/assets/stylesheets/components/_notifications.scss +++ b/app/assets/stylesheets/components/_notifications.scss @@ -42,7 +42,7 @@ & .dropdown-item:hover, & .dropdown-item:active { background: transparent; - color: RGB(var(--body-text)); + color: RGB(var(--raised-text)); } } diff --git a/app/assets/stylesheets/overrides/_dropdown.scss b/app/assets/stylesheets/overrides/_dropdown.scss index 5d647c3b..524ee2b6 100644 --- a/app/assets/stylesheets/overrides/_dropdown.scss +++ b/app/assets/stylesheets/overrides/_dropdown.scss @@ -1,14 +1,14 @@ .dropdown-menu { - color: RGB(var(--body-text)); + color: RGB(var(--raised-text)); background-color: var(--raised-bg); box-shadow: $box-shadow-lg; border: none; } .dropdown-item { - color: RGB(var(--body-text)); + color: RGB(var(--raised-text)); - &.active, + &.active, &:active, &:active:hover { color: RGB(var(--primary-text)); @@ -16,6 +16,7 @@ } &:hover { + color: RGB(var(--raised-accent-text)); background-color: var(--raised-accent); } } @@ -32,4 +33,4 @@ .dropdown-menu--lists { max-width: 275px; } -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/overrides/_list-group.scss b/app/assets/stylesheets/overrides/_list-group.scss index 0ef6477b..29839dea 100644 --- a/app/assets/stylesheets/overrides/_list-group.scss +++ b/app/assets/stylesheets/overrides/_list-group.scss @@ -13,9 +13,10 @@ } .list-group-item-action { - color: RGB(var(--body-text)); + color: RGB(var(--raised-text)); &:hover, &:focus { + color: RGB(var(--raised-accent-text)); background-color: var(--raised-accent); } From b5ab9d67d2a9e6e70124f8dc1271981854544e47 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Jan 2023 20:58:19 +0100 Subject: [PATCH 37/74] Add migration to use body text value for raised texts in themes --- ...94809_use_body_text_for_raised_texts_in_themes.rb | 12 ++++++++++++ db/schema.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb diff --git a/db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb b/db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb new file mode 100644 index 00000000..b8b574a1 --- /dev/null +++ b/db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class UseBodyTextForRaisedTextsInThemes < ActiveRecord::Migration[6.1] + def change + execute <<~SQUIRREL + UPDATE themes + SET raised_text = body_text, + raised_accent_text = body_text + WHERE body_text != 0; + SQUIRREL + end +end diff --git a/db/schema.rb b/db/schema.rb index d95c380d..82edbdda 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_01_23_214851) do +ActiveRecord::Schema.define(version: 2023_01_29_194809) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 61a31f97b0d58ce3fce5a7dc6780809a9dcfb440 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Jan 2023 21:12:33 +0100 Subject: [PATCH 38/74] Move theme attributes into their own method --- app/controllers/settings/theme_controller.rb | 38 +++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/app/controllers/settings/theme_controller.rb b/app/controllers/settings/theme_controller.rb index f37131f1..58829a67 100644 --- a/app/controllers/settings/theme_controller.rb +++ b/app/controllers/settings/theme_controller.rb @@ -8,23 +8,8 @@ class Settings::ThemeController < ApplicationController def edit; end def update - update_attributes = params.require(:theme).permit(%i[ - primary_color primary_text - danger_color danger_text - success_color success_text - warning_color warning_text - info_color info_text - dark_color dark_text - light_color light_text - raised_background raised_accent - raised_text raised_accent_text - background_color body_text - muted_text input_color - input_text input_placeholder - ]) - if current_user.theme.nil? - current_user.theme = Theme.new update_attributes + current_user.theme = Theme.new theme_attributes current_user.theme.user_id = current_user.id if current_user.theme.save @@ -32,7 +17,7 @@ class Settings::ThemeController < ApplicationController else flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" ")) end - elsif current_user.theme.update(update_attributes) + elsif current_user.theme.update(theme_attributes) flash[:success] = t(".success") else flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" ")) @@ -44,4 +29,23 @@ class Settings::ThemeController < ApplicationController current_user.theme.destroy! redirect_to edit_settings_theme_path end + + private + + def theme_attributes + params.require(:theme).permit(%i[ + primary_color primary_text + danger_color danger_text + success_color success_text + warning_color warning_text + info_color info_text + dark_color dark_text + light_color light_text + raised_background raised_accent + raised_text raised_accent_text + background_color body_text + muted_text input_color + input_text input_placeholder + ]) + end end From 63b16fd39ae6e1bdb0f20607eac793a357176972 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Jan 2023 21:13:38 +0100 Subject: [PATCH 39/74] Appease the dog overlords --- app/helpers/theme_helper.rb | 48 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/helpers/theme_helper.rb b/app/helpers/theme_helper.rb index c618b212..4c1a735f 100644 --- a/app/helpers/theme_helper.rb +++ b/app/helpers/theme_helper.rb @@ -2,30 +2,30 @@ module ThemeHelper ATTRIBUTE_MAP = { - "primary_color" => %w[primary primary-rgb], - "primary_text" => "primary-text", - "danger_color" => "danger", - "danger_text" => "danger-text", - "warning_color" => "warning", - "warning_text" => "warning-text", - "info_color" => "info", - "info_text" => "info-text", - "success_color" => "success", - "success_text" => "success-text", - "dark_color" => "dark", - "dark_text" => "dark-text", - "light_color" => "light", - "light_text" => "light-text", - "raised_background" => %w[raised-bg raised-bg-rgb], - "raised_text" => "raised-text", - "raised_accent" => %w[raised-accent raised-accent-rgb], - "raised_accent_text"=> "raised-accent-text", - "background_color" => "background", - "body_text" => "body-text", - "input_color" => "input-bg", - "input_text" => "input-text", - "input_placeholder" => "input-placeholder", - "muted_text" => "muted-text" + "primary_color" => %w[primary primary-rgb], + "primary_text" => "primary-text", + "danger_color" => "danger", + "danger_text" => "danger-text", + "warning_color" => "warning", + "warning_text" => "warning-text", + "info_color" => "info", + "info_text" => "info-text", + "success_color" => "success", + "success_text" => "success-text", + "dark_color" => "dark", + "dark_text" => "dark-text", + "light_color" => "light", + "light_text" => "light-text", + "raised_background" => %w[raised-bg raised-bg-rgb], + "raised_text" => "raised-text", + "raised_accent" => %w[raised-accent raised-accent-rgb], + "raised_accent_text" => "raised-accent-text", + "background_color" => "background", + "body_text" => "body-text", + "input_color" => "input-bg", + "input_text" => "input-text", + "input_placeholder" => "input-placeholder", + "muted_text" => "muted-text" }.freeze def render_theme From 92cb5da58afbc3893a0bf6825fb25e77345af580 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Jan 2023 21:17:23 +0100 Subject: [PATCH 40/74] Fix theme export specs --- spec/factories/theme.rb | 2 + spec/lib/use_case/data_export/theme_spec.rb | 54 +++++++++++---------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/spec/factories/theme.rb b/spec/factories/theme.rb index 4339377a..ae357dd6 100644 --- a/spec/factories/theme.rb +++ b/spec/factories/theme.rb @@ -15,12 +15,14 @@ FactoryBot.define do dark_color { 6_710_886 } dark_text { 15_658_734 } raised_background { 16_777_215 } + raised_text { 3_355_443 } background_color { 13_026_795 } body_text { 3_355_443 } muted_text { 3_355_443 } input_color { 15_789_556 } input_text { 6_710_886 } raised_accent { 16_250_871 } + raised_accent_text { 3_355_443 } light_color { 16_316_922 } light_text { 0 } end diff --git a/spec/lib/use_case/data_export/theme_spec.rb b/spec/lib/use_case/data_export/theme_spec.rb index af997cc8..11156488 100644 --- a/spec/lib/use_case/data_export/theme_spec.rb +++ b/spec/lib/use_case/data_export/theme_spec.rb @@ -22,32 +22,34 @@ describe UseCase::DataExport::Theme, :data_export do expect(json_file("theme.json")).to eq( { theme: { - id: theme.id, - user_id: user.id, - primary_color: 9342168, - primary_text: 16777215, - danger_color: 14257035, - danger_text: 16777215, - success_color: 12573067, - success_text: 16777215, - warning_color: 14261899, - warning_text: 16777215, - info_color: 9165273, - info_text: 16777215, - dark_color: 6710886, - dark_text: 15658734, - raised_background: 16777215, - background_color: 13026795, - body_text: 3355443, - muted_text: 3355443, - created_at: "2022-12-10T13:37:42.000Z", - updated_at: "2022-12-10T13:37:42.000Z", - input_color: 15789556, - input_text: 6710886, - raised_accent: 16250871, - light_color: 16316922, - light_text: 0, - input_placeholder: 7107965 + id: theme.id, + user_id: user.id, + primary_color: 9342168, + primary_text: 16777215, + danger_color: 14257035, + danger_text: 16777215, + success_color: 12573067, + success_text: 16777215, + warning_color: 14261899, + warning_text: 16777215, + info_color: 9165273, + info_text: 16777215, + dark_color: 6710886, + dark_text: 15658734, + raised_background: 16777215, + raised_text: 3355443, + background_color: 13026795, + body_text: 3355443, + muted_text: 3355443, + created_at: "2022-12-10T13:37:42.000Z", + updated_at: "2022-12-10T13:37:42.000Z", + input_color: 15789556, + input_text: 6710886, + raised_accent: 16250871, + raised_accent_text: 3355443, + light_color: 16316922, + light_text: 0, + input_placeholder: 7107965 } } ) From 0d78442507c11870968a4d4827f4d60104e53764 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Jan 2023 21:25:24 +0100 Subject: [PATCH 41/74] Fix up theme value migration --- ...20230129194809_use_body_text_for_raised_texts_in_themes.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb b/db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb index b8b574a1..7504cf5c 100644 --- a/db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb +++ b/db/migrate/20230129194809_use_body_text_for_raised_texts_in_themes.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class UseBodyTextForRaisedTextsInThemes < ActiveRecord::Migration[6.1] - def change + def up execute <<~SQUIRREL UPDATE themes SET raised_text = body_text, @@ -9,4 +9,6 @@ class UseBodyTextForRaisedTextsInThemes < ActiveRecord::Migration[6.1] WHERE body_text != 0; SQUIRREL end + + def down; end end From 666f95c143151809d8946b1a7b5b843c1403b421 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 29 Jan 2023 21:37:22 +0100 Subject: [PATCH 42/74] Adjust tests to not check ivars that are no longer used when filter is empty --- spec/controllers/inbox_controller_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/controllers/inbox_controller_spec.rb b/spec/controllers/inbox_controller_spec.rb index bc0ba2ad..f2ec2c9f 100644 --- a/spec/controllers/inbox_controller_spec.rb +++ b/spec/controllers/inbox_controller_spec.rb @@ -179,9 +179,7 @@ describe InboxController, type: :controller do inbox: [], inbox_last_id: nil, more_data_available: false, - inbox_count: 0, - delete_id: "ib-delete-all", - disabled: true + inbox_count: 0 } end end @@ -213,9 +211,7 @@ describe InboxController, type: :controller do inbox: [], inbox_last_id: nil, more_data_available: false, - inbox_count: 0, - delete_id: "ib-delete-all", - disabled: true + inbox_count: 0 } end end From 8b7ba59660e59721d08ac3fa98080e2783815fe7 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Mon, 30 Jan 2023 06:01:01 +0100 Subject: [PATCH 43/74] typoed_email_validator: add new endings to the typo list --- app/validators/typoed_email_validator.rb | 1 + spec/models/user_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/validators/typoed_email_validator.rb b/app/validators/typoed_email_validator.rb index 5cc07cff..e529e1fb 100644 --- a/app/validators/typoed_email_validator.rb +++ b/app/validators/typoed_email_validator.rb @@ -7,6 +7,7 @@ class TypoedEmailValidator < ActiveModel::EachValidator INVALID_ENDINGS = [ # with @: *%w[ + aoo.com fmail.com gail.com gamil.com diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index af65a555..f1f2abdc 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -81,6 +81,7 @@ RSpec.describe User, type: :model do # nor .mail (.email is, however) include_examples "invalid email", "fritz.fantom@proton.mail" # common typos: + include_examples "invalid email", "fritz.fantom@aoo.com" include_examples "invalid email", "fritz.fantom@fmail.com" include_examples "invalid email", "fritz.fantom@gamil.com" include_examples "invalid email", "fritz.fantom@gemail.com" From fa572a6b542516d81ca2066423e6114835e54ad3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:01:28 +0000 Subject: [PATCH 44/74] Bump redcarpet from 3.5.1 to 3.6.0 Bumps [redcarpet](https://github.com/vmg/redcarpet) from 3.5.1 to 3.6.0. - [Release notes](https://github.com/vmg/redcarpet/releases) - [Changelog](https://github.com/vmg/redcarpet/blob/master/CHANGELOG.md) - [Commits](https://github.com/vmg/redcarpet/compare/v3.5.1...v3.6.0) --- updated-dependencies: - dependency-name: redcarpet dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28e75168..83797c0d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -369,7 +369,7 @@ GEM thor (~> 1.0) rainbow (3.1.1) rake (13.0.6) - redcarpet (3.5.1) + redcarpet (3.6.0) redis (4.5.1) regexp_parser (2.6.1) request_store (1.5.1) From c5e87582db2f33a0133ae8bf4e11e53a8e64b352 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:02:11 +0000 Subject: [PATCH 45/74] Bump fog-aws from 3.15.0 to 3.16.0 Bumps [fog-aws](https://github.com/fog/fog-aws) from 3.15.0 to 3.16.0. - [Release notes](https://github.com/fog/fog-aws/releases) - [Changelog](https://github.com/fog/fog-aws/blob/master/CHANGELOG.md) - [Commits](https://github.com/fog/fog-aws/compare/v3.15.0...v3.16.0) --- updated-dependencies: - dependency-name: fog-aws dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28e75168..8bf18bf7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -150,7 +150,7 @@ GEM zeitwerk (~> 2.6) equalizer (0.0.11) erubi (1.12.0) - excon (0.93.1) + excon (0.98.0) factory_bot (6.2.0) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) @@ -165,7 +165,7 @@ GEM ffi-compiler (1.0.1) ffi (>= 1.0.0) rake - fog-aws (3.15.0) + fog-aws (3.16.0) fog-core (~> 2.1) fog-json (~> 1.1) fog-xml (~> 0.1) From 7b1083f5e0e971aa5353b0dadeb8e43c5a478ef9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:02:40 +0000 Subject: [PATCH 46/74] Bump haml_lint from 0.43.0 to 0.45.0 Bumps [haml_lint](https://github.com/sds/haml-lint) from 0.43.0 to 0.45.0. - [Release notes](https://github.com/sds/haml-lint/releases) - [Changelog](https://github.com/sds/haml-lint/blob/main/CHANGELOG.md) - [Commits](https://github.com/sds/haml-lint/compare/v0.43.0...v0.45.0) --- updated-dependencies: - dependency-name: haml_lint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28e75168..cb966b4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -190,7 +190,7 @@ GEM temple (>= 0.8.2) thor tilt - haml_lint (0.43.0) + haml_lint (0.45.0) haml (>= 4.0, < 6.2) parallel (~> 1.10) rainbow @@ -371,7 +371,7 @@ GEM rake (13.0.6) redcarpet (3.5.1) redis (4.5.1) - regexp_parser (2.6.1) + regexp_parser (2.6.2) request_store (1.5.1) rack (>= 1.4) responders (3.0.1) @@ -485,7 +485,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sysexits (1.2.0) - temple (0.9.1) + temple (0.10.0) thor (1.2.1) thread_safe (0.3.6) tilt (2.0.11) From 1432adde8c5fcd9e9e9e71e8ddd078787f790379 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:02:55 +0000 Subject: [PATCH 47/74] Bump esbuild from 0.17.4 to 0.17.5 Bumps [esbuild](https://github.com/evanw/esbuild) from 0.17.4 to 0.17.5. - [Release notes](https://github.com/evanw/esbuild/releases) - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md) - [Commits](https://github.com/evanw/esbuild/compare/v0.17.4...v0.17.5) --- updated-dependencies: - dependency-name: esbuild dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 228 +++++++++++++++++++++++++-------------------------- 2 files changed, 115 insertions(+), 115 deletions(-) diff --git a/package.json b/package.json index d84f6d89..2f4499f2 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "^4.11.0", "@typescript-eslint/parser": "^4.11.0", - "esbuild": "^0.17.4", + "esbuild": "^0.17.5", "eslint": "^7.16.0", "eslint-plugin-import": "^2.27.5", "stylelint": "^14.16.1", diff --git a/yarn.lock b/yarn.lock index 9b5c6a7f..f38e6b8f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -49,115 +49,115 @@ resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-2.0.2.tgz#1bfafe4b7ed0f3e4105837e056e0a89b108ebe36" integrity sha512-IkpVW/ehM1hWKln4fCA3NzJU8KwD+kIOvPZA4cqxoJHtE21CCzjyp+Kxbu0i5I4tBNOlXPL9mjwnWlL0VEG4Fg== -"@esbuild/android-arm64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.4.tgz#0a900a7e448cc038ae5a751255257fc67163ed32" - integrity sha512-91VwDrl4EpxBCiG6h2LZZEkuNvVZYJkv2T9gyLG/mhGG1qrM7i5SwUcg/hlSPnL/4hDT0TFcF35/XMGSn0bemg== +"@esbuild/android-arm64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.5.tgz#a145f43018e639bed94ed637369e2dcdd6bf9ea2" + integrity sha512-KHWkDqYAMmKZjY4RAN1PR96q6UOtfkWlTS8uEwWxdLtkRt/0F/csUhXIrVfaSIFxnscIBMPynGfhsMwQDRIBQw== -"@esbuild/android-arm@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.4.tgz#fe32ce82eb6064d3dc13c0d8ca0e440bbc776c93" - integrity sha512-R9GCe2xl2XDSc2XbQB63mFiFXHIVkOP+ltIxICKXqUPrFX97z6Z7vONCLQM1pSOLGqfLrGi3B7nbhxmFY/fomg== +"@esbuild/android-arm@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.5.tgz#9fa2deff7fc5d180bb4ecff70beea3a95ac44251" + integrity sha512-crmPUzgCmF+qZXfl1YkiFoUta2XAfixR1tEnr/gXIixE+WL8Z0BGqfydP5oox0EUOgQMMRgtATtakyAcClQVqQ== -"@esbuild/android-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.4.tgz#6ae1056f6ecf1963c1d076cf5f0109b52d8049f6" - integrity sha512-mGSqhEPL7029XL7QHNPxPs15JVa02hvZvysUcyMP9UXdGFwncl2WU0bqx+Ysgzd+WAbv8rfNa73QveOxAnAM2w== +"@esbuild/android-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.5.tgz#145fc61f810400e65a56b275280d1422a102c2ef" + integrity sha512-8fI/AnIdmWz/+1iza2WrCw8kwXK9wZp/yZY/iS8ioC+U37yJCeppi9EHY05ewJKN64ASoBIseufZROtcFnX5GA== -"@esbuild/darwin-arm64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.4.tgz#5064d81ee5b8d646a5b7cc3e53c98cb983c4af55" - integrity sha512-tTyJRM9dHvlMPt1KrBFVB5OW1kXOsRNvAPtbzoKazd5RhD5/wKlXk1qR2MpaZRYwf4WDMadt0Pv0GwxB41CVow== +"@esbuild/darwin-arm64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.5.tgz#61fb0546aa4bae0850817d6e0d008b1cb3f64b49" + integrity sha512-EAvaoyIySV6Iif3NQCglUNpnMfHSUgC5ugt2efl3+QDntucJe5spn0udNZjTgNi6tKVqSceOw9tQ32liNZc1Xw== -"@esbuild/darwin-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.4.tgz#67f0213b3333248b32a97a7fc3fee880c2157674" - integrity sha512-phQuC2Imrb3TjOJwLN8EO50nb2FHe8Ew0OwgZDH1SV6asIPGudnwTQtighDF2EAYlXChLoMJwqjAp4vAaACq6w== +"@esbuild/darwin-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.5.tgz#54b770f0c49f524ae9ba24c85d6dea8b521f610d" + integrity sha512-ha7QCJh1fuSwwCgoegfdaljowwWozwTDjBgjD3++WAy/qwee5uUi1gvOg2WENJC6EUyHBOkcd3YmLDYSZ2TPPA== -"@esbuild/freebsd-arm64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.4.tgz#8eaaa126d9ff24822c730f06a71ac2d1091dc1c2" - integrity sha512-oH6JUZkocgmjzzYaP5juERLpJQSwazdjZrTPgLRmAU2bzJ688x0vfMB/WTv4r58RiecdHvXOPC46VtsMy/mepg== +"@esbuild/freebsd-arm64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.5.tgz#be1dd18b7b9411f10bdc362ba8bff16386175367" + integrity sha512-VbdXJkn2aI2pQ/wxNEjEcnEDwPpxt3CWWMFYmO7CcdFBoOsABRy2W8F3kjbF9F/pecEUDcI3b5i2w+By4VQFPg== -"@esbuild/freebsd-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.4.tgz#314eff900a71abf64d4e5bea31e430d8ebd78d79" - integrity sha512-U4iWGn/9TrAfpAdfd56eO0pRxIgb0a8Wj9jClrhT8hvZnOnS4dfMPW7o4fn15D/KqoiVYHRm43jjBaTt3g/2KA== +"@esbuild/freebsd-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.5.tgz#c9c1960fa3e1eada4e5d4be2a11a2f04ce14198f" + integrity sha512-olgGYND1/XnnWxwhjtY3/ryjOG/M4WfcA6XH8dBTH1cxMeBemMODXSFhkw71Kf4TeZFFTN25YOomaNh0vq2iXg== -"@esbuild/linux-arm64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.4.tgz#5bed6bb8eb1d331644f8b31c87b8df57f204e84e" - integrity sha512-UkGfQvYlwOaeYJzZG4cLV0hCASzQZnKNktRXUo3/BMZvdau40AOz9GzmGA063n1piq6VrFFh43apRDQx8hMP2w== +"@esbuild/linux-arm64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.5.tgz#34d96d11c6899017ecae42fb97de8e0c3282902f" + integrity sha512-8a0bqSwu3OlLCfu2FBbDNgQyBYdPJh1B9PvNX7jMaKGC9/KopgHs37t+pQqeMLzcyRqG6z55IGNQAMSlCpBuqg== -"@esbuild/linux-arm@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.4.tgz#6eaa41f37e231d113da715a1d9cc820e5523aeb6" - integrity sha512-S2s9xWTGMTa/fG5EyMGDeL0wrWVgOSQcNddJWgu6rG1NCSXJHs76ZP9AsxjB3f2nZow9fWOyApklIgiTGZKhiw== +"@esbuild/linux-arm@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.5.tgz#86332e6293fd713a54ab299a5e2ed7c60c9e1c07" + integrity sha512-YBdCyQwA3OQupi6W2/WO4FnI+NWFWe79cZEtlbqSESOHEg7a73htBIRiE6uHPQe7Yp5E4aALv+JxkRLGEUL7tw== -"@esbuild/linux-ia32@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.4.tgz#3fc352bb54e0959fda273cd2253b1c72ca41b8c2" - integrity sha512-3lqFi4VFo/Vwvn77FZXeLd0ctolIJH/uXkH3yNgEk89Eh6D3XXAC9/iTPEzeEpsNE5IqGIsFa5Z0iPeOh25IyA== +"@esbuild/linux-ia32@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.5.tgz#7bd9185c844e7dfce6a01dfdec584e115602a8c4" + integrity sha512-uCwm1r/+NdP7vndctgq3PoZrnmhmnecWAr114GWMRwg2QMFFX+kIWnp7IO220/JLgnXK/jP7VKAFBGmeOYBQYQ== -"@esbuild/linux-loong64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.4.tgz#86d54f690be53669cd2a38a5333ecf2608c11189" - integrity sha512-HqpWZkVslDHIwdQ9D+gk7NuAulgQvRxF9no54ut/M55KEb3mi7sQS3GwpPJzSyzzP0UkjQVN7/tbk88/CaX4EQ== +"@esbuild/linux-loong64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.5.tgz#2907d4120c7b3642b96be6014f77e7624c378eea" + integrity sha512-3YxhSBl5Sb6TtBjJu+HP93poBruFzgXmf3PVfIe4xOXMj1XpxboYZyw3W8BhoX/uwxzZz4K1I99jTE/5cgDT1g== -"@esbuild/linux-mips64el@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.4.tgz#3dbd897bd8f047fef35e69bd253b8f07ca7fe483" - integrity sha512-d/nMCKKh/SVDbqR9ju+b78vOr0tNXtfBjcp5vfHONCCOAL9ad8gN9dC/u+UnH939pz7wO+0u/x9y1MaZcb/lKA== +"@esbuild/linux-mips64el@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.5.tgz#fc98be741e8080ecd13b404d5fca5302d3835bf4" + integrity sha512-Hy5Z0YVWyYHdtQ5mfmfp8LdhVwGbwVuq8mHzLqrG16BaMgEmit2xKO+iDakHs+OetEx0EN/2mUzDdfdktI+Nmg== -"@esbuild/linux-ppc64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.4.tgz#defaff6db9a60f08936fc0c59e0eabfb1055968a" - integrity sha512-lOD9p2dmjZcNiTU+sGe9Nn6G3aYw3k0HBJies1PU0j5IGfp6tdKOQ6mzfACRFCqXjnBuTqK7eTYpwx09O5LLfg== +"@esbuild/linux-ppc64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.5.tgz#ea12e8f6b290a613ac4903c9e00835c69ced065c" + integrity sha512-5dbQvBLbU/Y3Q4ABc9gi23hww1mQcM7KZ9KBqabB7qhJswYMf8WrDDOSw3gdf3p+ffmijMd28mfVMvFucuECyg== -"@esbuild/linux-riscv64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.4.tgz#270a09f6f4205a8a8c8ed3c7dbabdcebaafa8a84" - integrity sha512-mTGnwWwVshAjGsd8rP+K6583cPDgxOunsqqldEYij7T5/ysluMHKqUIT4TJHfrDFadUwrghAL6QjER4FeqQXoA== +"@esbuild/linux-riscv64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.5.tgz#ce47b15fd4227eeb0590826e41bdc430c5bfd06c" + integrity sha512-fp/KUB/ZPzEWGTEUgz9wIAKCqu7CjH1GqXUO2WJdik1UNBQ7Xzw7myIajpxztE4Csb9504ERiFMxZg5KZ6HlZQ== -"@esbuild/linux-s390x@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.4.tgz#197695bece68f514dcdcc286562b5d48c5dad5f9" - integrity sha512-AQYuUGp50XM29/N/dehADxvc2bUqDcoqrVuijop1Wv72SyxT6dDB9wjUxuPZm2HwIM876UoNNBMVd+iX/UTKVQ== +"@esbuild/linux-s390x@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.5.tgz#962fa540d7498967270eb1d4b9ac6c4a4f339735" + integrity sha512-kRV3yw19YDqHTp8SfHXfObUFXlaiiw4o2lvT1XjsPZ++22GqZwSsYWJLjMi1Sl7j9qDlDUduWDze/nQx0d6Lzw== -"@esbuild/linux-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.4.tgz#db50cdfb071c0d367025c1c98563aab1318f800e" - integrity sha512-+AsFBwKgQuhV2shfGgA9YloxLDVjXgUEWZum7glR5lLmV94IThu/u2JZGxTgjYby6kyXEx8lKOqP5rTEVBR0Rw== +"@esbuild/linux-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.5.tgz#9fa52884c3d876593a522aa1d4df43b717907050" + integrity sha512-vnxuhh9e4pbtABNLbT2ANW4uwQ/zvcHRCm1JxaYkzSehugoFd5iXyC4ci1nhXU13mxEwCnrnTIiiSGwa/uAF1g== -"@esbuild/netbsd-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.4.tgz#e4d5d8022f8eddbd7d9899d58265915444f46f3b" - integrity sha512-zD1TKYX9553OiLS/qkXPMlWoELYkH/VkzRYNKEU+GwFiqkq0SuxsKnsCg5UCdxN3cqd+1KZ8SS3R+WG/Hxy2jQ== +"@esbuild/netbsd-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.5.tgz#47bb187b86aad9622051cb80c27e439b7d9e3a9a" + integrity sha512-cigBpdiSx/vPy7doUyImsQQBnBjV5f1M99ZUlaJckDAJjgXWl6y9W17FIfJTy8TxosEF6MXq+fpLsitMGts2nA== -"@esbuild/openbsd-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.4.tgz#9b770e1e7745824cbe155f5a742fc781855a7e68" - integrity sha512-PY1NjEsLRhPEFFg1AV0/4Or/gR+q2dOb9s5rXcPuCjyHRzbt8vnHJl3vYj+641TgWZzTFmSUnZbzs1zwTzjeqw== +"@esbuild/openbsd-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.5.tgz#abc55c35a1ed2bc3c5ede2ef50a3b2f87395009a" + integrity sha512-VdqRqPVIjjZfkf40LrqOaVuhw9EQiAZ/GNCSM2UplDkaIzYVsSnycxcFfAnHdWI8Gyt6dO15KHikbpxwx+xHbw== -"@esbuild/sunos-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.4.tgz#4c6d2290f8bf39ab9284f5a1b9a2210858e2d6e6" - integrity sha512-B3Z7s8QZQW9tKGleMRXvVmwwLPAUoDCHs4WZ2ElVMWiortLJFowU1NjAhXOKjDgC7o9ByeVcwyOlJ+F2r6ZgmQ== +"@esbuild/sunos-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.5.tgz#b83c080a2147662599a5d18b2ff47f07c93e03a0" + integrity sha512-ItxPaJ3MBLtI4nK+mALLEoUs6amxsx+J1ibnfcYMkqaCqHST1AkF4aENpBehty3czqw64r/XqL+W9WqU6kc2Qw== -"@esbuild/win32-arm64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.4.tgz#424954b6d598f40e2c5a0d85e3af07147fb41909" - integrity sha512-0HCu8R3mY/H5V7N6kdlsJkvrT591bO/oRZy8ztF1dhgNU5xD5tAh5bKByT1UjTGjp/VVBsl1PDQ3L18SfvtnBQ== +"@esbuild/win32-arm64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.5.tgz#2a4c41f427d9cf25b75f9d61493711a482106850" + integrity sha512-4u2Q6qsJTYNFdS9zHoAi80spzf78C16m2wla4eJPh4kSbRv+BpXIfl6TmBSWupD8e47B1NrTfrOlEuco7mYQtg== -"@esbuild/win32-ia32@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.4.tgz#2c94e9c3a82c779d3f07b3fb5c482a2e3fecedb1" - integrity sha512-VUjhVDQycse1gLbe06pC/uaA0M+piQXJpdpNdhg8sPmeIZZqu5xPoGWVCmcsOO2gaM2cywuTYTHkXRozo3/Nkg== +"@esbuild/win32-ia32@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.5.tgz#7c14e3250725d0e2c21f89c98eb6abb520cba0e0" + integrity sha512-KYlm+Xu9TXsfTWAcocLuISRtqxKp/Y9ZBVg6CEEj0O5J9mn7YvBKzAszo2j1ndyzUPk+op+Tie2PJeN+BnXGqQ== -"@esbuild/win32-x64@0.17.4": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.4.tgz#9b7760cdc77678bdbc5b582fae2cf3de449df048" - integrity sha512-0kLAjs+xN5OjhTt/aUA6t48SfENSCKgGPfExADYTOo/UCn0ivxos9/anUVeSfg+L+2O9xkFxvJXIJfG+Q4sYSg== +"@esbuild/win32-x64@0.17.5": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.5.tgz#a8f3d26d8afc5186eccda265ceb1820b8e8830be" + integrity sha512-XgA9qWRqby7xdYXuF6KALsn37QGBMHsdhmnpjfZtYxKxbTOwfnDM6MYi2WuUku5poNaX2n9XGVr20zgT/2QwCw== "@eslint/eslintrc@^0.4.3": version "0.4.3" @@ -835,33 +835,33 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" -esbuild@^0.17.4: - version "0.17.4" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.4.tgz#af4f8f78604c67f8e6afbdee36a3f4211ecfc859" - integrity sha512-zBn9MeCwT7W5F1a3lXClD61ip6vQM+H8Msb0w8zMT4ZKBpDg+rFAraNyWCDelB/2L6M3g6AXHPnsyvjMFnxtFw== +esbuild@^0.17.5: + version "0.17.5" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.5.tgz#cd76d75700d49ac050ad9eedfbed777bd6a9d930" + integrity sha512-Bu6WLCc9NMsNoMJUjGl3yBzTjVLXdysMltxQWiLAypP+/vQrf+3L1Xe8fCXzxaECus2cEJ9M7pk4yKatEwQMqQ== optionalDependencies: - "@esbuild/android-arm" "0.17.4" - "@esbuild/android-arm64" "0.17.4" - "@esbuild/android-x64" "0.17.4" - "@esbuild/darwin-arm64" "0.17.4" - "@esbuild/darwin-x64" "0.17.4" - "@esbuild/freebsd-arm64" "0.17.4" - "@esbuild/freebsd-x64" "0.17.4" - "@esbuild/linux-arm" "0.17.4" - "@esbuild/linux-arm64" "0.17.4" - "@esbuild/linux-ia32" "0.17.4" - "@esbuild/linux-loong64" "0.17.4" - "@esbuild/linux-mips64el" "0.17.4" - "@esbuild/linux-ppc64" "0.17.4" - "@esbuild/linux-riscv64" "0.17.4" - "@esbuild/linux-s390x" "0.17.4" - "@esbuild/linux-x64" "0.17.4" - "@esbuild/netbsd-x64" "0.17.4" - "@esbuild/openbsd-x64" "0.17.4" - "@esbuild/sunos-x64" "0.17.4" - "@esbuild/win32-arm64" "0.17.4" - "@esbuild/win32-ia32" "0.17.4" - "@esbuild/win32-x64" "0.17.4" + "@esbuild/android-arm" "0.17.5" + "@esbuild/android-arm64" "0.17.5" + "@esbuild/android-x64" "0.17.5" + "@esbuild/darwin-arm64" "0.17.5" + "@esbuild/darwin-x64" "0.17.5" + "@esbuild/freebsd-arm64" "0.17.5" + "@esbuild/freebsd-x64" "0.17.5" + "@esbuild/linux-arm" "0.17.5" + "@esbuild/linux-arm64" "0.17.5" + "@esbuild/linux-ia32" "0.17.5" + "@esbuild/linux-loong64" "0.17.5" + "@esbuild/linux-mips64el" "0.17.5" + "@esbuild/linux-ppc64" "0.17.5" + "@esbuild/linux-riscv64" "0.17.5" + "@esbuild/linux-s390x" "0.17.5" + "@esbuild/linux-x64" "0.17.5" + "@esbuild/netbsd-x64" "0.17.5" + "@esbuild/openbsd-x64" "0.17.5" + "@esbuild/sunos-x64" "0.17.5" + "@esbuild/win32-arm64" "0.17.5" + "@esbuild/win32-ia32" "0.17.5" + "@esbuild/win32-x64" "0.17.5" escape-string-regexp@^1.0.5: version "1.0.5" From 6bfb6049eb446661b103c5afdf7dedfc8a129b09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:04:10 +0000 Subject: [PATCH 48/74] Bump rubocop from 1.43.0 to 1.44.1 Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.43.0 to 1.44.1. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.43.0...v1.44.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 54f40638..5cf81104 100644 --- a/Gemfile +++ b/Gemfile @@ -97,7 +97,7 @@ group :development, :test do gem "rspec-mocks" gem "rspec-rails", "~> 6.0" gem "rspec-sidekiq", "~> 3.0", require: false - gem "rubocop", "~> 1.43" + gem "rubocop", "~> 1.44" gem "rubocop-rails", "~> 2.17" gem "shoulda-matchers", "~> 5.3" gem "simplecov", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 28e75168..90542604 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -371,7 +371,7 @@ GEM rake (13.0.6) redcarpet (3.5.1) redis (4.5.1) - regexp_parser (2.6.1) + regexp_parser (2.6.2) request_store (1.5.1) rack (>= 1.4) responders (3.0.1) @@ -417,7 +417,7 @@ GEM rspec-core (~> 3.0, >= 3.0.0) sidekiq (>= 2.4.0) rspec-support (3.12.0) - rubocop (1.43.0) + rubocop (1.44.1) json (~> 2.3) parallel (~> 1.10) parser (>= 3.2.0.0) @@ -594,7 +594,7 @@ DEPENDENCIES rspec-mocks rspec-rails (~> 6.0) rspec-sidekiq (~> 3.0) - rubocop (~> 1.43) + rubocop (~> 1.44) rubocop-rails (~> 2.17) ruby-progressbar rubyzip (~> 2.3) From d72966fcec7a3b3b281477e5a610554f6544ced1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:23:09 +0000 Subject: [PATCH 49/74] Bump rails from 6.1.7.1 to 6.1.7.2 Bumps [rails](https://github.com/rails/rails) from 6.1.7.1 to 6.1.7.2. - [Release notes](https://github.com/rails/rails/releases) - [Commits](https://github.com/rails/rails/compare/v6.1.7.1...v6.1.7.2) --- updated-dependencies: - dependency-name: rails dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 112 +++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9928dc90..92850db1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,40 +9,40 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.1) - actionpack (= 6.1.7.1) - activesupport (= 6.1.7.1) + actioncable (6.1.7.2) + actionpack (= 6.1.7.2) + activesupport (= 6.1.7.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.1) - actionpack (= 6.1.7.1) - activejob (= 6.1.7.1) - activerecord (= 6.1.7.1) - activestorage (= 6.1.7.1) - activesupport (= 6.1.7.1) + actionmailbox (6.1.7.2) + actionpack (= 6.1.7.2) + activejob (= 6.1.7.2) + activerecord (= 6.1.7.2) + activestorage (= 6.1.7.2) + activesupport (= 6.1.7.2) mail (>= 2.7.1) - actionmailer (6.1.7.1) - actionpack (= 6.1.7.1) - actionview (= 6.1.7.1) - activejob (= 6.1.7.1) - activesupport (= 6.1.7.1) + actionmailer (6.1.7.2) + actionpack (= 6.1.7.2) + actionview (= 6.1.7.2) + activejob (= 6.1.7.2) + activesupport (= 6.1.7.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.1) - actionview (= 6.1.7.1) - activesupport (= 6.1.7.1) + actionpack (6.1.7.2) + actionview (= 6.1.7.2) + activesupport (= 6.1.7.2) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.1) - actionpack (= 6.1.7.1) - activerecord (= 6.1.7.1) - activestorage (= 6.1.7.1) - activesupport (= 6.1.7.1) + actiontext (6.1.7.2) + actionpack (= 6.1.7.2) + activerecord (= 6.1.7.2) + activestorage (= 6.1.7.2) + activesupport (= 6.1.7.2) nokogiri (>= 1.8.5) - actionview (6.1.7.1) - activesupport (= 6.1.7.1) + actionview (6.1.7.2) + activesupport (= 6.1.7.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -50,26 +50,26 @@ GEM active_model_otp (2.3.1) activemodel rotp (~> 6.2.0) - activejob (6.1.7.1) - activesupport (= 6.1.7.1) + activejob (6.1.7.2) + activesupport (= 6.1.7.2) globalid (>= 0.3.6) - activemodel (6.1.7.1) - activesupport (= 6.1.7.1) + activemodel (6.1.7.2) + activesupport (= 6.1.7.2) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.1.7.1) - activemodel (= 6.1.7.1) - activesupport (= 6.1.7.1) - activestorage (6.1.7.1) - actionpack (= 6.1.7.1) - activejob (= 6.1.7.1) - activerecord (= 6.1.7.1) - activesupport (= 6.1.7.1) + activerecord (6.1.7.2) + activemodel (= 6.1.7.2) + activesupport (= 6.1.7.2) + activestorage (6.1.7.2) + actionpack (= 6.1.7.2) + activejob (= 6.1.7.2) + activerecord (= 6.1.7.2) + activesupport (= 6.1.7.2) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.1) + activesupport (6.1.7.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -105,7 +105,7 @@ GEM chunky_png (1.4.0) coderay (1.1.3) colorize (0.8.1) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.0) connection_pool (2.2.5) crass (1.0.6) cssbundling-rails (1.1.2) @@ -184,7 +184,7 @@ GEM nokogiri (>= 1.5.11, < 2.0.0) formatador (1.1.0) glob (0.3.1) - globalid (1.0.1) + globalid (1.1.0) activesupport (>= 5.0) haml (6.1.1) temple (>= 0.8.2) @@ -328,20 +328,20 @@ GEM rack rack-test (2.0.2) rack (>= 1.3) - rails (6.1.7.1) - actioncable (= 6.1.7.1) - actionmailbox (= 6.1.7.1) - actionmailer (= 6.1.7.1) - actionpack (= 6.1.7.1) - actiontext (= 6.1.7.1) - actionview (= 6.1.7.1) - activejob (= 6.1.7.1) - activemodel (= 6.1.7.1) - activerecord (= 6.1.7.1) - activestorage (= 6.1.7.1) - activesupport (= 6.1.7.1) + rails (6.1.7.2) + actioncable (= 6.1.7.2) + actionmailbox (= 6.1.7.2) + actionmailer (= 6.1.7.2) + actionpack (= 6.1.7.2) + actiontext (= 6.1.7.2) + actionview (= 6.1.7.2) + activejob (= 6.1.7.2) + activemodel (= 6.1.7.2) + activerecord (= 6.1.7.2) + activestorage (= 6.1.7.2) + activesupport (= 6.1.7.2) bundler (>= 1.15.0) - railties (= 6.1.7.1) + railties (= 6.1.7.2) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -361,9 +361,9 @@ GEM nested_form (~> 0.3) rails (>= 6.0, < 8) turbo-rails (~> 1.0) - railties (6.1.7.1) - actionpack (= 6.1.7.1) - activesupport (= 6.1.7.1) + railties (6.1.7.2) + actionpack (= 6.1.7.2) + activesupport (= 6.1.7.2) method_source rake (>= 12.2) thor (~> 1.0) @@ -511,7 +511,7 @@ GEM twitter-text (3.1.0) idn-ruby unf (~> 0.1.0) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext From e723fe3d6877db5080354d5d7272f1afd46757f6 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Mon, 30 Jan 2023 17:34:17 +0100 Subject: [PATCH 50/74] fix image in 502 page --- public/502.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/502.html b/public/502.html index 4a8f344a..65e51797 100644 --- a/public/502.html +++ b/public/502.html @@ -74,7 +74,7 @@

This page takes way too long to load!

- Unicorn + Unicorn

Sorry about that. Please try refreshing and contact us if the problem persists.

From e5f0c2f61a5e83d65ef36285c76be88490273692 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 30 Jan 2023 22:07:09 +0100 Subject: [PATCH 51/74] Add issue templates --- .github/ISSUE_TEMPLATE/01-bug_report.yml | 55 +++++++++++++++++++ .github/ISSUE_TEMPLATE/02-feature_request.yml | 20 +++++++ .github/ISSUE_TEMPLATE/config.yml | 5 ++ 3 files changed, 80 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/01-bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/02-feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/01-bug_report.yml b/.github/ISSUE_TEMPLATE/01-bug_report.yml new file mode 100644 index 00000000..777e5a6a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/01-bug_report.yml @@ -0,0 +1,55 @@ +name: Bug Report +description: If something isn't working as expected +labels: [bug] +body: + - type: markdown + attributes: + value: | + Before opening an issue, make sure to check if the issue was not previously reported or fixed. + - type: textarea + attributes: + label: Steps to reproduce the problem + description: What were you trying to do? + value: | + 1. + 2. + 3. + ... + validations: + required: true + - type: textarea + attributes: + label: Expected behaviour + description: What should have happened? + validations: + required: true + - type: textarea + attributes: + label: Actual behaviour + description: What happened? + validations: + required: true + - type: textarea + attributes: + label: Detailed description + validations: + required: false + - type: textarea + attributes: + label: Specifications + description: | + If you host Retrospring, what version/commit hash of Retrospring did this issue occur in? + + If a front-end issue, what browser and operating systems were you using? + placeholder: | + Retrospring 1970.0101.0 + Ruby 3.1.3 + Node.js 18.13.0 + + Google Chrome 112 + Firefox 109.0 + Internet Explorer 11 + + etc... + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/02-feature_request.yml b/.github/ISSUE_TEMPLATE/02-feature_request.yml new file mode 100644 index 00000000..c4ad2a3f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/02-feature_request.yml @@ -0,0 +1,20 @@ +name: Feature Request +description: If you have a suggestion +labels: [suggestion] +body: + - type: markdown + attributes: + value: | + Please use a concise and distinct title for the issue. + - type: textarea + attributes: + label: Pitch + description: Describe your idea for a feature. Make sure it has not already been suggested/implemented/turned down before. + validations: + required: true + - type: textarea + attributes: + label: Motivation + description: Why do you think this feature is needed? Who would benefit from it? + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..2d671adb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: GitHub Discussions + url: https://github.com/retrospring/retrospring/discussions + about: Please ask and answer questions here. From d991188c195dec6e29d3e3dc76c74ce6eb79acd7 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 30 Jan 2023 22:07:36 +0100 Subject: [PATCH 52/74] Add security policy --- SECURITY.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..0bef6de2 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +If you believe you've found a security vulnerability in Retrospring (a bug that allows something to happen that shouldn't be possible), you can reach us at . + +You should *not* report such issues on GitHub or in other public spaces to give us time to publish a fix for the issue without exposing Retrospring's users to increased risk. + +## Scope + +A "vulnerability in Retrospring" is a vulnerability in the code distributed through our main source code repository on GitHub. Vulnerabilities that are specific to a given installation (e.g. misconfiguration) should be reported to the owner of that installation and not us. + +## Supported Versions + +As long as Retrospring is in rapid development pace the currently supported version for security issues is always the [latest tagged release](https://github.com/Retrospring/retrospring/releases/latest). From 87aac34f16acfc8a2e7a9cae425d83c3188af307 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 31 Jan 2023 08:28:08 +0100 Subject: [PATCH 53/74] Move raised content theming section below general --- app/views/settings/theme/edit.html.haml | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/views/settings/theme/edit.html.haml b/app/views/settings/theme/edit.html.haml index cd1c5132..a5064c23 100644 --- a/app/views/settings/theme/edit.html.haml +++ b/app/views/settings/theme/edit.html.haml @@ -21,6 +21,23 @@ = f.text_field :background_color, class: "color", data: { default: 0xF0EDF4, theme_target: "color", action: "theme#updatePreview" } .col-sm-6 = f.text_field :body_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" } + .card + .card-body + %h2= t(".raised.heading") + %p= t(".raised.body") + + .row + .col-sm-6 + = f.text_field :raised_background, class: "color", data: { default: 0xFFFFFF, theme_target: "color", action: "theme#updatePreview" } + .col-sm-6 + = f.text_field :raised_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" } + .row + .col-sm-6 + = f.text_field :raised_accent, class: "color", data: { default: 0xF7F7F7, theme_target: "color", action: "theme#updatePreview" } + .col-sm-6 + = f.text_field :raised_accent_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" } + .card-footer + %p= t(".raised.accent.example") .card .card-body %h2= t(".colors.heading") @@ -98,23 +115,6 @@ .form-group %label.form-label Example Input %input.form-control{ placeholder: "A test placeholder" } - .card - .card-body - %h2= t(".raised.heading") - %p= t(".raised.body") - - .row - .col-sm-6 - = f.text_field :raised_background, class: "color", data: { default: 0xFFFFFF, theme_target: "color", action: "theme#updatePreview" } - .col-sm-6 - = f.text_field :raised_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" } - .row - .col-sm-6 - = f.text_field :raised_accent, class: "color", data: { default: 0xF7F7F7, theme_target: "color", action: "theme#updatePreview" } - .col-sm-6 - = f.text_field :raised_accent_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" } - .card-footer - %p= t(".raised.accent.example") .card .card-body .pull-left From 1b6eafd2d106d64cf64e2bdc8ac5d36bc675e925 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 12:25:55 +0100 Subject: [PATCH 54/74] =?UTF-8?q?Prevent=20=F0=9D=91=9B+1=20on=20follower/?= =?UTF-8?q?following=20lists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/user_controller.rb | 12 ++++++++++++ app/views/user/_actions.html.haml | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index ad94a2d1..b9e8e59c 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -21,6 +21,7 @@ class UserController < ApplicationController @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero? @users = @relationships.map(&:source) + find_own_relationships respond_to do |format| format.html { render "show_follow", locals: { type: :follower } } @@ -33,6 +34,7 @@ class UserController < ApplicationController @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero? @users = @relationships.map(&:target) + find_own_relationships respond_to do |format| format.html { render "show_follow", locals: { type: :friend } } @@ -69,6 +71,16 @@ class UserController < ApplicationController @user = User.where("LOWER(screen_name) = ?", params[:username].downcase).includes(:profile).first! end + # Checks which of the displayed users are followed or blocked by the current user + # + # This prevents 𝑛+1 queries. + def find_own_relationships + return unless user_signed_in? + + @own_followings = current_user.active_follow_relationships.where(target_id: @users.map(&:id)).select(:target_id).map(&:target_id) + @own_blocks = current_user.active_block_relationships.where(target_id: @users.map(&:id)).select(:target_id).map(&:target_id) + end + def hidden_social_graph_redirect return if belongs_to_current_user? || !@user.privacy_hide_social_graph diff --git a/app/views/user/_actions.html.haml b/app/views/user/_actions.html.haml index 909efe22..157e7a6d 100644 --- a/app/views/user/_actions.html.haml +++ b/app/views/user/_actions.html.haml @@ -5,7 +5,7 @@ %a.btn.btn-dark{ href: settings_profile_path } Edit profile - elsif user_signed_in? .d-grid.gap-2 - - if current_user.following? user + - if @own_followings.include?(user.id) %button.btn.btn-primary{ type: :button, name: 'user-action', data: { action: :unfollow, type: type, target: user.screen_name } } = t("voc.unfollow") - else @@ -19,7 +19,7 @@ %a.dropdown-item.d-block.d-sm-none{ href: '#', data: { bs_target: '#modal-list-memberships', bs_toggle: :modal } } %i.fa.fa-list.fa-fw = t(".list") - - if current_user.blocking?(user) + - if @own_blocks.include?(user.id) %a.dropdown-item{ href: '#', data: { action: :unblock, target: user.screen_name } } %i.fa.fa-minus-circle.fa-fw %span.pe-none= t("voc.unblock") From 51e15ef195d0ca23db15a0e877c3e2ca33054872 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 12:30:58 +0100 Subject: [PATCH 55/74] Appease the dog overlords --- app/views/user/_actions.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/user/_actions.html.haml b/app/views/user/_actions.html.haml index 157e7a6d..1a8354ed 100644 --- a/app/views/user/_actions.html.haml +++ b/app/views/user/_actions.html.haml @@ -5,7 +5,7 @@ %a.btn.btn-dark{ href: settings_profile_path } Edit profile - elsif user_signed_in? .d-grid.gap-2 - - if @own_followings.include?(user.id) + - if @own_followings.include? user.id %button.btn.btn-primary{ type: :button, name: 'user-action', data: { action: :unfollow, type: type, target: user.screen_name } } = t("voc.unfollow") - else @@ -19,7 +19,7 @@ %a.dropdown-item.d-block.d-sm-none{ href: '#', data: { bs_target: '#modal-list-memberships', bs_toggle: :modal } } %i.fa.fa-list.fa-fw = t(".list") - - if @own_blocks.include?(user.id) + - if @own_blocks.include? user.id %a.dropdown-item{ href: '#', data: { action: :unblock, target: user.screen_name } } %i.fa.fa-minus-circle.fa-fw %span.pe-none= t("voc.unblock") From 83eeabb5258a36d7c3e24c2f500d60e9ca34f9d7 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 13:46:09 +0100 Subject: [PATCH 56/74] Use locals for own relationships --- app/controllers/user_controller.rb | 24 +++++++++----------- app/views/shared/_userbox.html.haml | 2 +- app/views/user/_actions.html.haml | 6 +++-- app/views/user/show_follow.html.haml | 2 +- app/views/user/show_follow.turbo_stream.haml | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index b9e8e59c..e4c0f059 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -21,11 +21,12 @@ class UserController < ApplicationController @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero? @users = @relationships.map(&:source) - find_own_relationships + own_followings = find_own_relationships(current_user&.active_follow_relationships) + own_blocks = find_own_relationships(current_user&.active_block_relationships) respond_to do |format| - format.html { render "show_follow", locals: { type: :follower } } - format.turbo_stream { render "show_follow", locals: { type: :follower } } + format.html { render "show_follow", locals: { type: :follower, own_followings:, own_blocks: } } + format.turbo_stream { render "show_follow", locals: { type: :follower, own_followings:, own_blocks: } } end end @@ -34,11 +35,12 @@ class UserController < ApplicationController @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero? @users = @relationships.map(&:target) - find_own_relationships + own_followings = find_own_relationships(current_user&.active_follow_relationships) + own_blocks = find_own_relationships(current_user&.active_block_relationships) respond_to do |format| - format.html { render "show_follow", locals: { type: :friend } } - format.turbo_stream { render "show_follow", locals: { type: :friend } } + format.html { render "show_follow", locals: { type: :friend, own_followings:, own_blocks: } } + format.turbo_stream { render "show_follow", locals: { type: :friend, own_followings:, own_blocks: } } end end @@ -71,14 +73,10 @@ class UserController < ApplicationController @user = User.where("LOWER(screen_name) = ?", params[:username].downcase).includes(:profile).first! end - # Checks which of the displayed users are followed or blocked by the current user - # - # This prevents 𝑛+1 queries. - def find_own_relationships - return unless user_signed_in? + def find_own_relationships(relationships) + return nil if relationships.nil? - @own_followings = current_user.active_follow_relationships.where(target_id: @users.map(&:id)).select(:target_id).map(&:target_id) - @own_blocks = current_user.active_block_relationships.where(target_id: @users.map(&:id)).select(:target_id).map(&:target_id) + relationships.where(target_id: @users.map(&:id))&.select(:target_id)&.map(&:target_id) end def hidden_social_graph_redirect diff --git a/app/views/shared/_userbox.html.haml b/app/views/shared/_userbox.html.haml index e3ce5116..d346dd69 100644 --- a/app/views/shared/_userbox.html.haml +++ b/app/views/shared/_userbox.html.haml @@ -9,4 +9,4 @@ = user.profile.display_name .profile__screen-name = user.screen_name - = render 'user/actions', user: user, type: type + = render "user/actions", user:, type:, own_followings:, own_blocks: diff --git a/app/views/user/_actions.html.haml b/app/views/user/_actions.html.haml index 1a8354ed..d37205e8 100644 --- a/app/views/user/_actions.html.haml +++ b/app/views/user/_actions.html.haml @@ -1,11 +1,13 @@ .profile__actions - type ||= :nil + - own_followings ||= nil + - own_blocks ||= nil - if user_signed_in? && user == current_user .d-grid %a.btn.btn-dark{ href: settings_profile_path } Edit profile - elsif user_signed_in? .d-grid.gap-2 - - if @own_followings.include? user.id + - if own_followings&.include? user.id || current_user.following?(user) %button.btn.btn-primary{ type: :button, name: 'user-action', data: { action: :unfollow, type: type, target: user.screen_name } } = t("voc.unfollow") - else @@ -19,7 +21,7 @@ %a.dropdown-item.d-block.d-sm-none{ href: '#', data: { bs_target: '#modal-list-memberships', bs_toggle: :modal } } %i.fa.fa-list.fa-fw = t(".list") - - if @own_blocks.include? user.id + - if own_blocks&.include? user.id || current_user.blocking?(user) %a.dropdown-item{ href: '#', data: { action: :unblock, target: user.screen_name } } %i.fa.fa-minus-circle.fa-fw %span.pe-none= t("voc.unblock") diff --git a/app/views/user/show_follow.html.haml b/app/views/user/show_follow.html.haml index 364d5dcf..890698ca 100644 --- a/app/views/user/show_follow.html.haml +++ b/app/views/user/show_follow.html.haml @@ -1,7 +1,7 @@ .row.row-cols-1.row-cols-sm-2.row-cols-md-3#users - @users.each do |user| .col.pb-3 - = render "shared/userbox", user:, type: + = render "shared/userbox", user:, type:, own_followings:, own_blocks: - if @more_data_available .d-flex.justify-content-center.justify-content-sm-start#paginator diff --git a/app/views/user/show_follow.turbo_stream.haml b/app/views/user/show_follow.turbo_stream.haml index 7719340e..b0c52a2a 100644 --- a/app/views/user/show_follow.turbo_stream.haml +++ b/app/views/user/show_follow.turbo_stream.haml @@ -1,7 +1,7 @@ = turbo_stream.append "users" do - @users.each do |user| .col.pb-3 - = render "shared/userbox", user:, type: + = render "shared/userbox", user:, type:, own_followings:, own_blocks: = turbo_stream.update "paginator" do - if @more_data_available From 8520dbc4b9b4373698a09ade91246df660156efb Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 13:59:05 +0100 Subject: [PATCH 57/74] De-duplicate relationship pagination logic --- app/controllers/user_controller.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index e4c0f059..25c05efe 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -17,9 +17,7 @@ class UserController < ApplicationController end def followers - @relationships = @user.cursored_follower_relationships(last_id: params[:last_id]) - @relationships_last_id = @relationships.map(&:id).min - @more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero? + paginate_relationships(:cursored_follower_relationships) @users = @relationships.map(&:source) own_followings = find_own_relationships(current_user&.active_follow_relationships) own_blocks = find_own_relationships(current_user&.active_block_relationships) @@ -31,9 +29,7 @@ class UserController < ApplicationController end def followings - @relationships = @user.cursored_following_relationships(last_id: params[:last_id]) - @relationships_last_id = @relationships.map(&:id).min - @more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero? + paginate_relationships(:cursored_following_relationships) @users = @relationships.map(&:target) own_followings = find_own_relationships(current_user&.active_follow_relationships) own_blocks = find_own_relationships(current_user&.active_block_relationships) @@ -79,6 +75,12 @@ class UserController < ApplicationController relationships.where(target_id: @users.map(&:id))&.select(:target_id)&.map(&:target_id) end + def paginate_relationships(method) + @relationships = @user.public_send(method, last_id: params[:last_id]) + @relationships_last_id = @relationships.map(&:id).min + @more_data_available = !@user.public_send(method, last_id: @relationships_last_id, size: 1).count.zero? + end + def hidden_social_graph_redirect return if belongs_to_current_user? || !@user.privacy_hide_social_graph From 226cd10fbccb1153f2cb2d0308f9cb7aaa93a9f2 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 14:01:21 +0100 Subject: [PATCH 58/74] Appease the dog overlords --- app/views/user/_actions.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/user/_actions.html.haml b/app/views/user/_actions.html.haml index d37205e8..0eae948f 100644 --- a/app/views/user/_actions.html.haml +++ b/app/views/user/_actions.html.haml @@ -7,7 +7,7 @@ %a.btn.btn-dark{ href: settings_profile_path } Edit profile - elsif user_signed_in? .d-grid.gap-2 - - if own_followings&.include? user.id || current_user.following?(user) + - if own_followings&.include?(user.id) || current_user.following?(user) %button.btn.btn-primary{ type: :button, name: 'user-action', data: { action: :unfollow, type: type, target: user.screen_name } } = t("voc.unfollow") - else @@ -21,7 +21,7 @@ %a.dropdown-item.d-block.d-sm-none{ href: '#', data: { bs_target: '#modal-list-memberships', bs_toggle: :modal } } %i.fa.fa-list.fa-fw = t(".list") - - if own_blocks&.include? user.id || current_user.blocking?(user) + - if own_blocks&.include?(user.id) || current_user.blocking?(user) %a.dropdown-item{ href: '#', data: { action: :unblock, target: user.screen_name } } %i.fa.fa-minus-circle.fa-fw %span.pe-none= t("voc.unblock") From 18a150b969a5a8e92167af8c53b4d48d5dcda4e8 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 31 Jan 2023 14:27:25 +0100 Subject: [PATCH 59/74] update Sidekiq to 6 --- Gemfile | 2 +- Gemfile.lock | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 5cf81104..ded0bcba 100644 --- a/Gemfile +++ b/Gemfile @@ -50,7 +50,7 @@ gem "sentry-rails" gem "sentry-ruby" gem "sentry-sidekiq" -gem "sidekiq", "< 6" # remove version constraint once we have redis 5 +gem "sidekiq", "< 7" # remove version constraint once are ready to upgrade https://github.com/mperham/sidekiq/blob/main/docs/7.0-Upgrade.md gem "questiongenerator", "~> 1.0" diff --git a/Gemfile.lock b/Gemfile.lock index 92850db1..5d59d6ad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,7 +106,7 @@ GEM coderay (1.1.3) colorize (0.8.1) concurrent-ruby (1.2.0) - connection_pool (2.2.5) + connection_pool (2.3.0) crass (1.0.6) cssbundling-rails (1.1.2) railties (>= 6.0.0) @@ -324,7 +324,7 @@ GEM questiongenerator (1.0.0) racc (1.6.2) rack (2.2.6.2) - rack-protection (2.2.2) + rack-protection (3.0.5) rack rack-test (2.0.2) rack (>= 1.3) @@ -370,7 +370,7 @@ GEM rainbow (3.1.1) rake (13.0.6) redcarpet (3.6.0) - redis (4.5.1) + redis (4.8.0) regexp_parser (2.6.2) request_store (1.5.1) rack (>= 1.4) @@ -458,11 +458,10 @@ GEM sidekiq (>= 3.0) shoulda-matchers (5.3.0) activesupport (>= 5.2.0) - sidekiq (5.2.10) - connection_pool (~> 2.2, >= 2.2.2) + sidekiq (6.5.8) + connection_pool (>= 2.2.5, < 3) rack (~> 2.0) - rack-protection (>= 1.5.0) - redis (~> 4.5, < 4.6.0) + redis (>= 4.5.0, < 5) simple_oauth (0.3.1) simplecov (0.22.0) docile (~> 1.1) @@ -604,7 +603,7 @@ DEPENDENCIES sentry-ruby sentry-sidekiq shoulda-matchers (~> 5.3) - sidekiq (< 6) + sidekiq (< 7) simplecov simplecov-cobertura simplecov-json From 184cd680eb3db8e4f27e7cad4aff2c2c424005e7 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 31 Jan 2023 21:45:16 +0100 Subject: [PATCH 60/74] Apply review suggestion --- .github/ISSUE_TEMPLATE/01-bug_report.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/01-bug_report.yml b/.github/ISSUE_TEMPLATE/01-bug_report.yml index 777e5a6a..95d75142 100644 --- a/.github/ISSUE_TEMPLATE/01-bug_report.yml +++ b/.github/ISSUE_TEMPLATE/01-bug_report.yml @@ -48,7 +48,6 @@ body: Google Chrome 112 Firefox 109.0 - Internet Explorer 11 etc... validations: From d442324d3e84f03c0175a16f3cc1ccd1ca31272c Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 31 Jan 2023 21:46:11 +0100 Subject: [PATCH 61/74] Apply suggestions from code review Co-authored-by: Karina Kwiatek <6197148+raccube@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/01-bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/02-feature_request.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/01-bug_report.yml b/.github/ISSUE_TEMPLATE/01-bug_report.yml index 95d75142..28e87489 100644 --- a/.github/ISSUE_TEMPLATE/01-bug_report.yml +++ b/.github/ISSUE_TEMPLATE/01-bug_report.yml @@ -5,7 +5,7 @@ body: - type: markdown attributes: value: | - Before opening an issue, make sure to check if the issue was not previously reported or fixed. + Before opening an issue, please make sure to check if the [issue tracker](https://github.com/Retrospring/retrospring/issues?q=is%3Aissue+label%3Abug) in case it has been previously reported or fixed. - type: textarea attributes: label: Steps to reproduce the problem diff --git a/.github/ISSUE_TEMPLATE/02-feature_request.yml b/.github/ISSUE_TEMPLATE/02-feature_request.yml index c4ad2a3f..0d81c05b 100644 --- a/.github/ISSUE_TEMPLATE/02-feature_request.yml +++ b/.github/ISSUE_TEMPLATE/02-feature_request.yml @@ -9,7 +9,7 @@ body: - type: textarea attributes: label: Pitch - description: Describe your idea for a feature. Make sure it has not already been suggested/implemented/turned down before. + description: Describe your idea for a feature. Please check our [issue tracker](https://github.com/Retrospring/retrospring/issues?q=is%3Aissue+label%3Asuggestion) to make sure it has not already been suggested/implemented/turned down before. validations: required: true - type: textarea From 7e83c1551ca369a1ec0d42ae094703fee83fef1a Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 22:17:19 +0100 Subject: [PATCH 62/74] Bump version to 2023.0131.0 --- lib/retrospring/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/retrospring/version.rb b/lib/retrospring/version.rb index f35b16f9..3257d358 100644 --- a/lib/retrospring/version.rb +++ b/lib/retrospring/version.rb @@ -17,7 +17,7 @@ module Retrospring def month = 1 - def day = 27 + def day = 31 def patch = 0 From d08198668b62319044dad157c379b36cdb9b5f76 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 23:10:51 +0100 Subject: [PATCH 63/74] Pass user services for question generate turbo frame --- app/controllers/inbox_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index ff23f8c6..c38f2c49 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -38,10 +38,11 @@ class InboxController < ApplicationController user: current_user) inbox = Inbox.create!(user: current_user, question_id: question.id, new: true) + services = current_user.services respond_to do |format| format.turbo_stream do - render turbo_stream: turbo_stream.prepend("entries", partial: "inbox/entry", locals: { i: inbox }) + render turbo_stream: turbo_stream.prepend("entries", partial: "inbox/entry", locals: { i: inbox, services: }) inbox.update(new: false) end From 8deb78b548c6bcb89c67b1098709579e0ee16005 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 31 Jan 2023 23:13:09 +0100 Subject: [PATCH 64/74] Bump version to 2023.0131.1 --- lib/retrospring/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/retrospring/version.rb b/lib/retrospring/version.rb index 3257d358..57250b36 100644 --- a/lib/retrospring/version.rb +++ b/lib/retrospring/version.rb @@ -19,7 +19,7 @@ module Retrospring def day = 31 - def patch = 0 + def patch = 1 def suffix = "" From 0855dee294e03a768006df9a989aeaaf50d9932e Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 31 Jan 2023 23:18:48 +0100 Subject: [PATCH 65/74] update questiongenerator to 1.1.0 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index ded0bcba..6c128e9a 100644 --- a/Gemfile +++ b/Gemfile @@ -52,7 +52,7 @@ gem "sentry-sidekiq" gem "sidekiq", "< 7" # remove version constraint once are ready to upgrade https://github.com/mperham/sidekiq/blob/main/docs/7.0-Upgrade.md -gem "questiongenerator", "~> 1.0" +gem "questiongenerator", "~> 1.1" gem "httparty" gem "redcarpet" diff --git a/Gemfile.lock b/Gemfile.lock index 5d59d6ad..82b7f5c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -321,7 +321,7 @@ GEM nio4r (~> 2.0) pundit (2.3.0) activesupport (>= 3.0.0) - questiongenerator (1.0.0) + questiongenerator (1.1.0) racc (1.6.2) rack (2.2.6.2) rack-protection (3.0.5) @@ -578,7 +578,7 @@ DEPENDENCIES pghero puma pundit (~> 2.3) - questiongenerator (~> 1.0) + questiongenerator (~> 1.1) rails (~> 6.1) rails-controller-testing rails-i18n (~> 7.0) From 3f0e690f2814aa3456a44de2d1d356f312380164 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 31 Jan 2023 23:22:21 +0100 Subject: [PATCH 66/74] provide our own default questions file independent from the questiongenerator gem --- config/initializers/questiongenerator.rb | 7 +- config/questions/en.yml | 311 +++++++++++++++++++++++ 2 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 config/questions/en.yml diff --git a/config/initializers/questiongenerator.rb b/config/initializers/questiongenerator.rb index 2aacfa93..3ee204b0 100644 --- a/config/initializers/questiongenerator.rb +++ b/config/initializers/questiongenerator.rb @@ -1 +1,6 @@ -QuestionGenerator.compile +# frozen_string_literal: true + +Rails.application.config.to_prepare do + QuestionGenerator.question_base_path = File.expand_path("../questions", __dir__) + QuestionGenerator.compile +end diff --git a/config/questions/en.yml b/config/questions/en.yml new file mode 100644 index 00000000..85a8e2ac --- /dev/null +++ b/config/questions/en.yml @@ -0,0 +1,311 @@ +Do: + you: + - recycle + - have: + - a: + - nickname + - any: + - siblings + - pets + - like: + - social networks + - muffins + - video games + - the: + - city: + - or: + - country + - where you: + - live + - to: + - travel + - sing out loud when no one else is around + - want: + - old times back + - to know more: + about: + - your: + - future + - relatives + - history + - new inventions + - more: + - money + - friends + - things than you need + - think that: + - late is better than never + - prefer: + to: + - take baths or showers + your: + friends: + like: + - you: + - the way you are + - social networks + - muffins + - video games + know: + [much, too much]: + about: + - your: + - life + - hobbies + - family + - friends + - you +What: + - was: + the: + best: + - day of your life like + last: + song: + - you listened on repeat + thing: + you: + have: + - bought + - done + - eaten + your: + favourite: + song: + - as a 5 year old + - from a few weeks ago + - would: + you: + do: + if: + you: + had: + - one million dollars + - the ability to fly + were: + - a dragon + woke up: + with: + - someone else next to you + - some drawings in your face + - do: + you: + do: + - for fun + - 'on': + - the: + - weekend + like: + more,: + - dogs or cats + - shower or bath + - tea or coffee + think: + about: + - the: + - Internet + - Bad Dragon + - dragons + - '"fact" accounts' + - society + - cats + - surveillance + - coyotes + - raccoons + - foxes + - dogs + - lizards + - [activity, activities]: + do: + you: + - enjoy the most + - kind: + of: + animals: + - do you have + - habit: + do: + you: + really: + find: + cute: + - in a person + - is: + your: + - first memory + - dream job + - favourite: + - season + - video game + - board game + - sports team + - activity + - beverage + - Internet browser + - piece of music + - console + - snack + - food + - animal + - programming language: + - '' + - and why is it: + - PHP + - Rust + - C++ + - Lisp + - Pascal + - Swift + - Ruby + - website: + - '' + - and why is it: + - Reddit + - Twitter + - Facebook + - YouTube + the: + [best, worst]: + thing: + - about: + the: + - Internet + your: + - favourite: + - series + - movie + - book + - country + - hometown + - one can do: + - if: + - "they're bored" + - ever + fast: + food: + - chain + one: + - thing you would like to become better at + - was: + the: + last: + thing: + you: + - did + - ate + - looked for + [best, worst]: + thing: + - "you've eaten so far" + - languages do you know + - apps do you use daily + - 'is heavier: a kilogram of steel, or a kilogram of feathers' +Can: + you: + - swim + - speak: + - different: + - languages + - play: + - any: + - sports + - the: + - piano + - guitar + - trumpet + - saxophone + - baseball + - ski + - cook + - dance + - yodel + - draw +Are: + you: + - religious +Have: + you: + ever: + - been: + - to: + - Austria + - Germany + - Japan + - Switzerland + - France + - Sweden + - Norway + - Finland + - Australia + - Italy + - Russia + - China + - the: + - USA + - United Kingdom + - caught: + - "doing things you shouldn't do" + - cheating + - mistaken for: + - someone else + - listened to: + - classical music + - music: + - "from the 80's" + - dubstep + - nightcore + - metal + - had: + - an: + - accident + - written: + - a love letter + - code + - in Japanese +How: + has: + your: + day: + - been + old: + are: + - you + many: + - open tabs do you currently have + - followers is too many +Where: + do: + you: + - work + - live +Which: + food: + do: + you: + - love + - hate +Who: + is: + the: + - most famous person you have met + your: + - favourite: + - Retrospring user + - actor + - artist + - comedian + - musician +Why: + do: + - they call it oven when you of in the cold food of out hot eat the food +Would: + you: + rather: + live: + - in: + - a city or in the countryside + - a flat or in a house + lose: + - an arm or a leg + be: + - the best player on a horrible team or the worst player on a great team From 3c263db45c9e54434db430348acdf6016d364214 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 31 Jan 2023 23:12:05 +0100 Subject: [PATCH 67/74] Use Redis 6 in Docker setup --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 18afab61..0bdc353d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: - 1234:1234 redis: - image: redis:3.2.11-alpine + image: redis:6.2.10-alpine ports: - 6379:6379 From b8648d9998a5e83e085a64299bcbdd9fbc34edf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 04:07:20 +0000 Subject: [PATCH 68/74] Bump bootsnap from 1.15.0 to 1.16.0 Bumps [bootsnap](https://github.com/Shopify/bootsnap) from 1.15.0 to 1.16.0. - [Release notes](https://github.com/Shopify/bootsnap/releases) - [Changelog](https://github.com/Shopify/bootsnap/blob/main/CHANGELOG.md) - [Commits](https://github.com/Shopify/bootsnap/compare/v1.15.0...v1.16.0) --- updated-dependencies: - dependency-name: bootsnap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 82b7f5c6..9361cd44 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,7 +85,7 @@ GEM rack (>= 0.9.0) binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) - bootsnap (1.15.0) + bootsnap (1.16.0) msgpack (~> 1.2) bootstrap_form (5.1.0) actionpack (>= 5.2) From 603e9c501eae4656a6753484ac40fa22c8eeeb93 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 1 Feb 2023 23:20:49 +0100 Subject: [PATCH 69/74] Pre-load own mute relationships in follow lists --- app/controllers/user_controller.rb | 34 +++++++++++++------- app/views/shared/_userbox.html.haml | 2 +- app/views/user/_actions.html.haml | 3 +- app/views/user/show_follow.html.haml | 2 +- app/views/user/show_follow.turbo_stream.haml | 2 +- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 25c05efe..041748f8 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -19,24 +19,34 @@ class UserController < ApplicationController def followers paginate_relationships(:cursored_follower_relationships) @users = @relationships.map(&:source) - own_followings = find_own_relationships(current_user&.active_follow_relationships) - own_blocks = find_own_relationships(current_user&.active_block_relationships) + own_relationships = find_own_relationships + locals = { + type: :friend, + own_followings: own_relationships[Relationships::Follow], + own_blocks: own_relationships[Relationships::Block], + own_mutes: own_relationships[Relationships::Mute] + } respond_to do |format| - format.html { render "show_follow", locals: { type: :follower, own_followings:, own_blocks: } } - format.turbo_stream { render "show_follow", locals: { type: :follower, own_followings:, own_blocks: } } + format.html { render "show_follow", locals: } + format.turbo_stream { render "show_follow", locals: } end end def followings paginate_relationships(:cursored_following_relationships) @users = @relationships.map(&:target) - own_followings = find_own_relationships(current_user&.active_follow_relationships) - own_blocks = find_own_relationships(current_user&.active_block_relationships) + own_relationships = find_own_relationships + locals = { + type: :friend, + own_followings: own_relationships[Relationships::Follow], + own_blocks: own_relationships[Relationships::Block], + own_mutes: own_relationships[Relationships::Mute] + } respond_to do |format| - format.html { render "show_follow", locals: { type: :friend, own_followings:, own_blocks: } } - format.turbo_stream { render "show_follow", locals: { type: :friend, own_followings:, own_blocks: } } + format.html { render "show_follow", locals: } + format.turbo_stream { render "show_follow", locals: } end end @@ -69,10 +79,12 @@ class UserController < ApplicationController @user = User.where("LOWER(screen_name) = ?", params[:username].downcase).includes(:profile).first! end - def find_own_relationships(relationships) - return nil if relationships.nil? + def find_own_relationships + return {} unless user_signed_in? - relationships.where(target_id: @users.map(&:id))&.select(:target_id)&.map(&:target_id) + Relationship.where(source: current_user, target_id: @users.map(&:id)) + &.select(:target_id, :type) + &.group_by(&:type) end def paginate_relationships(method) diff --git a/app/views/shared/_userbox.html.haml b/app/views/shared/_userbox.html.haml index d346dd69..5aee47b4 100644 --- a/app/views/shared/_userbox.html.haml +++ b/app/views/shared/_userbox.html.haml @@ -9,4 +9,4 @@ = user.profile.display_name .profile__screen-name = user.screen_name - = render "user/actions", user:, type:, own_followings:, own_blocks: + = render "user/actions", user:, type:, own_followings:, own_blocks:, own_mutes: diff --git a/app/views/user/_actions.html.haml b/app/views/user/_actions.html.haml index 0eae948f..23960a38 100644 --- a/app/views/user/_actions.html.haml +++ b/app/views/user/_actions.html.haml @@ -2,6 +2,7 @@ - type ||= :nil - own_followings ||= nil - own_blocks ||= nil + - own_mutes ||= nil - if user_signed_in? && user == current_user .d-grid %a.btn.btn-dark{ href: settings_profile_path } Edit profile @@ -29,7 +30,7 @@ %a.dropdown-item{ href: '#', data: { action: :block, target: user.screen_name } } %i.fa.fa-minus-circle.fa-fw %span.pe-none= t("voc.block") - - if current_user.muting?(user) + - if own_mutes&.include?(user.id) || current_user.muting?(user) %a.dropdown-item{ href: '#', data: { action: :unmute, target: user.screen_name } } %i.fa.fa-volume-off.fa-fw %span.pe-none= t("voc.unmute") diff --git a/app/views/user/show_follow.html.haml b/app/views/user/show_follow.html.haml index 890698ca..699df89a 100644 --- a/app/views/user/show_follow.html.haml +++ b/app/views/user/show_follow.html.haml @@ -1,7 +1,7 @@ .row.row-cols-1.row-cols-sm-2.row-cols-md-3#users - @users.each do |user| .col.pb-3 - = render "shared/userbox", user:, type:, own_followings:, own_blocks: + = render "shared/userbox", user:, type:, own_followings:, own_blocks:, own_mutes: - if @more_data_available .d-flex.justify-content-center.justify-content-sm-start#paginator diff --git a/app/views/user/show_follow.turbo_stream.haml b/app/views/user/show_follow.turbo_stream.haml index b0c52a2a..fe434f69 100644 --- a/app/views/user/show_follow.turbo_stream.haml +++ b/app/views/user/show_follow.turbo_stream.haml @@ -1,7 +1,7 @@ = turbo_stream.append "users" do - @users.each do |user| .col.pb-3 - = render "shared/userbox", user:, type:, own_followings:, own_blocks: + = render "shared/userbox", user:, type:, own_followings:, own_blocks:, own_mutes: = turbo_stream.update "paginator" do - if @more_data_available From 825454bbae547593f80768bbfe666c6f426b795e Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 1 Feb 2023 23:34:33 +0100 Subject: [PATCH 70/74] Fix incorrect type local in followers endpoint --- app/controllers/user_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 041748f8..17926429 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -21,7 +21,7 @@ class UserController < ApplicationController @users = @relationships.map(&:source) own_relationships = find_own_relationships locals = { - type: :friend, + type: :follower, own_followings: own_relationships[Relationships::Follow], own_blocks: own_relationships[Relationships::Block], own_mutes: own_relationships[Relationships::Mute] From 7d91c0349a2b5325044f9ef9a9f6ad7534217411 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 2 Feb 2023 00:44:42 +0100 Subject: [PATCH 71/74] Eagerly load services in action to prevent n+1 query --- app/controllers/inbox_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index c38f2c49..a31080e8 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -18,7 +18,7 @@ class InboxController < ApplicationController @delete_id = find_delete_id @disabled = true if @inbox.empty? - services = current_user.services + services = current_user.services.to_a respond_to do |format| format.html { render "show", locals: { services: } } From 81a6c6ac55aa40b36f32244efc5a2d50ad404df7 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Thu, 2 Feb 2023 00:55:31 +0100 Subject: [PATCH 72/74] =?UTF-8?q?Prevent=20=F0=9D=91=9B+1=20for=20notifica?= =?UTF-8?q?tion=20type=20counters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/notifications_controller.rb | 3 +++ app/views/tabs/_notifications.html.haml | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 4f2dfdeb..8572f8ff 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -18,6 +18,9 @@ class NotificationsController < ApplicationController @notifications = cursored_notifications_for(type: @type, last_id: params[:last_id]) @notifications_last_id = @notifications.map(&:id).min @more_data_available = !cursored_notifications_for(type: @type, last_id: @notifications_last_id, size: 1).count.zero? + @counters = Notification.where(recipient: current_user, new: true) + .group(:target_type) + .count(:target_type) respond_to do |format| format.html diff --git a/app/views/tabs/_notifications.html.haml b/app/views/tabs/_notifications.html.haml index ad4d7a63..98ba302a 100644 --- a/app/views/tabs/_notifications.html.haml +++ b/app/views/tabs/_notifications.html.haml @@ -9,18 +9,18 @@ .list-group = list_group_item t('.answer'), notifications_path('answer'), - badge: Notification.for(current_user).where(target_type: 'Answer', new: true).count + badge: @counters['Answer'] = list_group_item t('.smile'), notifications_path('smile'), - badge: Notification.for(current_user).where(target_type: 'Smile', new: true).count + badge: @counters['Smile'] = list_group_item t('.comment'), notifications_path('comment'), - badge: Notification.for(current_user).where(target_type: 'Comment', new: true).count + badge: @counters['Comment'] = list_group_item t('.commentsmile'), notifications_path('commentsmile'), - badge: Notification.for(current_user).where(target_type: 'CommentSmile', new: true).count + badge: @counters['CommentSmile'] = list_group_item t('.relationship'), notifications_path('relationship'), - badge: Notification.for(current_user).where(target_type: 'Relationship', new: true).count + badge: @counters['Relationship'] .d-none.d-sm-block= render 'shared/links' From 80e312eb3b140392f0fa351add29baf02073baba Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Thu, 2 Feb 2023 10:38:41 +0100 Subject: [PATCH 73/74] Appease the dog overlords --- app/controllers/notifications_controller.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 8572f8ff..860dd3ec 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -16,11 +16,8 @@ class NotificationsController < ApplicationController def index @type = TYPE_MAPPINGS[params[:type]] || params[:type] @notifications = cursored_notifications_for(type: @type, last_id: params[:last_id]) - @notifications_last_id = @notifications.map(&:id).min - @more_data_available = !cursored_notifications_for(type: @type, last_id: @notifications_last_id, size: 1).count.zero? - @counters = Notification.where(recipient: current_user, new: true) - .group(:target_type) - .count(:target_type) + paginate_notifications + @counters = count_unread_by_type respond_to do |format| format.html @@ -30,6 +27,17 @@ class NotificationsController < ApplicationController private + def paginate_notifications + @notifications_last_id = @notifications.map(&:id).min + @more_data_available = !cursored_notifications_for(type: @type, last_id: @notifications_last_id, size: 1).count.zero? + end + + def count_unread_by_type + Notification.where(recipient: current_user, new: true) + .group(:target_type) + .count(:target_type) + end + def mark_notifications_as_read # using .dup to not modify @notifications -- useful in tests @notifications&.dup&.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations From 40f7f8f525b67c5ffc7ebb9478736f08970b606a Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Thu, 2 Feb 2023 11:03:27 +0100 Subject: [PATCH 74/74] Eager load notification targets --- app/models/notification.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index 0bf19ff7..60890d17 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -11,11 +11,11 @@ class Notification < ApplicationRecord define_cursor_paginator :cursored_for_type, :for_type def for(recipient, **kwargs) - where(kwargs.merge!(recipient:)).order(:created_at).reverse_order + where(kwargs.merge!(recipient:)).includes(:target).order(:created_at).reverse_order end def for_type(recipient, type, **kwargs) - where(kwargs.merge!(recipient:)).where(type:).order(:created_at).reverse_order + where(kwargs.merge!(recipient:)).includes(:target).where(type:).order(:created_at).reverse_order end def notify(recipient, target)