10447 Commits

Author SHA1 Message Date
Loïc Guitaut
f057c71fc8 DEV: Follow-up to the lock step for services
This patch adds two things:

1. An outcome matcher (`on_lock_not_acquired`), allowing to react when
   there was a problem with the lock.
2. Compatibility with the steps inspector, allowing to display properly
   the steps of a service containing locks.
2025-02-06 11:38:15 +01:00
Ted Johansson
997a9e3de9
FEATURE: Allow excluding uploads from min post length requirement (#31194)
Currently, the markdown for uploads is counted towards post minimum length requirements. This change introduces a site setting `prevent_uploads_only_posts` which can be flipped to exclude upload segments from the calculation.
2025-02-06 10:26:23 +08:00
Martin Brennan
8f72a57363
UX: Conditionally refresh page on wizard styling step (#31193)
Previously, were always forcing the page to reload
for the wizard after pressing Next for the styling step,
with the logic that if style changes are being made,
the admin needs to see them straight away.

However this doesn't make sense if nothing changes on
that step. This commit makes the change to only refresh
the page if any of the settings on the step changed,
bringing it in line with other steps.
2025-02-06 10:31:22 +10:00
Ted Johansson
bb12f8275d
DEV: Only include custom admin UIs in the plugins index tabs (#31192)
In the current admin index page, all plugins show up as tabs. This includes plugins with auto-generated config routes.

This changes the tabs to include only plugins with custom UIs.
2025-02-05 15:02:46 +08:00
Renato Atilio
0e61565b2b
FEATURE: introduce a ProseMirror editor (#30815)
This is the first in a series of PRs to introduce a
ProseMirror-based
WYSIWYM editor experience
alongside our current textarea Markdown editor.

Behind a hidden site setting, this PR adds a toggle to the composer
toolbar, allowing users to switch between the two options.

Our implementation builds upon the excellent ProseMirror and its
non-core Markdown
module, using the
module's schema, parsing, and serialization definitions as the base for
further Discourse-specific features.

An extension API is included to enable further customizations.

The necessary extensions to support all Discourse's core and core
plugins features **will be implemented in subsequent PRs**.

---------

Co-authored-by: David Taylor <david@taylorhq.com>
2025-02-04 14:37:18 -03:00
Roman Rizzi
ee33535013
Bump version to v3.5.0.beta1-dev 2025-02-04 13:49:16 -03:00
Roman Rizzi
76e7f12a6d
Bump version to v3.4.0.beta4 2025-02-04 13:49:16 -03:00
OsamaSayegh
416ec83ae5
SECURITY: Limit /inline-onebox to 10 URLs at a time 2025-02-04 13:32:53 -03:00
David Battersby
3d47a1268c
SECURITY: Ability to bypass disabling chat of users 2025-02-04 13:32:42 -03:00
Blake Erickson
17116c440b
SECURITY: Restrict allowed URL patterns
Restrict allowed URL patterns for oneboxes.
2025-02-04 13:32:34 -03:00
Alan Guo Xiang Tan
17e1bfe069
SECURITY: Preload data only when rendering application layout
This commit drops the `before_action :preload_json` callback in `ApplicationController` as it adds unnecessary complexity to `ApplicationController` as well as other controllers which has to skip this callback. The source of the complexity comes mainly from the following two conditionals in the `preload_json` method:

```
    # We don't preload JSON on xhr or JSON request
    return if request.xhr? || request.format.json?

    # if we are posting in makes no sense to preload
    return if request.method != "GET"
```

Basically, the conditionals solely exists for optimization purposes to ensure that we don't run the preloading code when the request is not a GET request and the response is not expected to be HTML. The key problem here is that the conditionals are trying to expect what the content type of the response will be and this has proven to be hard to get right. Instead, we can simplify this problem by running the preloading code in a more deterministic way which is to preload only when the `application` layout is being rendered and this is main change that this commit introduces.
2025-02-04 13:32:30 -03:00
Loïc Guitaut
5055a071b8 FIX: Allow to follow non-ASCII canonical links for oneboxes 2025-02-04 15:40:23 +01:00
Kelv
65324b6e5d
DEV: enable raise_error in test envs for deprecated icons in svg_sprite.rb (#30980)
This PR raises an error on any deprecated icon names being converted by
svg_sprite.rb, which will result in any deprecated icons being processed
by the ruby lib to fail tests.
2025-02-04 21:21:20 +08:00
Ted Johansson
503f9b6f02
DEV: Use default admin routes for plugins with settings (#30941)
This change adds a sidebar link for each plugin that fulfils the following criteria:

- Does not have an explicit admin route defined in the plugin.
- Has at least one site setting (not including enabled/disabled.)

That sidebar link leads to the automatically generated plugin show settings page.
2025-02-04 14:57:28 +08:00
David Taylor
30bea25631
DEV: Tweak db:create re-exec (#31132)
Rake allows env variables to specified in arguments, so we need to use
the list of top_level_tasks which excludes those env

Followup to c8718a64dd7a26165efe91706ce5507e6999044a.
2025-02-03 16:57:01 +00:00
David Taylor
c8718a64dd
DEV: Re-exec rake after creating database (#31120)
By design, db:create initializes the Rails app with SKIP_DB=true. That
means that SiteSettings get set up with the LocalProcessProvider instead
of the DBProvider. In other words: any calls to site settings will
return the default, rather then the actual value in the database.

Running db:migrate in the same rake invocation means that rails will not
be re-initialized, and so skip_db will remain true. Site settings
accessed during migrations and fixtures will therefore return incorrect
values.

One example of this is that running bin/rake db:create db:migrate
repeatedly in a development environment will cause the FAQ topic to be
seeded repeatedly, because the seed logic does not have access to the
site setting which stores the already-seeded topic id.

This commit will automatically re-exec the Rake command if any tasks are
specified after `db:create`
2025-02-03 15:51:52 +00:00
Martin Brennan
d28a4edd1f
FIX: Hacker News onebox favicon (#31115)
This file has changed at some point to an svg instead
of a gif
2025-02-03 09:17:13 +10:00
Jarek Radosz
3a93a61092
FEATURE: Remove unnecessary org names from PR oneboxes (#31102)
Instead of displaying:

`discourse:main <- discourse:feature` or `discourse:main <-
user:feature`

shows:

`main <- feature` or `main <- user:feature`
2025-02-01 01:05:08 +01:00
Arkshine
a6b136977c
DEV: Add missing clock icon to the svg_sprite list (#31093)
Meta:
https://meta.discourse.org/t/the-icon-clock-is-missing-from-the-default-svg-subset/349823/3

This adds the missing `clock` icon to the default SVG subset.
The icon is used in the GitHub PR onebox and the user's activity pending
posts tab.


![image](https://github.com/user-attachments/assets/24c639ac-fb72-4180-aa3b-75b107ae4e07)


![image](https://github.com/user-attachments/assets/cffd878a-3889-4f59-87d8-8ade1f292a33)
2025-01-31 15:47:30 +01:00
Rafael dos Santos Silva
68dde7887a
FEATURE: Handle newer url format for Twitch clips (#31080) 2025-01-31 10:42:46 -03:00
Alan Guo Xiang Tan
a9eefd1b48
DEV: Support synchronous mode for uploads:sync_s3_acls rake task (#31091)
This commit updates the `uploads:sync_s3_acls` rake task to accept a
`sync` argument that would run the rake task in a synchronous manner
so that the outcome of running the rake task can easily be determined.
2025-01-31 17:34:34 +08:00
Alan Guo Xiang Tan
76ade65a26
DEV: Remove optimized_images_preloaded kwarg from FileStore::S3Store#update_upload_ACL (#31087)
The optimization is not required because `find_each` fetches records in
batches of 1000 and no upload record will have more than 1000 optimized
images.
2025-01-31 15:53:06 +08:00
Blake Erickson
dfb64f9b84
FIX: Quoting videos can show a corrupted thumbnail (#31079)
This change ensures we use the base62 sha1 for videos when quoting
because this is what the composer is used to using. With a valid base62
sha1 the composer already knows how to fetch the placeholder image for
it.

Fallbacks have been created to continue to support the old way as well
as a fix for the old way so that the thumbnail continues to display when
quoting. These fallbacks are in place so that we don't have to rebake
all posts that contain videos. If we ever do that we may remove these
fallbacks.
2025-01-30 17:54:50 -07:00
Martin Brennan
5ebbba250a
DEV: Include lib/stylesheet mtime in stylesheet cache (#31063)
Followup 23edfe7cc27cd56d5806c965ac52ed2b0394e8b8

When working on changes to any of the lib/stylesheet/*.rb
files, the color_definitions.scss and other stylesheet
caches can be annoyingly persistent.

This commit adds all of these lib files to the `max_file_mtime`
part of the `fs_asset_cachebuster` cache key, so if any of
them are changed then the cache will break, making development
a lot easier.
2025-01-31 09:32:10 +10:00
Krzysztof Kotlarek
d75a0b1165
FIX: Remove groups when promotion is recalculated. (#31058)
The group has `grant_trust_level` setting which automatically updates
the trust level when the user is added to the group.

Similarly, when the user is removed from the group, the trust level is
recalculated.

There was a bug that when the trust level was downgraded, the user was
not removed from automatic groups like for example `trust_level_3`.
2025-01-30 14:24:18 +11:00
Régis Hanol
a16b2f2248
DEV: new lock step for services (#30872)
That allows services to wrap steps within a Distributed lock (mutex).
2025-01-29 14:28:22 +01:00
Régis Hanol
cfa281a697
FIX: remove muted topics/tags/categories from top and hot topics lists (#30892)
So it matches the behavior of latest and new.
2025-01-29 11:51:10 +01:00
David Taylor
a480c40f81
Revert "DEV: Upload assets to S3 in parallel (#30210)" (#31050)
This reverts commit b9f8a77d9ba5222bbf55172092f0b235b92d1c85.

Reverting while we work on adding error handling. At the moment,
failures are logged, but the process still exits with status=0.
2025-01-29 10:03:56 +00:00
Martin Brennan
15838aa756
DEV: Convert AdminReport component to gjs (#31011)
This commit converts the `AdminReport` component, which is quite
high complexity, to gjs. After this initial round, ideally this
component would be broken up into smaller components because it is
getting quite big now.

Also in this commit:

* Add an option to display the report description in a tooltip, which
was
   the main way the description was shown until recently. We want to use
   this on the dashboard view mostly.
* Move admin report "mode" definitions to the server-side Report model,
inside a `Report::MODES` constant, collecting the modes defined in
various
   places in the UI into one place
* Refactor report code to refer to mode definitions
* Add a `REPORT_MODES` constant in JS via javascript.rake and refactor
  JS to refer to the modes
* Delete old admin report components that are no longer used
  (trust-level-counts, counts, per-day-counts) which were replaced
  by admin-report-counters a while ago
* Add a new `registerReportModeComponent` plugin API, some plugins
   introduce their own modes (like AI's `emotion`) and components and
   we need a way to render them
2025-01-29 10:33:43 +10:00
Alan Guo Xiang Tan
c0fdb2f33d
PERF: Optimize uploads:disable_secure_uploads to load in batches (#31030)
This commit updates the `uploads:disable_secure_uploads` to be more
memory efficient by loading records in batches instead.
2025-01-28 15:31:00 +08:00
Krzysztof Kotlarek
cfcc60f847
FEATURE: new fast_typing_threshold site setting (#30865)
Rename `min_first_post_typing_time` to `fast_typing_threshold` and
provide admin 4 options:
- disabled
- low - 1 second
- standard - 3 seconds
- high - 5 seconds

Related PRs:
- https://github.com/discourse/discourse-zoom/pull/112
2025-01-28 09:53:03 +11:00
Martin Brennan
78a857931c
FEATURE: Improve wizard font selection and set Inter as default font for new sites (#30974)
This commit narrows down the list of fonts we offer
in our setup wizard and simplifies things to only
show a single font dropdown. This selection will then
set the `base_font` and `heading_font` site setting to
the same value.

For existing sites that may have set different values,
we will still show 2 dropdowns when visiting the wizard.

We are also changing our default font to the more modern
selection Inter, replacing Arial. Arial is very dependent
on system installed fonts, whereas Inter we can package
to everyone in Discourse.

Finally, for existing sites that have not changed their default
from Arial, we will keep that value via a migration so we do
not surprise site owners with a completely new font.
2025-01-27 11:29:55 +10:00
Sam
8be16c997e
FIX: truncate extremely long site name titles (#30977)
This corrects an issue where very long titles on
website would cause the backup not to save
cause filename was too long
2025-01-24 15:47:05 +11:00
Natalie Tay
8d45755a06
FEATURE: Allow setting locale from 'lang' param (#30952)
As we start to translate more pages, we'll need a way for other sites to
link back to our translated topics.

This commit gives us the ability to use the "lang" URL param to define what
language a site should be in.

Related: https://github.com/discourse/discourse-translator/pull/199
2025-01-24 11:53:13 +08:00
Gary Pendergast
7d2fcb8812
FIX: Only apply the rate limit to user exports, not downloads (#30965)
Follow-up to 7fc8d74f3eed52116add452b5321b41e02e04499.

This change moves the guardian check for whether an export has been generated too recently to the endpoint handler, since we only want this check to apply when generating an export.
2025-01-24 09:37:05 +11:00
Gary Pendergast
7fc8d74f3e
FEATURE: Allow admins to export users (#30918)
The GDPR requires all users to be able to export their data, or request an export of their data. This is fine for active users as we have a data export button on user profiles, but suspended users have no way of accessing the data export function, and the workaround for admins to export data for suspended users involves temporarily unsuspending them, then impersonating the user to export the data as them.

Since suspended users no longer have access to their account, we can safely assume that the export request will be coming via a medium outside of Discourse (eg, email). This change is built with this workflow in mind.

This change adds a new "User exports" section to the admin user page, allowing admins to start a new export, and to download the latest export file.
2025-01-24 08:13:25 +11:00
Osama Sayegh
10f34ddf86
DEV: Backend support for light/dark mode in color palettes (#30893)
We're embarking on a project for overhauling the color palette and theme
systems in Discourse. As part of this project, we're making each color
palette include light and dark modes instead of the status quo of
requiring 2 separate color palettes to implement light and dark modes.

This commit is a first step towards that goal; it adds a code path for
generating and serving `color_definitions` stylesheets using the
built-in dark variant of a color palette. All of this code path is
behind a default-off site setting `use_overhauled_theme_color_palette`,
so there's no change in behavior unless the setting is enabled.

Internal topic: t/141467.
2025-01-23 15:54:49 +03:00
Martin Brennan
83cc97994f
FEATURE: Handle special font properties from discourse-fonts (#30891)
In https://github.com/discourse/discourse-fonts/pull/15 we are
introducing special font properties for certain fonts,
specifically the `font-variation-settings` and `font-feature-settings`.
For now this will only apply to Inter, but we may do it for other
fonts in future.

This commit makes it so the color_definitions.css file includes
these special properties for each font, either defined on the
root `html` element for the body font or on the `h1-h6` elements
for the heading font. This is done in this way because defining
them on `@font-face` is ignored by the browser.

This also ensures special CSS classes for the wizard container
e.g. wizard-container-font-FONTID are defined, this is so we can
use these special properties scoped to the font selected in the
wizard, which will affect the way the canvas preview is rendered.

Here is an example of before/after with special properties applied to
Inter,
in this case:

```css
font-variation-settings: 'opsz' 28;
font-feature-settings: 'calt' 0, 'ccmp' 0, 'ss02' 1;
```
2025-01-22 10:56:09 +10:00
David Taylor
6fd577d97d
FEATURE: Improve use_email_for_username_and_name_suggestions (#30845)
Previously this setting would only control values received in an 'email'
field from an identity provider. This commit extends it, so that it also
applies to email-like content in other fields. This provides improved
protections against partial email addresses being leaked
2025-01-21 13:04:48 +00:00
David Taylor
23edfe7cc2
FIX: Invalidate stylesheet cache when discourse-fonts is bumped (#30869) 2025-01-20 12:25:28 +00:00
Ted Johansson
96b725a11c
FIX: Don't allow editing own posts user can no longer see (#30839)
In a PM, if a user has made a post, and is later removed from the PM, they can still edit their own post. This can be done either if they happen to have a composer open in an active tab, or by just manually sending an HTTP request.

The post guardian is missing a basic check, can_see_post_topic? when we determine whether a user can edit a post or not. This basic check is already in place when we determine whether a user can see the post in the first place.

This PR adds in the missing check, so that if the user tries to edit their post after being removed, they'll receive a 403.

It also adds a MessageBus message scoped to the affected user and topic when they are removed from the PM, which will redirect them to their inbox. This helps avoid a stale tab where they are still in the PM which they by right can now no longer see.
2025-01-20 10:09:58 +08:00
Régis Hanol
5d76f2e343
FIX: only attach images in digests (#30844)
When secure uploads are enabled, we have to attach the images in the
digest so they can show up in the email.

However, we send attaching all the attachments, including "files" and
"media".

This ensures we only attach images when sending a digest.

Internal t/144542
2025-01-17 15:36:47 +01:00
Krzysztof Kotlarek
029bd6feda
FEATURE: setting allowing tl0/anonymous flag illegal content (#30785)
The new site setting `allow_anonymous_and_tl0_to_flag_illegal` allows
tl0 users to flag illegal content. In addition, anonymous users are
instructed on how to flag illegal content by sending emails.

Also `email_address_to_report_illegal_content` setting is added. If not
provided, then the site contact email is used.
2025-01-17 08:57:44 +11:00
Martin Brennan
35507d4090
FIX: Process tag synonyms when approving reviewable queued post (#30810)
Followup 72c4709a5ab26f00e32b65d874b3a206d679181e

Previously we made a fix to allow skip validations when tagging
a topic via TopicCreator. However, this flow also skips a lot of
the more in-depth work on tags we do when creating a topic, like
processing tag synonyms. When approving reviewable queued posts,
we skip validations, so this would cause an issue where a topic
was approved and the tag synonyms weren't applied.

This commit changes the logic so we attempt the more complete
`DiscourseTagging.tag_topic_by_names` call first and if this fails
and skip validations is on, then we do
`DiscourseTagging.add_or_create_tags_by_name`.
This at least gives a chance for the full workflow to work first.
2025-01-16 11:01:45 +10:00
Natalie Tay
cfac49fb10
FIX: Include original filename in s3 uploads even if not attachment (#30789)
Related: https://github.com/discourse/discourse/pull/30535

In the PR above, the [content-disposition
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
was removed for all non-svg files due to the "attachment" keyword added
to them, causing files to be downloaded instead of opening in a new tab
when requested. When removing that, it also removed the filename
attribute attached to s3 uploads.

After some testing, it turns out that `filename` is also respected when
next to `inline`, despite it not being obvious [in
docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#syntax).
This commit adds inline+filename so that users can still download files
and have filenames be respected instead of using the s3 hash.
```http
<!-- mdn docs -->
Content-Disposition: inline
Content-Disposition: attachment
Content-Disposition: attachment; filename="file name.jpg"
Content-Disposition: attachment; filename*=UTF-8''file%20name.jpg
<!-- this actually works too -->
Content-Disposition: inline; filename="file name.jpg"
```
2025-01-15 18:08:18 +08:00
Alan Guo Xiang Tan
1a70d118a8
FIX: S3Inventory#backfill_etags_and_list_missing need to unescape key (#30787)
The `key` provided in the S3 inventory file will esacpe any special
characters in the filename of the key so we need to unescape. Otherwise,
uploads with extensions that conatins special characters will fail to
match records which we insert into the temporary table based off the
s3 inventory file.
2025-01-15 14:52:49 +08:00
Martin Brennan
061899fee4
UX: Wizard homepage dropdown improvements (#30763)
* Do not offer "categories with latest" option anymore, it does
  not look good with our default Sidebar selection
* Display a sensible item in the dropdown if the admin has not
  chosen hot, latest, or category_boxes as the homepage style,
  before it was broken. Now we show Custom with a little blurb
  about whether topics or categories are shown, and what the landing
  page is


![image](https://github.com/user-attachments/assets/3e392583-d107-489e-9725-62d995a2d341)
2025-01-15 16:49:47 +10:00
Martin Brennan
125e686bf2
FIX: Do not allow_any on fonts site_settings (#30780)
Both heading_font and body_font should not allow
additional user-defined values, these are lists with
predefined choices. The UI already prevents this
because the font selector dropdown is unique, but
we want to make sure the setting definition reflects
this too.
2025-01-15 14:13:34 +10:00
Mark VanLandingham
a89086f799
DEV: Add per_page as public param for TopicQuery (#30716)
This change allows controllers that construct TopicQuery parameters, to pass per_page into the TopicQuery constructor as an option. I can't see why this shouldn't be a public param, so long as we properly validate the value!

Internal discussion at t/145686.
2025-01-14 09:19:19 -06:00
Ella E.
dff1327eba
UX: Remove flat icons from wizard step two (#30761)
### What's changed?
This PR removes the flat icons from wizard step 2, as they are not used
elsewhere in the wizard. Keeping the steps consistent with the existing
style improves visual alignment and avoids unnecessary elements.

### Before
<img width="511" alt="image"
src="https://github.com/user-attachments/assets/9e8b6f46-7c35-433b-9f5e-511579bc4768"
/>


### After
<img width="514" alt="image"
src="https://github.com/user-attachments/assets/028e52af-9777-4733-8ff4-1daab5b39e22"
/>
2025-01-13 23:04:42 -07:00