Commit Graph

10637 Commits

Author SHA1 Message Date
d5b72a54ae Revert "FEATURE: Add post language on creating a new post (#33001)" (#33157)
This reverts commit b55af383f779d01d983a3ccf1149438aee9c6725.
2025-06-11 08:01:56 -07:00
b55af383f7 FEATURE: Add post language on creating a new post (#33001)
## 🔍 Overview
Previously we added the ability to translate existing posts in different
languages: https://github.com/discourse/discourse/pull/32564. In this
update we add the ability to set a post language upon initially creating
a post.

Internally, we also clean-up/improve a few things, like:
- adding a `PostLanguageSelector` component
- Adding a `available_content_localization_locales` onto `SiteSetting`
so it's available in the service (without needing to parse the JSON to
access it)
- fix issues with the translation-editor not working due to some
regressions from here: https://github.com/discourse/discourse/pull/32869
- ensure everything works for replies/drafts/edits

## 📷 Screenshots
![Screenshot 2025-06-05 at 12 03
24](https://github.com/user-attachments/assets/ff334575-ba30-4c52-9e9a-4054f69795ec)
2025-06-11 07:29:05 -07:00
1f2efa7954 FEATURE: Add utilities for importing and exporting backups (#32992)
This commit introduces new features and utilities related to the backup
and restore system that make use of remote URLs:

- `discourse restore` accepts a URL to a backup file

- `discourse backup_url` generates a URL of a backup file (S3 only)

- `discourse import_backup_url` downloads a backup file from a URL to
the configured backup store

This can be used to move content between two Discourse instances by
backing up the entire site, copying the backup URL, importing or
restoring it on the other instance.
2025-06-11 15:44:10 +03:00
f057866070 FEATURE: Add X-Discourse-Sender Header to outgoing mail (#33123)
When there is a relevant `username` associated with an outgoing email,
like in the case of post notifications, the `X-Discourse-Sender` header
will be added to the email, indicating the sender's username.

This mimics the `X-GitHub-Sender` header used by GitHub, which is useful
for filtering and categorizing emails based on the sender.
2025-06-10 10:45:31 +10:00
8074c8dadd FIX: Moment locale loading in type=module (#33128)
The moment locale files expect `this.` to be the window object. In a
type=module, `this` is `undefined`. This commit wraps the
moment-timezone definitions in an IIFE to resolve that.

Also adds a system spec to prevent future moment-timezone regressions.

Followup to a2b0c193dff40278c0a93995cc9b97b05dc8abb2
2025-06-09 14:20:04 +01:00
27227c9ece DEV: Simplify CORS logic for public asset routes (#33106)
Previously we would check the request for a matching CDN hostname before
applying the `Access-Control-Allow-Origin` header. That logic requires
the CDN to include its public-facing hostname in the `Host` header,
which is not always the case.

Since we are only running this `apply_cdn_headers` before_action on
publicly-accessible asset routes, we can simplify things so that the
`Access-Control-Allow-Origin: *` header is always included. That will
make CDN config requirements much more relaxed.

At the moment, this is primarily relevant to the HighlightJsController
routes, which are loaded using native JS `type=module`. But in the near
future, we plan to expand our use of `type=module` to more critical JS
assets like translations and themes.

Also drops the `Access-Control-Allow-Methods` header from these
responses. That isn't needed for `GET` and `HEAD` requests.
2025-06-09 08:58:27 +01:00
b1d4db17e3 Bump version to v3.5.0.beta7-dev 2025-06-09 12:19:57 +08:00
189e1361e1 Bump version to v3.5.0.beta6 2025-06-09 12:19:56 +08:00
aa6d0bb685 SECURITY: Respect max length in bot-human PMs
…and work around long-url parsing issue.
2025-06-09 12:04:11 +08:00
Nat
72e224b762 SECURITY: Escape topic title for mailers 2025-06-09 12:04:06 +08:00
60a3fe41d2 FIX: Disallow encoded words in e-mail addresses (#33083)
RFC 5322 allows special characters, including ? and =, to be used in e-mail addresses.

RFC 2047 is an extension that adds a feature called "encoded words" which let you embed different encodings in the same header. However, it explicitly says that these aren't allowed in e-mail address headers.

Encoded words have the format:

encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
Where encoding is either Q or B, but could take on other values in the future.

After this change we consider e-mail addresses with an encoded word inside invalid.
2025-06-05 12:58:01 +08:00
9613f657d0 DEV: remove educational tips and associated site settings (#33012)
Removes the composer educational tips for:

- upload avatar
- sequential replies 
- reviving old topic

We are also removing the associated site settings that are now
redundant:

- Disable avatar education message
- Sequential replies threshold
- Warn reviving old topic age
2025-06-03 09:44:35 +04:00
3ff96d6cfc FIX: correctly unescape title for amazon oneboxes (#33010)
Fixes `&` in onebox title and replaces with `&`.
2025-06-02 17:50:13 +05:30
6912025564 FIX: restore category text color field (#32915)
Restores the category text/foreground color field that was removed in
#32015.

We are also retaining the auto text color selection that was introduced
and applying on background color change rather than when the form is
saved. The text color algorithm has been changed from color brightness
to use color difference instead, which appears to be more reliable.

Algorithm for color difference:
https://www.w3.org/TR/AERT/#color-contrast

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2025-06-02 12:16:38 +04:00
291953c4f0 DEV: Remove unused method (#33008)
Method is not being used anywhere
2025-05-30 15:41:48 +08:00
0187853aad DEV: Remove stale s3:correct_acl and s3:correct_cachecontrol tasks (#33005)
Both rake tasks do not account for secure uploads so they should be
considered broken. Since there is no longer a need for these rake tasks,
we are removing them instead of spending time to fix them.
2025-05-30 14:39:37 +08:00
ecc64e3925 DEV: Remove UploadFixer and uploads:fix_all_extensions rake task (#33004)
The code being removed here was added 7 years ago and is stale at this
point. We don't even know if it is safe to run since no tests have been
written for it. Therefore, it is safer for us to remove it than to spend
time reviewing it.
2025-05-30 14:11:55 +08:00
ce6e8a9809 FEATURE: Show language switcher for anons (#32965)
Related: 
- https://github.com/discourse/discourse-translator/pull/308
- https://github.com/discourse/discourse/pull/32920 (setting introduced)

Moving the switcher to core, as the setting is now in core.
2025-05-29 11:37:20 +08:00
f99c17d52b Bump version to v3.5.0.beta6-dev 2025-05-28 12:34:15 +08:00
0db6f59383 Bump version to v3.5.0.beta5 2025-05-28 12:34:14 +08:00
06d3d3f418 DEV: Import likes into user_actions table (#32921)
Likes given / likes received on user admin page were empty because of
this missing data. Also, a background job cleared the like stats from
`user_stats` table after some time because of this missing data.
2025-05-27 22:08:51 +02:00
1de8960d2a FIX: Serve RTL CSS for themes and components (#32916)
Follow up to https://github.com/discourse/discourse/pull/32881

Stylesheet `<link>` tags for themes/components are aren't getting
included/rendered in the HTML document due to a missing check in
stylesheet manager. See
https://meta.discourse.org/t/ui-layout-broken-for-rtl-language-after-latest-update/367434?u=osama.
2025-05-27 03:15:05 +03:00
b485e04e4f FEATURE: Also localize banners (#32908)
Banners take a different route and are retrieved separately.
2025-05-26 13:16:22 +08:00
b4990ccb71 DEV: Compile and serve rtl versions of theme CSS (#32881) 2025-05-23 13:48:57 +01:00
e2fe5671ed DEV: Resolve mixed-decls misconfiguration (#32858)
Marking mixed-decls as silenced & fatal simultaneously is causing a
warning "Ignoring setting to silence mixed-decls deprecation, since it
has also been made fatal"

The intention is for it to be silenced for themes/plugins, but fatal for
core.
2025-05-22 13:52:20 +01:00
1eba96a75f DEV: Remove branding and styling steps from wizard (#32797)
https://github.com/discourse/discourse/pull/32797
2025-05-21 09:46:49 +08:00
9d70336bab DEV: support un-hiding site settings programmatically (#32824)
This might be useful to revert changes made by plugins when they're
disabled for example.
2025-05-20 21:44:56 +02:00
0de08e780b UX: better error message when social login fails (#32772)
This improves the error message(s) displayed when an error happens while
using a social login to log in / sign up into a Discourse community.

Unfortunately, we can't be super precise in the reason behind the error
(it can be the user clicked "cancel" during the authorization phase, or
any of the plethora of other possible errors) because the reason isn't
provided (either for security reasons, or because it's just hard to do
so in a reliable & consistent way accross all social logins).

The best I could do was to

- add the name of the "social login" provider in the error message
- tweak the copy a bit for the different cases handle
- fix the CSS/HTML to match the one used by the main application

In order to show the name of the provider, we use either the "provider"
or the "strategy" query parameter, or use the name of the authenticator
(if it's the only one enabled).

Internal ref - t/153662

---

**BEFORE**


![before](https://github.com/user-attachments/assets/67579a3e-5a61-4e8f-aa72-4dc375547e39)

**AFTER**


![after](https://github.com/user-attachments/assets/954f9c8a-e865-44ff-b1e3-841393a26edf)
2025-05-20 16:22:38 +02:00
d86b4ff298 DEV: Remove precompile for locale js (#32799)
The Rails asset pipeline isn't used for locale bundles any more. Plus,
`assets.precompile` isn't used for anything since we switched to
propshaft.
2025-05-19 11:08:01 +01:00
41363a2a18 DEV: Silence scss mixed-decls for themes/plugins (#32750)
Fixing this everywhere will be a very large undertaking, so we're
deferring it until there is a concrete timeline for it becoming an error
in sass.

In the meantime, we'll be adding a stylelint rule to enforce ordering of
declarations/nested-blocks/mixins, so that will go some way towards
avoiding this deprecation.
2025-05-16 13:06:10 +01:00
d564386066 UX: Add discourse text icon (#32744)
![CleanShot 2025-05-15 at 12 02
49@2x](https://github.com/user-attachments/assets/eacf0376-4491-4fcd-8e7e-c052564f0093)
2025-05-15 15:58:32 +02:00
d90b03f3bf DEV: Remove deprecated/archived theme from CI (#32747) 2025-05-15 13:04:43 +01:00
4df5638b3f DEV: Remove discourse-logster-rate-limit-checker from official plugins (#32727)
This is a plugin that is no longer maintained.
2025-05-15 09:10:15 +08:00
267736e5bc DEV: Show login-required splash in root route (take 2) (#32629) 2025-05-14 11:25:43 -04:00
c8d49a4d0a UX: split admin logo and fonts to separate pages (#32700)
Before we had logo and fonts page merged together. Decided to split
them.
2025-05-14 14:02:34 +08:00
4d99c839b6 FEATURE: porting type object to site settings (#32706) 2025-05-13 14:30:24 -03:00
da111d87bd DEV: adds unregister_locale (#32676)
Running this spec locally I was getting an error:

```
  1) translate accelerator plugins loads plural rules from plugins
     Failure/Error: DiscoursePluginRegistry.unregister_locale("foo")

     NoMethodError:
       undefined method `unregister_locale' for class DiscoursePluginRegistry
     # ./spec/lib/freedom_patches/translate_accelerator_spec.rb:113:in `block (3 levels) in <main>'

Finished in 0.17998 seconds (files took 1.88 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/lib/freedom_patches/translate_accelerator_spec.rb:117 # translate accelerator plugins loads plural rules from plugins
```

On top of this, this spec was flakey, Im not sure this is going to fix
flakyness, but this seems like a good first step.
2025-05-10 19:50:00 +02:00
f3c41af772 DEV: Refactor image compression for iOS (#32652) 2025-05-09 09:51:30 -04:00
90c19ee54d DEV: remove email updater debugging (#32664) 2025-05-09 15:11:11 +04:00
b28df068fc FIX: ensure old email set correctly when updating email (#32309)
Previously when changing back to the same email (ie. change to new
email, then change back again) we can easily end up showing the
incorrect old email if changing back to the same email more than once.
Then passing the incorrect old email causes an error as it can't be found.

This happens because we only searched for a combination of `user_id` and
`new_email` which can load an older change from the database. By using
the current email address when finding / initializing the
`EmailChangeRequest` we can prevent this issue as we will be creating a
new entry rather than loading an outdated one.
2025-05-09 12:50:01 +04:00
6154fa6b45 FEATURE: Add translations to posts (#32564)
## 🔍 Overview
This update adds the ability for users to manually add translations to
specific posts. It adds a 🌐 icon on the post menu where you can click to
add translations for posts.

It also introduces a new site setting:
`content_localization_debug_allowed_groups` which is convenient when
debugging localized posts. It adds a globe icon in the post meta data
area along with a number of how many languages the post is translated
in. Hovering over the icon will show a tooltip with access to editing
and deleting the translated posts.

## 📸 Screenshots
<img width="1234" alt="Screenshot 2025-05-07 at 13 26 09"
src="https://github.com/user-attachments/assets/9d65374d-ee3e-4e8b-b171-b98db6f90f23"
/>
<img width="300" alt="Screenshot 2025-05-07 at 13 26 41"
src="https://github.com/user-attachments/assets/6ee9c5e6-16ed-4dab-97ec-9401804a4ac8"
/>
2025-05-08 10:40:36 -07:00
4d9bc4fef4 DEV: More helper methods for topic localization (#32643)
This adds more methods on `Topic` so it can be used in a later PR that
will localize topics.
2025-05-08 16:12:28 +08:00
413fea8051 DEV: Add new key for anon cache for localization (#32640)
As we move content localization to core, we will need to register a new
key to handle cases when anon users hit the cache to avoid cache
poisoning.

Related:
- https://github.com/discourse/discourse-translator/pull/273
-
d7ae611981/lib/discourse_translator/inline_translation.rb (L94-L98)
2025-05-08 14:30:03 +08:00
4490a52976 DEV: Recover from missing ember-cli assets in development (#32625) 2025-05-07 14:42:32 -04:00
b16fb6a60b FIX: Ensure hashtag_lookup falls back to system user if post user is deleted (#32466)
`hashtag_lookup` fails if called with a deleted user's ID. This change
defaults to system user if the user does not exist.
2025-05-07 15:49:49 +10:00
54faff1608 DEV: Add a missing path to the stylesheet watcher (#32579)
A followup to https://github.com/discourse/discourse/pull/31416

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2025-05-05 19:31:39 +02:00
49e3b5be76 Bump version to v3.5.0.beta5-dev 2025-05-05 12:58:30 -04:00
133b230ed9 Bump version to v3.5.0.beta4 2025-05-05 12:58:30 -04:00
3492819c19 DEV: Don't allow context-free system post destruction (#32523)
There are instances of posts being deleted by system_user where the context is left blank in the staff action logs, leading to confusion about why exactly they have been deleted.

This change deprecates using the PostDestroyer as system_user without providing a context, and adds a context to all call sites currently missing it in core. Plugins to be done after this is merged.
2025-05-05 09:58:29 +08:00
ffa406b0b1 UX: Add more info to theme cards (#32334)
Demo:
<img width="1431" alt="Screenshot 2025-05-02 at 2 24 41 pm"
src="https://github.com/user-attachments/assets/c8ec824e-25df-4efc-a4be-c774a2a97896"
/>
<img width="1480" alt="Screenshot 2025-05-02 at 2 24 32 pm"
src="https://github.com/user-attachments/assets/a4020283-9b6d-4f5e-a8c2-72b7608a6026"
/>

Mobile:
<img width="424" alt="Screenshot 2025-05-02 at 2 25 29 pm"
src="https://github.com/user-attachments/assets/af68669a-7bb4-46dc-92ab-6ecc7a3f3842"
/>
<img width="421" alt="Screenshot 2025-05-02 at 2 25 36 pm"
src="https://github.com/user-attachments/assets/961d9f5c-8010-4c5f-a319-6e356b088667"
/>
2025-05-05 09:06:05 +08:00