2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-10-04 17:32:34 +08:00
Commit graph

10707 commits

Author SHA1 Message Date
Loïc Guitaut
039aecae9b DEV: Fix sidekiq requires in test env
When in test env, we can get errors because the "sidekiq/api" file isn’t
properly loaded.
2025-07-22 12:40:57 +02:00
Loïc Guitaut
0eab7daea4 DEV: Upgrade Rails to version 8.0.2
- Migrated from annotate to annotaterb as the former is not maintained
  anymore.
- Dropped our `fast_pluck` patch as the default `pluck` implementation
  seems now faster.
2025-07-22 09:59:44 +02:00
Sam
68b901586a
FEATURE: dynamic search when in /filter route (#33614)
Introduces new dynamic autocomplete for filter to make discovery
easier:

<img width="930" height="585" alt="image"
src="https://github.com/user-attachments/assets/17e7f746-a170-4f10-9ddf-77ef651e5325"
/>



https://github.com/user-attachments/assets/e9d7bc29-a593-4ef3-82a2-f10fc35ed47c

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2025-07-22 16:08:10 +10:00
David Taylor
5ba28911ca
DEV: Only load specific plugin bundles during qunit test (#33678)
Previously, running qunit tests for a plugin would load the JS of all
installed plugins. This can be problematic because, depending on the
plugins installed in the current environment, there can be unexpected
interactions between the plugins.

This commit updates our qunit system to check the
`tests.requiredPlugins` list from the theme/plugin `about.json` file,
and only loads the listed plugins. This means that the environment is
much more consistent across CI and different development environments.

Alongside that change, this commit also:

- Starts storing the original `about.json` for themes in the database

- Improves qunit error handling when the test environment fails to boot
(e.g. there's a bad import in a plugin)

- Restores plugin CSS in theme qunit tests
2025-07-21 21:00:48 +01:00
Penar Musaraj
ecb4ece065
DEV: Add validator for enable_discourse_id setting (#33710)
Still an internal beta feature, but without an id and a secret, the
authenticator shouldn't be enabled.
2025-07-21 08:18:36 -04:00
Ted Johansson
24f58cb4b0
DEV: Remove now-redundant is_staff check from PostGuardian (#33714)
A while back we replaced hard-coded #is_staff? checks with group based permissions.

The edit_post_allowed_groups setting has admins and moderators (i.e. staff) as mandatory values, and so we no longer need the explicit staff check.
2025-07-21 15:19:39 +08:00
Ted Johansson
a658e50a48
DEV: Remove now-redundant is_staff check from PostGuardian (part 1) (#33713)
A while back we replaced hard-coded #is_staff? checks with group based permissions.

The edit_post_allowed_groups setting has admins and moderators (i.e. staff) as mandatory values, and so we no longer need the explicit staff check.
2025-07-21 15:15:13 +08:00
Ted Johansson
c1313c365f
DEV: Add test coverage for PostGuardian methods (#33712)
In #33587 we moved PostGuardian related tests from guardian_spec to post_guardian_spec. When doing so we also added stubs for missing tests.

This PR implements those missing tests.
2025-07-21 14:47:53 +08:00
Jarek Radosz
3ef64175f9
DEV: Run qunit tests and system specs for bundled themes (#33704)
Also: check for .gjs tests
2025-07-18 18:49:08 +02:00
Gabriel Grubba
3003d29852
SECURITY: Only public subcategories in onebox (#33705) 2025-07-18 11:41:10 -03:00
David Battersby
793c55aa58
FIX: composer educational limit should use post count (#33650)
The educational posts site setting (`educate_until_posts`) feels buggy,
this is because the logic for showing these messages treats topics and
replies (posts) as a separate count.

If `SiteSetting.educate_until_posts` has a value of 2, the user can
write multiple replies to existing topics and see the "Welcome to our
community! You are brand new here..." message for the first 2 times then
it will not show again.

However, once they decide to create a topic they will see the message
again which doesn't feel right.

The solution is to use a combined count (`user.topic_count` and
`user.post_count`) and check against the site setting value. That way we
don't double up educational messages for both topics and replies when
using composer.
2025-07-17 18:15:18 +04:00
Ted Johansson
e05ef50c70
FIX: Disallow replies to categories when reply by email disabled (#33641)
When the reply_by_email_enabled setting is set to false, we no longer include a reply link in e-mail notifications. However, we do not prevent actual e-mails to a configured email_in address associated with a category.

This change into consideration the setting in Email::Receiver#check_address.
2025-07-17 11:10:15 +08:00
David Taylor
f4b70c746d
DEV: Extract theme script tags into their own JS files (#33647)
Previously, all script tags in a theme field would be combined into a
single `.js` bundle along with the `text/discourse-plugin` modules. This
led to some unexpected run order, and also makes it hard to implement
the `type=module` change being developed in #33103.

This commit refactors things so that each raw script gets extracted into
its own `.js` bundle, which is then placed in exactly the same place in
the HTML.
2025-07-16 17:17:36 +01:00
Krzysztof Kotlarek
2ee1c6d7d4
FIX: enforce system themes to be enabled (#33643)
Ensure that the system themes are always enabled.
2025-07-16 14:30:08 +08:00
Martin Brennan
679d51a985
FIX: Error in shadowed global settings for deprecated settings (#33642)
Followup 19af83d39e

There was another edge case here, where this scenario happened:

* A site setting is deprecated _without_ an override
* This site setting is being shadowed by a global setting
* This would cause an argument error when getting the deprecated
  setting value in SiteSetting.client_settings_json_uncached

An example of this setting was `external_system_avatars_enabled`.
The shadowed setting was blowing up because it was missing the
`scoped_to` argument that was added for themeable site settings
in the referenced commit.

This commit fixes the issue and adds a spec to cover this scenario,
followup commit will add stronger handling of shadowed global
settings for theme site settings...this is not allowed.
2025-07-16 14:04:05 +10:00
Martin Brennan
1b3e17e993
FIX: Error in client site settings JSON (#33640)
Followup 19af83d39e

In some scenarios, the client_settings_json_uncached
was silently failing and returning "", which caused
problems down the line in mini_racer when this code
was produced:

```
__optInput = {};
__optInput.siteSettings = ;
```

The problem was only happening in rare cases with interaction
between core and other plugins, because the length of the
array we were trying to make a Hash with wasn't an even length.

To address this, we can use filter_map to ensure correct behavior,
and add some specs and also raise errors when parsing client settings
JSON
in specs, so we don't miss this in the future.
2025-07-16 12:12:59 +10:00
Martin Brennan
19af83d39e
FEATURE: Themeable site settings (#32233)
This commit introduces the concept of themeable site settings,
which is a new tool for theme authors that lives alongside theme
modifiers and theme settings. Here is a quick summary:

* Theme settings - These are custom settings used to control UI and functionality within your theme or component and provide configuration options. These cannot change core Discourse functionality.
* Theme modifiers - Allows a theme or a component to modify selected server-side functionality of core Discourse as an alternative to building a plugin.
* Themeable site settings (new) - Allows a theme (not components) to override a small subset of core site settings, which generally control parts of the UI and other minor functionality. This allows themes to have a greater control over the full site experience.

Themeable site settings will be shown for all themes, whether the theme
changes
the value or not, and have a similar UI to custom theme settings.

We are also introducing a new page at
`/admin/config/theme-site-settings` that
allows admins to see all possible themeable site settings, and which
themes
are changing the value from the default.

### Configuration

Theme authors can configure initial values themeable site settings using
a section in the `about.json` file like so:

```json
"theme_site_settings": {
  "search_experience": "search_field"
}
```

These values will not change when the theme updates, because we cannot
know if admins have manually changed them.

### Limitations

Themeable site settings are only really intended to control elements of
the UI, and when retrieving their value we require a theme ID, so these
limitations apply:

- Themeable site settings cannot be used in Sidekiq jobs
- Themeable site settings cannot be used in markdown rules
- Themeable site settings will be cached separately to client site
settings using theme ID as a key
- Themeable site settings will override keys on the `siteSettings`
service on the client using the application preloader
- `SiteSetting.client_settings_json` will not include themeable site
settings, instead you can call `SiteSetting.theme_site_settings_json`
with a theme ID

### Initial settings

There are only two site settings that will be themeable to begin with:

* `enable_welcome_banner`
* `search_experience`

And our new Horizon theme will take advantage of both. Over time, more
settings that control elements of the UI will be exposed this way.
2025-07-16 11:00:21 +10:00
Régis Hanol
36157496f6
FEATURE: pass email to external auth on signup (#33559)
And forward them in "discourse id" so we can pre-fill the email field on
the signup page.

Also added `PreloadStore.has("key")` so we can quickly check a key is
present in the "preload store" without actually retrieving it.

Internal ref - t/154880
2025-07-15 16:17:01 +02:00
Linca
7a099ebb6a
FEATURE: Allow users to bulk recategorize silently (#33490)
We want to add an option for admins to carry out the operation silently
when they are updating the category for the selected topics. When the
“Perform this action silently” checkbox has been checked, the
`:notify_category_change sidekiq` job should not be enqueued.
2025-07-15 11:42:30 +08:00
Martin Brennan
33abb858e9
DEV: Add X-Discourse-BrowserPageView response header (#33598)
When we are tracking requests in the `Middleware::RequestTracker`, we
have historically added an `X-Discourse-TrackView` response header
for implicitly tracked requests HTML requests, and also explicitly
tracked page view requests when navigating the Ember app.

Within the past couple of years, we introduced the concept of
Browser Page Views (BPVs), which are recorded when requests are made
via AJAX when navigating the app with Ember, and also piggybacked
onto the first MessageBus request on page load. The former is known
as an explicitly tracked request, the latter is a deferred tracked request.

The explicitly tracked browser page views also add the `X-Discourse-TrackView`
header to the response, so it is hard to differentiate which requests are purely
browser page view requests in the logs.

This commit adds a new response header, `X-Discourse-BrowserPageView`,
that acts in a similar way to the existing `X-Discourse-TrackView`
header, but is specifically for requests that are tracked as BPVs (both explicit
and deferred).
2025-07-15 11:28:10 +10:00
Krzysztof Kotlarek
d164351458
DEV: remove deduplicate horizon script (#33595)
The Horizon theme is now in core, and the remote Horizon repo is
deprecated. This script is not needed anymore.
2025-07-14 14:34:47 +08:00
Linca
a3cff97b48
FEATURE: Make it easier for staff to see if a profile is silenced (#33537)
This commit make it easier for staff to see if a profile is silenced by
aligning it with how suspended notices are shown.

- The number of times a profile has been silenced is shown in the staff
counters banner at the top of the public user profiles.
- Clicking on the silenced note in the staff counters banner goes to a
filtered view of the staff action logs for the user and the silenced
action.
- The profile indicates if a user is silenced and shows the date they
are silenced until. This looks exactly the same as how it currently
displays for suspended users, with the added info of the date. This is
also displayed on the user card, the same as suspended notices currently
are.

## Screenshots


![image](https://github.com/user-attachments/assets/43cf8134-3391-43ff-98fe-fcba07c9e3dd)

![image](https://github.com/user-attachments/assets/2804dcba-70b2-4cf2-8a93-63433a23b481)
2025-07-14 12:44:31 +08:00
Kris
cb0b8351a9
A11Y: onebox avatars/images are decorative, so screenreaders can skip (#33572)
Adding `alt=""` to tell screenreaders to skip these, we don't reliably
have alt content available for onebox images and they tend to be
decorative, so better to omit.


<img width="738" height="151" alt="learn.microsoft.com onebox with the
link whats new in C# 11, there's a purple C# badge to the left of the
link"
src="https://github.com/user-attachments/assets/15bdc830-683f-4c69-a11b-9d54c66fa627"
/>


We already do this in some oneboxes, so this covers some more cases
including the generic.
2025-07-11 09:55:48 -04:00
Martin Brennan
afc5d13c63
FEATURE: Text heading/paragraph menu in composer toolbar (#33461)
This PR introduces a heading/paragraph dropdown menu for  the
composer toolbar, that works for both the new rich text editor, and
the old markdown editor.

Features include:

* Dynamically changing the icon based on the heading level
* Checking the current heading level in the dropdown list
* Applying the same heading level to multiple selections

---------

Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Renato Atilio <renatoat@gmail.com>
2025-07-11 12:29:58 +10:00
Régis Hanol
bccf4e0b53
FIX: improve "read only" modes (#33521)
The reasons for these changes is https://meta.discourse.org/t/-/89605
broke and admins were not able to log back in if they had previously
enabled the "read only" mode.

Thus ensued a deep dive into how all the "read only" modes worked, which
was made difficult due to the lack of tests.

The "cornerstone" of this PR is the `read_only_mixin.rb` file which was
improved to be able to differentiate between the "readonly" mode and the
"staff writes only" mode.

I then made use of the `allow_in_readonly_mode` and
`allow_in_staff_writes_only_mode` method to **explicitely** list all the
actions that should work in those modes.

I also added the "readonly" mixin to the `WebhooksController` since it
doesn't inherit from the `ApplicationController`.

I improved the security of the `/u/admin-login` endpoint by always
sending the same message no matter if we found or not an admin account
with the provided email address.

I added two system specs:

1. for ensuring that admins can log in via /u/admin-lgoin and then
clicking the link in the email they received while the site is in
readonly mode.
2. for ensuring the "staff writes only mode" is _actually_ tested by
ensuring a moderator can log in and create a topic while the site is in
that mode.

Plenty of specs were updated to ensure 100% converage of the various
"read only" modes.
2025-07-10 09:08:00 +02:00
Osama Sayegh
0dcbbe0de4
DEV: Load admin JS bundles from plugins for staff users (#33540)
JS assets defined under `admin/` in plugins are compiled into a separate
bundle that should be loaded for staff users only, but we currently load
it for all users including normal users and anons. This is wasteful and
unexpected since it could cause errors if an asset in the admin bundle
of a plugin imports a module from the admin bundle in core (which
doesn't get loaded for non-staff users).
2025-07-10 07:39:11 +03:00
Natalie Tay
12d433dfca
FIX: Also update topic locale on creation (#33544)
When a user creates a new topic via the composer and sets the locale, we
currently set the post's locale but not the topic's. This PR updates
that.
2025-07-10 00:33:20 +08:00
Bianca Nenciu
11bf7ad539
FIX: Handle restore URLs ending with query params (#33384)
Moving parsing the URL to the constructor ensures that is_archive is
correctly initialized. This allows .sql.gz backups to be restored.
2025-07-07 18:43:31 +03:00
Ted Johansson
4c7089f817
DEV: Deprecate external_system_avatars_enabled (#33436)
We want to deprecate the enabled/disabled toggle for this setting and rely entirely on the presence of a URL.

This change:

- Deprecates and hides the enabled/disabled setting.
- Updates all code paths and tests that rely on the old setting.
- Adds a migration that clears the URL if the enabled/disabled setting is set to false.
2025-07-04 16:02:04 +08:00
Natalie Tay
01d42ab524
FEATURE: Display locale change in post history modal (#33469)
This commit adds locale changes to the post history modal, and also updates
the topic's locale if the first post is being updated.
2025-07-03 23:08:47 +08:00
Ella E.
38194c2aec
DEV: First pass of review queue redesign
This is the start of the review queue redesign. Due to the rapidly
growing size of this redesign, this PR is being merged in a
semi-functional state: large chunks of it have the new design, but there
are substantial sections that may not function at all.

This PR is focussed on the variations of reviewable posts, other
reviewables (eg, users, chat messages) will continue to use the old UI.

Co-authored-by: Gary Pendergast <gary@pento.net>
2025-07-03 14:32:43 +08:00
Alan Guo Xiang Tan
ffeec9fb27 Revert "DEV: Introduce reviewable_ui_refresh site setting (#33404)"
This reverts commit bc29e5088e.
2025-07-03 13:31:27 +08:00
Ted Johansson
02e17ddb7f
FIX: Make hide_new_user_profiles work with manually upgraded users (#33458)
The site setting hide_new_user_profiles states:

> Hide trust level 1 or lower user profiles from the public and trust level 1 users until they post for the first time.

This implies that TL2 and above should be visible.

However, the actual logic encodes the assumption that TL2 have posted at some point. This fails to account for the fact that admins can manually upgrade a user without posts to a higher TL. This PR covers for that scenario.
2025-07-03 13:00:30 +08:00
Krzysztof Kotlarek
052cebce48
FIX: Horizon default color scheme must be user selectable (#33428)
Improvements:
- When import Horizon theme, ensure that default color scheme is marked
as `user_selectable`
- Dark version of the theme is `user_selectable` as well
- When merge remote Horizon into system Horizon, also ensure that
default color scheme is marked as `user_selectable`
2025-07-02 13:40:44 +08:00
Alan Guo Xiang Tan
bc29e5088e
DEV: Introduce reviewable_ui_refresh site setting (#33404)
This commit introduces an experimental `reviewable_ui_refresh` site
setting of `group_list` type. When a user is part of any group
configured in the site setting, the new reviewable UI will be shown to
the user.

Co-authored-by: Gary <gary@pento.net>
2025-07-01 15:31:26 +08:00
Krzysztof Kotlarek
c42333f264
FIX: improve the merge horizons task (#33394)
When the remote horizon color scheme is `user_selectable`, the system
color scheme should be as well.
2025-07-01 08:36:33 +08:00
Natalie Tay
b20d6792bf
FEATURE: Add a hidden setting to limit number of content localization locales (#33378)
We want to add a hidden limit to the number of locales an admin can set
for localization. This is a safe limit to prevent excessive localization
(if each post can be localized to 10 locales, that's 10x the amount of
storage and tokens needed).


t/157677
2025-06-30 15:29:58 +08:00
Krzysztof Kotlarek
39a43f7e76
DEV: rake task to merge the manually installed Horizon (#33355)
Rake task to merge a single installation of Horizon into the system
Horizon.

What task do:
- Set Horizon as `experimental_system_themes` if not yet included;
- Set system Horizon as the default if manual Horizon was the default;
- Set the system Horizon as selectable if the manual Horizon was
selectable;
- Link components from the manual Horizon to the system Horizon;
- Update UserOptions `theme_id`, `color_scheme_id` and `dark_scheme_id`;
- Update the system Horizon color palette to match the manual Horizon
color palette;
- Move ThemeSettings from manual Horizon to system Horizon;
- Move ThemeTranslations from manual Horizon to system Horizon;
- Delete manual Horizon color schemes;
- Delete the manual Horizon.

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2025-06-30 14:40:46 +08:00
Osama Sayegh
12dbbadbc1
DEV: Add modifier for restricting theme creation endpoints (#33313)
This commit adds a new modifier that plugins can hook into to add further
restriction to who can install themes and components via the admin UI. It
isn't possible to use this modifier to open up the theme installation
permissions to more than core allows, e.g. this modifier can't be used
to allow moderators to install themes on the site.

Internal topic: t/156924.
2025-06-30 09:26:02 +03:00
Renato Atilio
88b37a715a
DEV: ensure retries do not re-set attempts=0 (#33365) 2025-06-27 06:51:10 -03:00
Sam
e180c62d2e
FEATURE: new search order for read topics (#33353)
Introduces order:read and r to search through recently read topics

Also applies to filter route
2025-06-26 17:02:52 +10:00
Penar Musaraj
00c97178d5
FIX: Don't allow submitting bulk topic actions without a notification… (#33292)
… level

See report https://meta.discourse.org/t/-/371074

---------

Co-authored-by: Blake Erickson <blake@discourse.org>
2025-06-25 14:48:36 -06:00
Alan Guo Xiang Tan
99ab4608dc
FIX: Ignore recent posts offset in search when before/after filters are used (#33323)
There exists a hidden `search_recent_regular_posts_offset_post_id` site
setting which is used to optimize the searching of recent posts through
the use of a partial index. However, we do not want this optimization to
apply when the `before` and `after` advanced search filters are used
since the partial index only contains the most recent posts 1 million
posts and the `before`/`after` filter may be searching for posts that
falls outside of the
most recent posts range.
2025-06-25 15:23:08 +08:00
Alan Guo Xiang Tan
b9628ad40a
DEV: Update uploads:sync_access_control rake task to remove ACLs (#33286)
The `uploads:sync_access_control` rake task should reset the access
control
of all s3 objects linked to an upload record. This means that if the
`s3_use_acls` site setting has been disabled, the rake task should
remove the existing ACL that has been set previously.
2025-06-25 15:03:05 +08:00
Alan Guo Xiang Tan
3eb252c9d1
Bump version to v3.5.0.beta8-dev 2025-06-25 10:52:27 +08:00
Alan Guo Xiang Tan
fd2f543a08
Bump version to v3.5.0.beta7 2025-06-25 10:52:27 +08:00
Alan Guo Xiang Tan
0b1dd04550
SECURITY: Don't display user's old whispers if not in allowed group
Before this change, users were able to see their own whispers even if
they are no longer in the groups specified by the `whispers_allowed_groups` site setting.

This commit fixes that by disallowing users to see their own whispers if
they are no longer part of any `whispers_allowed_groups`.
2025-06-25 10:25:44 +08:00
Gary Pendergast
cef46d612f
DEV: Add "UI" as a humanizable acronym (#33322)
Site settings with the acronym "ui" in them will now have it formatted as "UI".
2025-06-24 15:42:35 +10:00
Martin Brennan
5b236ccc07
DEV: Move site setting name humanization to server side (#33311)
This commit moves the humanization of site setting names from the client
side to the server side, since this is becoming more widely used and
will be useful for specs to be able to access the same humanized name
formatting without duplicating the logic on the server.

There are only a couple of places in the admin UI that we send this
down in the JSON, the `site.sitSettings` object does not include these
humanized names as they are not needed.
2025-06-24 13:20:29 +10:00
Loïc Guitaut
3fbb2954cb DEV: Refactor Chat::ListChannelMessages service a bit
- improve the contract a little
- use `model` where possible
- extract message existence logic to a dedicated policy, allowing easier
  testing.
- remove unused code
- refactor specs to follow current guidelines/best practices
2025-06-23 14:18:49 +02:00