From 154a3119fb45401dcd785b085b28fe18202b091c Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 21 Feb 2024 17:50:41 +0100 Subject: [PATCH 01/12] Further reduce CSS differences with upstream (#2638) --- .../flavours/glitch/styles/components.scss | 153 ++++++++---------- 1 file changed, 66 insertions(+), 87 deletions(-) diff --git a/app/javascript/flavours/glitch/styles/components.scss b/app/javascript/flavours/glitch/styles/components.scss index 9e21cc36ba..b37ffe322e 100644 --- a/app/javascript/flavours/glitch/styles/components.scss +++ b/app/javascript/flavours/glitch/styles/components.scss @@ -852,21 +852,33 @@ body > [data-popper-placement] { clear: both; } +.status__content, .reply-indicator__content { position: relative; - font-size: 14px; + font-size: 15px; line-height: 20px; word-wrap: break-word; font-weight: 400; overflow: hidden; - padding-top: 5px; - color: $inverted-text-color; - white-space: pre-wrap; + text-overflow: ellipsis; + padding-top: 2px; + color: $primary-text-color; + + &:focus { + outline: 0; + } + + .emojione { + width: 20px; + height: 20px; + margin: -3px 0 0; + } p, pre { margin-bottom: 20px; white-space: pre-wrap; + unicode-bidi: plaintext; &:last-child { margin-bottom: 0; @@ -874,8 +886,9 @@ body > [data-popper-placement] { } a { - color: $lighter-text-color; + color: $secondary-text-color; text-decoration: none; + unicode-bidi: isolate; &:hover { text-decoration: underline; @@ -892,10 +905,45 @@ body > [data-popper-placement] { } } - .emojione { - width: 20px; - height: 20px; - margin: -5px 0 0; + a.unhandled-link { + color: $highlight-text-color; + + .link-origin-tag { + color: $gold-star; + font-size: 0.8em; + } + } + + .status__content__spoiler-link { + background: $action-button-color; + + &:hover, + &:focus { + background: lighten($action-button-color, 7%); + text-decoration: none; + } + + &::-moz-focus-inner { + border: 0; + } + + &::-moz-focus-inner, + &:focus, + &:active { + outline: 0 !important; + } + } +} + +.status__content { + overflow: visible; + + .status__content__spoiler { + display: none; + + &.status__content__spoiler--visible { + display: block; + } } } @@ -1503,6 +1551,15 @@ body > [data-popper-placement] { line-height: 18px; } +.reply-indicator__content { + color: $inverted-text-color; + font-size: 14px; + + a { + color: $lighter-text-color; + } +} + .domain { padding: 10px; border-bottom: 1px solid lighten($ui-base-color, 8%); @@ -5204,84 +5261,6 @@ a.status-card { } } -.status__content { - position: relative; - font-size: 15px; - line-height: 20px; - word-wrap: break-word; - font-weight: 400; - overflow: visible; - padding-top: 5px; - - &:focus { - outline: 0; - } - - .emojione { - width: 20px; - height: 20px; - margin: -3px 0 0; - } - - p, - pre { - margin-bottom: 20px; - white-space: pre-wrap; - unicode-bidi: plaintext; - - &:last-child { - margin-bottom: 0; - } - } - - a { - color: $secondary-text-color; - text-decoration: none; - unicode-bidi: isolate; - - &:hover { - text-decoration: underline; - } - - &.mention { - &:hover { - text-decoration: none; - - span { - text-decoration: underline; - } - } - } - } - - .status__content__spoiler { - display: none; - - &.status__content__spoiler--visible { - display: block; - } - } - - a.unhandled-link { - color: $highlight-text-color; - - .link-origin-tag { - color: $gold-star; - font-size: 0.8em; - } - } - - .status__content__spoiler-link { - background: lighten($ui-base-color, 30%); - - &:hover, - &:focus { - background: lighten($ui-base-color, 33%); - text-decoration: none; - } - } -} - .notif-cleaning { .status, .notification { From 604c93332f860105aca0d02d1654b1220f7ca679 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 21 Feb 2024 19:30:54 +0100 Subject: [PATCH 02/12] Fix pillbar button colors (#2639) --- app/javascript/flavours/glitch/styles/components.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/styles/components.scss b/app/javascript/flavours/glitch/styles/components.scss index b37ffe322e..831efb01e9 100644 --- a/app/javascript/flavours/glitch/styles/components.scss +++ b/app/javascript/flavours/glitch/styles/components.scss @@ -4185,7 +4185,7 @@ a.status-card { margin: 0; font-size: inherit; flex: auto; - background-color: $ui-base-color; + background-color: lighten($ui-base-color, 8%); transition: all 0.2s ease; transition-property: background-color, box-shadow; From fff378177eaf9c39ce817a715121ecd56c564adc Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 22 Feb 2024 18:45:54 +0100 Subject: [PATCH 03/12] Further reduce differences with upstream (mainly private mention styling) (#2641) * Use upstream's CSS for private mentions styling * Further reduce differences with upstream --- .../flavours/glitch/styles/components.scss | 239 +++++++++++------- 1 file changed, 144 insertions(+), 95 deletions(-) diff --git a/app/javascript/flavours/glitch/styles/components.scss b/app/javascript/flavours/glitch/styles/components.scss index 831efb01e9..954a014f3a 100644 --- a/app/javascript/flavours/glitch/styles/components.scss +++ b/app/javascript/flavours/glitch/styles/components.scss @@ -774,6 +774,28 @@ body > [data-popper-placement] { opacity 0.4s ease; } +.compose-form__textarea-icons { + display: block; + position: absolute; + top: 29px; + inset-inline-end: 5px; + bottom: 5px; + overflow: hidden; + + & > .textarea_icon { + display: block; + margin-top: 2px; + margin-inline-start: 2px; + width: 24px; + height: 24px; + color: $lighter-text-color; + font-size: 18px; + line-height: 24px; + text-align: center; + opacity: 0.8; + } +} + .sign-in-banner { padding: 10px; @@ -933,10 +955,6 @@ body > [data-popper-placement] { outline: 0 !important; } } -} - -.status__content { - overflow: visible; .status__content__spoiler { display: none; @@ -947,6 +965,11 @@ body > [data-popper-placement] { } } +.status__content { + // glitch: necessary for fullwidth media options + overflow: visible; +} + .announcements__item__content { word-wrap: break-word; overflow-y: auto; @@ -990,6 +1013,30 @@ body > [data-popper-placement] { } } +.status__content__read-more-button, +.status__content__translate-button { + display: flex; + align-items: center; + font-size: 15px; + line-height: 22px; + color: $highlight-text-color; + border: 0; + background: transparent; + padding: 0; + padding-top: 16px; + text-decoration: none; + + &:hover, + &:active { + text-decoration: underline; + } + + .icon { + width: 15px; + height: 15px; + } +} + .translate-button { margin-top: 16px; font-size: 15px; @@ -1002,7 +1049,7 @@ body > [data-popper-placement] { .status__content__spoiler-link { display: inline-flex; border-radius: 2px; - background: lighten($ui-base-color, 30%); + background: transparent; border: 0; color: $inverted-text-color; font-weight: 700; @@ -1064,14 +1111,6 @@ body > [data-popper-placement] { outline: 0; background: lighten($ui-base-color, 4%); - &.status.status-direct { - background: mix(lighten($ui-base-color, 4%), $ui-highlight-color, 95%); - - &.muted { - background: transparent; - } - } - .detailed-status, .detailed-status__action-bar { background: lighten($ui-base-color, 8%); @@ -1105,11 +1144,6 @@ body > [data-popper-placement] { margin-top: 8px; // glitch: reduced margins } - &.status-direct { - background: mix($ui-base-color, $ui-highlight-color, 95%); - border-bottom-color: lighten($ui-base-color, 12%); - } - &.light { .status__relative-time, .status__visibility-icon { @@ -1157,6 +1191,10 @@ body > [data-popper-placement] { margin-inline-start: $thread-margin; width: calc(100% - ($thread-margin)); } + + .status__content__read-more-button { + margin-inline-start: $thread-margin; + } } &--first-in-thread { @@ -1256,6 +1294,7 @@ body > [data-popper-placement] { ); } + // TODO: review &.status-direct > .status__content::after { background: linear-gradient( rgba(mix($ui-base-color, $ui-highlight-color, 95%), 0), @@ -1372,6 +1411,50 @@ body > [data-popper-placement] { } } +@keyframes spring-flip-in { + 0% { + transform: rotate(0deg); + } + + 30% { + transform: rotate(-242.4deg); + } + + 60% { + transform: rotate(-158.35deg); + } + + 90% { + transform: rotate(-187.5deg); + } + + 100% { + transform: rotate(-180deg); + } +} + +@keyframes spring-flip-out { + 0% { + transform: rotate(-180deg); + } + + 30% { + transform: rotate(62.4deg); + } + + 60% { + transform: rotate(-21.635deg); + } + + 90% { + transform: rotate(7.5deg); + } + + 100% { + transform: rotate(0deg); + } +} + .status-check-box__status { display: block; box-sizing: border-box; @@ -1428,6 +1511,18 @@ body > [data-popper-placement] { } } +.status__wrapper-direct { + background: mix($ui-base-color, $ui-highlight-color, 95%); + + &:focus { + background: mix(lighten($ui-base-color, 4%), $ui-highlight-color, 95%); + } + + .status__prepend { + color: $highlight-text-color; + } +} + .status__action-bar { display: flex; align-items: center; @@ -1473,6 +1568,11 @@ body > [data-popper-placement] { height: 24px; margin: -1px 0 0; } + + .status__content__spoiler-link { + line-height: 24px; + margin: -1px 0 0; + } } .media-gallery, @@ -1508,25 +1608,29 @@ body > [data-popper-placement] { padding: 8px 0; // glitch: reduced padding } -.compose-form__textarea-icons { - display: block; - position: absolute; - top: 29px; - inset-inline-end: 5px; - bottom: 5px; - overflow: hidden; +.detailed-status__wrapper-direct { + .detailed-status, + .detailed-status__action-bar { + background: mix($ui-base-color, $ui-highlight-color, 95%); + } - & > .textarea_icon { - display: block; - margin-top: 2px; - margin-inline-start: 2px; - width: 24px; - height: 24px; - color: $lighter-text-color; - font-size: 18px; - line-height: 24px; - text-align: center; - opacity: 0.8; + &:focus { + .detailed-status, + .detailed-status__action-bar { + background: mix(lighten($ui-base-color, 4%), $ui-highlight-color, 95%); + } + } + + .detailed-status__action-bar { + border-top-color: mix( + lighten($ui-base-color, 8%), + $ui-highlight-color, + 95% + ); + } + + .status__prepend { + color: $highlight-text-color; } } @@ -4659,10 +4763,10 @@ a.status-card { margin-bottom: 4px; display: block; background-color: rgba($black, 0.45); - text-transform: uppercase; font-size: 11px; - font-weight: 500; - padding: 4px; + text-transform: uppercase; + font-weight: 700; + padding: 2px 6px; border-radius: 4px; opacity: 0.7; @@ -5217,50 +5321,6 @@ a.status-card { } } -@keyframes spring-flip-in { - 0% { - transform: rotate(0deg); - } - - 30% { - transform: rotate(-242.4deg); - } - - 60% { - transform: rotate(-158.35deg); - } - - 90% { - transform: rotate(-187.5deg); - } - - 100% { - transform: rotate(-180deg); - } -} - -@keyframes spring-flip-out { - 0% { - transform: rotate(-180deg); - } - - 30% { - transform: rotate(62.4deg); - } - - 60% { - transform: rotate(-21.635deg); - } - - 90% { - transform: rotate(7.5deg); - } - - 100% { - transform: rotate(0deg); - } -} - .notif-cleaning { .status, .notification { @@ -5268,18 +5328,6 @@ a.status-card { } } -.notification-follow, -.notification-follow-request { - position: relative; - - // same like Status - border-bottom: 1px solid lighten($ui-base-color, 8%); - - .account { - border-bottom: 0 none; - } -} - .language-dropdown { &__dropdown { background: $simple-background-color; @@ -8614,6 +8662,7 @@ noscript { inset-inline-end: 20px; width: 300px; + // glitch: feature to chose which side the pop-in player is displayed &.left { inset-inline-end: unset; inset-inline-start: 20px; From 7cd5866ddc1e5db080ccb200f7d631d6866105f1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:59:51 +0100 Subject: [PATCH 04/12] Update dependency doorkeeper to v5.6.9 (#29196) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0b53df82e0..79d3b1e637 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -219,7 +219,7 @@ GEM docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - doorkeeper (5.6.8) + doorkeeper (5.6.9) railties (>= 5) dotenv (2.8.1) dotenv-rails (2.8.1) @@ -811,7 +811,7 @@ GEM xorcist (1.1.3) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS ruby From 840ce1e0cb4ba47861fac9876819a0e4b3928552 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:11:22 +0000 Subject: [PATCH 05/12] Update dependency webmock to v3.21.2 (#29290) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 79d3b1e637..fac511d026 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -793,7 +793,7 @@ GEM webfinger (1.2.0) activesupport httpclient (>= 2.4) - webmock (3.20.0) + webmock (3.21.2) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) From fec49022ed00323d1176c51b0949f45ee78d8fb7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:17:41 +0100 Subject: [PATCH 06/12] Update dependency selenium-webdriver to v4.18.1 (#29287) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index fac511d026..8dd1a7ed08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -691,7 +691,7 @@ GEM scenic (1.7.0) activerecord (>= 4.0.0) railties (>= 4.0.0) - selenium-webdriver (4.17.0) + selenium-webdriver (4.18.1) base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) From d10848946c391e343e0b19f88672a159c2293fc5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 11:37:52 +0100 Subject: [PATCH 07/12] Update dependency rails to v7.1.3.2 (#29342) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 110 +++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8dd1a7ed08..b88a062566 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,35 +10,35 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.3) - actionpack (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activesupport (= 7.1.3) + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.3) - actionview (= 7.1.3) - activesupport (= 7.1.3) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -46,15 +46,15 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3) - actionpack (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3) - activesupport (= 7.1.3) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) @@ -64,22 +64,22 @@ GEM activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (7.1.3) - activesupport (= 7.1.3) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (7.1.3) - activesupport (= 7.1.3) - activerecord (7.1.3) - activemodel (= 7.1.3) - activesupport (= 7.1.3) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) timeout (>= 0.4.0) - activestorage (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activesupport (= 7.1.3) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - activesupport (7.1.3) + activesupport (7.1.3.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -444,7 +444,7 @@ GEM uri net-http-persistent (4.0.2) connection_pool (~> 2.2) - net-imap (0.4.9.1) + net-imap (0.4.10) date net-protocol net-ldap (0.19.0) @@ -532,7 +532,7 @@ GEM activesupport (>= 3.0.0) raabro (1.4.0) racc (1.7.3) - rack (2.2.8) + rack (2.2.8.1) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-cors (2.0.1) @@ -554,20 +554,20 @@ GEM rackup (1.0.0) rack (< 3) webrick - rails (7.1.3) - actioncable (= 7.1.3) - actionmailbox (= 7.1.3) - actionmailer (= 7.1.3) - actionpack (= 7.1.3) - actiontext (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activemodel (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 7.1.3) + railties (= 7.1.3.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -582,9 +582,9 @@ GEM rails-i18n (7.0.8) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) irb rackup (>= 1.0.0) rake (>= 12.2) From 3dae23816bdcf149c6ab974a338b8c1514949d4c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:26:48 +0100 Subject: [PATCH 08/12] Update dependency haml_lint to v0.57.0 (#29181) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b88a062566..07e6afb1c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -309,7 +309,7 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - haml_lint (0.56.0) + haml_lint (0.57.0) haml (>= 5.0) parallel (~> 1.10) rainbow From d908ed8e86d08e67c91a41f6f90bd33c6552446f Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Tue, 20 Feb 2024 11:10:58 +0100 Subject: [PATCH 09/12] Remove unused dependencies (#29289) --- package.json | 6 +----- yarn.lock | 19 +++---------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index abb65a98da..f38457272d 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,6 @@ "mark-loader": "^0.1.6", "marky": "^1.2.5", "mini-css-extract-plugin": "^1.6.2", - "mkdirp": "^3.0.1", "path-complete-extname": "^1.0.0", "postcss": "^8.4.24", "postcss-loader": "^4.3.0", @@ -121,7 +120,6 @@ "redux-immutable": "^4.0.0", "regenerator-runtime": "^0.14.0", "requestidlecallback": "^0.3.0", - "rimraf": "^5.0.1", "sass": "^1.62.1", "sass-loader": "^10.2.0", "stacktrace-js": "^2.0.2", @@ -178,7 +176,6 @@ "@types/redux-immutable": "^4.0.3", "@types/requestidlecallback": "^0.3.5", "@types/webpack": "^4.41.33", - "@types/yargs": "^17.0.24", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.17.0", "babel-jest": "^29.5.0", @@ -203,8 +200,7 @@ "stylelint": "^16.0.2", "stylelint-config-standard-scss": "^13.0.0", "typescript": "^5.0.4", - "webpack-dev-server": "^3.11.3", - "yargs": "^17.7.2" + "webpack-dev-server": "^3.11.3" }, "resolutions": { "kind-of": "^6.0.3", diff --git a/yarn.lock b/yarn.lock index 3dc4244546..bdd218804c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2394,7 +2394,6 @@ __metadata: "@types/redux-immutable": "npm:^4.0.3" "@types/requestidlecallback": "npm:^0.3.5" "@types/webpack": "npm:^4.41.33" - "@types/yargs": "npm:^17.0.24" "@typescript-eslint/eslint-plugin": "npm:^6.0.0" "@typescript-eslint/parser": "npm:^6.17.0" arrow-key-navigation: "npm:^1.2.0" @@ -2454,7 +2453,6 @@ __metadata: mark-loader: "npm:^0.1.6" marky: "npm:^1.2.5" mini-css-extract-plugin: "npm:^1.6.2" - mkdirp: "npm:^3.0.1" path-complete-extname: "npm:^1.0.0" postcss: "npm:^8.4.24" postcss-loader: "npm:^4.3.0" @@ -2485,7 +2483,6 @@ __metadata: redux-immutable: "npm:^4.0.0" regenerator-runtime: "npm:^0.14.0" requestidlecallback: "npm:^0.3.0" - rimraf: "npm:^5.0.1" sass: "npm:^1.62.1" sass-loader: "npm:^10.2.0" stacktrace-js: "npm:^2.0.2" @@ -2511,7 +2508,6 @@ __metadata: workbox-strategies: "npm:^7.0.0" workbox-webpack-plugin: "npm:^7.0.0" workbox-window: "npm:^7.0.0" - yargs: "npm:^17.7.2" peerDependenciesMeta: react: optional: true @@ -3713,7 +3709,7 @@ __metadata: languageName: node linkType: hard -"@types/yargs@npm:^17.0.24, @types/yargs@npm:^17.0.8": +"@types/yargs@npm:^17.0.8": version: 17.0.32 resolution: "@types/yargs@npm:17.0.32" dependencies: @@ -11662,15 +11658,6 @@ __metadata: languageName: node linkType: hard -"mkdirp@npm:^3.0.1": - version: 3.0.1 - resolution: "mkdirp@npm:3.0.1" - bin: - mkdirp: dist/cjs/src/bin.js - checksum: 9f2b975e9246351f5e3a40dcfac99fcd0baa31fbfab615fe059fb11e51f10e4803c63de1f384c54d656e4db31d000e4767e9ef076a22e12a641357602e31d57d - languageName: node - linkType: hard - "mousetrap@npm:^1.5.2": version: 1.6.5 resolution: "mousetrap@npm:1.6.5" @@ -14521,7 +14508,7 @@ __metadata: languageName: node linkType: hard -"rimraf@npm:^5.0.1, rimraf@npm:^5.0.5": +"rimraf@npm:^5.0.5": version: 5.0.5 resolution: "rimraf@npm:5.0.5" dependencies: @@ -17822,7 +17809,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^17.3.1, yargs@npm:^17.7.2": +"yargs@npm:^17.3.1": version: 17.7.2 resolution: "yargs@npm:17.7.2" dependencies: From d23f445527ecc71dd41b649e578f9139e35b2bb2 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 21 Feb 2024 18:45:06 +0100 Subject: [PATCH 10/12] Automatically switch from open to approved registrations in absence of moderators (#29318) --- app/mailers/admin_mailer.rb | 6 ++ .../auto_close_registrations.text.erb | 3 + .../auto_close_registrations_scheduler.rb | 33 ++++++++++ config/locales/en.yml | 3 + config/sidekiq.yml | 4 ++ ...auto_close_registrations_scheduler_spec.rb | 60 +++++++++++++++++++ 6 files changed, 109 insertions(+) create mode 100644 app/views/admin_mailer/auto_close_registrations.text.erb create mode 100644 app/workers/scheduler/auto_close_registrations_scheduler.rb create mode 100644 spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index 2a6fbb0ab7..8990b2a847 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -61,6 +61,12 @@ class AdminMailer < ApplicationMailer end end + def auto_close_registrations + locale_for_account(@me) do + mail subject: default_i18n_subject(instance: @instance) + end + end + private def process_params diff --git a/app/views/admin_mailer/auto_close_registrations.text.erb b/app/views/admin_mailer/auto_close_registrations.text.erb new file mode 100644 index 0000000000..c0f8486929 --- /dev/null +++ b/app/views/admin_mailer/auto_close_registrations.text.erb @@ -0,0 +1,3 @@ +<%= raw t('admin_mailer.auto_close_registrations.body', instance: @instance) %> + +<%= raw t('application_mailer.view')%> <%= admin_settings_registrations_url %> diff --git a/app/workers/scheduler/auto_close_registrations_scheduler.rb b/app/workers/scheduler/auto_close_registrations_scheduler.rb new file mode 100644 index 0000000000..17516dd23f --- /dev/null +++ b/app/workers/scheduler/auto_close_registrations_scheduler.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class Scheduler::AutoCloseRegistrationsScheduler + include Sidekiq::Worker + include Redisable + + sidekiq_options retry: 0 + + # Automatically switch away from open registrations if no + # moderator had any activity in that period of time + OPEN_REGISTRATIONS_MODERATOR_THRESHOLD = 1.week + UserTrackingConcern::SIGN_IN_UPDATE_FREQUENCY + + def perform + return if Rails.configuration.x.email_domains_whitelist.present? || ENV['DISABLE_AUTOMATIC_SWITCHING_TO_APPROVED_REGISTRATIONS'] == 'true' + return unless Setting.registrations_mode == 'open' + + switch_to_approval_mode! unless active_moderators? + end + + private + + def active_moderators? + User.those_who_can(:manage_reports).exists?(current_sign_in_at: OPEN_REGISTRATIONS_MODERATOR_THRESHOLD.ago...) + end + + def switch_to_approval_mode! + Setting.registrations_mode = 'approved' + + User.those_who_can(:view_devops).includes(:account).find_each do |user| + AdminMailer.with(recipient: user.account).auto_close_registrations.deliver_later + end + end +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9d739be07f..a7a83391d4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -966,6 +966,9 @@ en: title: Webhooks webhook: Webhook admin_mailer: + auto_close_registrations: + body: Due to a lack of recent moderator activity, registrations on %{instance} have been automatically switched to requiring manual review, to prevent %{instance} from being used as a platform for potential bad actors. You can switch it back to open registrations at any time. + subject: Registrations for %{instance} have been automatically switched to requiring approval new_appeal: actions: delete_statuses: to delete their posts diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 3f9cbd9a7a..488c2f2ab3 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -63,3 +63,7 @@ interval: 30 minutes class: Scheduler::SoftwareUpdateCheckScheduler queue: scheduler + auto_close_registrations_scheduler: + interval: 1 hour + class: Scheduler::AutoCloseRegistrationsScheduler + queue: scheduler diff --git a/spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb b/spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb new file mode 100644 index 0000000000..c0c50b128d --- /dev/null +++ b/spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::AutoCloseRegistrationsScheduler do + subject { described_class.new } + + describe '#perform' do + let(:moderator_activity_date) { Time.now.utc } + + before do + Fabricate(:user, role: UserRole.find_by(name: 'Owner'), current_sign_in_at: 10.years.ago) + Fabricate(:user, role: UserRole.find_by(name: 'Moderator'), current_sign_in_at: moderator_activity_date) + end + + context 'when registrations are open' do + before do + Setting.registrations_mode = 'open' + end + + context 'when a moderator has logged in recently' do + let(:moderator_activity_date) { Time.now.utc } + + it 'does not change registrations mode' do + expect { subject.perform }.to_not change(Setting, :registrations_mode) + end + end + + context 'when a moderator has not recently signed in' do + let(:moderator_activity_date) { 1.year.ago } + + it 'changes registrations mode from open to approved' do + expect { subject.perform }.to change(Setting, :registrations_mode).from('open').to('approved') + end + end + end + + context 'when registrations are closed' do + before do + Setting.registrations_mode = 'none' + end + + context 'when a moderator has logged in recently' do + let(:moderator_activity_date) { Time.now.utc } + + it 'does not change registrations mode' do + expect { subject.perform }.to_not change(Setting, :registrations_mode) + end + end + + context 'when a moderator has not recently signed in' do + let(:moderator_activity_date) { 1.year.ago } + + it 'does not change registrations mode' do + expect { subject.perform }.to_not change(Setting, :registrations_mode) + end + end + end + end +end From b0822ae9cdad0405ade823b5b19de1e1da0e75be Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 22 Feb 2024 15:52:14 +0100 Subject: [PATCH 11/12] Fix auto-close email being sent to users with devops permissions instead of settings permissions (#29355) --- app/workers/scheduler/auto_close_registrations_scheduler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/scheduler/auto_close_registrations_scheduler.rb b/app/workers/scheduler/auto_close_registrations_scheduler.rb index 17516dd23f..6874502915 100644 --- a/app/workers/scheduler/auto_close_registrations_scheduler.rb +++ b/app/workers/scheduler/auto_close_registrations_scheduler.rb @@ -26,7 +26,7 @@ class Scheduler::AutoCloseRegistrationsScheduler def switch_to_approval_mode! Setting.registrations_mode = 'approved' - User.those_who_can(:view_devops).includes(:account).find_each do |user| + User.those_who_can(:manage_settings).includes(:account).find_each do |user| AdminMailer.with(recipient: user.account).auto_close_registrations.deliver_later end end From f25414014a68deae1c05d7e22ecebd69215b8755 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 22 Feb 2024 18:31:50 +0100 Subject: [PATCH 12/12] Fix link verifications when page size exceeds 1MB (#29358) --- app/services/verify_link_service.rb | 2 +- spec/services/verify_link_service_spec.rb | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/services/verify_link_service.rb b/app/services/verify_link_service.rb index 707aeb4e08..b317fc31a8 100644 --- a/app/services/verify_link_service.rb +++ b/app/services/verify_link_service.rb @@ -19,7 +19,7 @@ class VerifyLinkService < BaseService def perform_request! @body = Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res| - res.code == 200 ? res.body_with_limit : nil + res.code == 200 ? res.truncated_body : nil end end diff --git a/spec/services/verify_link_service_spec.rb b/spec/services/verify_link_service_spec.rb index 415788cb58..d06344f9cc 100644 --- a/spec/services/verify_link_service_spec.rb +++ b/spec/services/verify_link_service_spec.rb @@ -80,24 +80,25 @@ RSpec.describe VerifyLinkService, type: :service do " - " end - it 'marks the field as not verified' do - expect(field.verified?).to be false + it 'marks the field as verified' do + expect(field.verified?).to be true end end - context 'when a link back might be truncated' do + context 'when a link tag might be truncated' do let(:html) do " -