Commit Graph

43398 Commits

Author SHA1 Message Date
David Taylor 495aa4752c FIX: Correctly avoid concurrent requests in PresenceChannel get
This if statement was intended to prevent concurrent `/presence/get` requests, but it was missing a critical line. Now it should function as intended.
2021-10-26 18:27:07 +01:00
David Taylor edc1378aed DEV: Raise error when anon subscribes to PresenceChannels on login_required sites
In this situation, messagebus and the server-side Presence endpoints are unavailable, so it's better to quit early in the JS
2021-10-26 18:27:07 +01:00
David Taylor d43b77b56b DEV: Ensure presence beforeunload event listener is cleaned up
In production, services are singletons. This logic will only affect the test environment
2021-10-26 18:27:07 +01:00
David Taylor 54ca7a9618 FIX: Do not send presence leave beacon if not present in any channels 2021-10-26 18:27:07 +01:00
Jeremy Waters b24002018a Update phorum.rb
Add attachment/file/upload handling to bring them in from phorum to discourse
2021-10-26 12:41:50 -04:00
Bianca Nenciu 0c6f9d7c67
FIX: Show right message when permanently deleting topic (#14717) 2021-10-26 18:31:15 +03:00
Roman Rizzi dfb7924105
DEV: Specify target browsers when running Ember CLI tests from the docker rake task (#14720) 2021-10-26 11:10:22 -03:00
Roman Rizzi be38615afd
FEATURE: Mark omniauth failures as HTML safe. (#14713)
Plugins can add HTML elements to auth error messages.
2021-10-26 09:46:25 -03:00
David Taylor 9882aa840a
UX: Re-order auth-related site settings for clarity (#14716)
This commit groups `auth_overrides_*`, `discourse_connect_*` and `discourse_connect_provider_*` settings separately, rather than interspersing them.

There will be no functional change. This only affects the order in which they're shown in the admin panel
2021-10-26 11:24:10 +01:00
dependabot[bot] 3bae85e203
Build(deps): Bump omniauth-facebook from 8.0.0 to 9.0.0 (#14712)
Bumps [omniauth-facebook](https://github.com/simi/omniauth-facebook) from 8.0.0 to 9.0.0.
- [Release notes](https://github.com/simi/omniauth-facebook/releases)
- [Changelog](https://github.com/simi/omniauth-facebook/blob/master/CHANGELOG.md)
- [Commits](https://github.com/simi/omniauth-facebook/compare/v8.0.0...v9.0.0)

---
updated-dependencies:
- dependency-name: omniauth-facebook
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-26 12:09:20 +02:00
dependabot[bot] 93183b18e0
Build(deps): Bump ipaddr from 1.2.2 to 1.2.3 (#14711)
Bumps [ipaddr](https://github.com/ruby/ipaddr) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/ruby/ipaddr/releases)
- [Changelog](https://github.com/ruby/ipaddr/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ruby/ipaddr/compare/v1.2.2...v1.2.3)

---
updated-dependencies:
- dependency-name: ipaddr
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-26 12:09:03 +02:00
Dan Ungureanu f003e31e2f
PERF: Optimize search in private messages query (#14660)
* PERF: Remove JOIN on categories for PM search

JOIN on categories is not needed when searchin in private messages as
PMs are not categorized.

* DEV: Use == for string comparison

* PERF: Optimize query for allowed topic groups

There was a query that checked for all topics a user or their groups
were allowed to see. This used UNION between topic_allowed_users and
topic_allowed_groups which was very inefficient. That was replaced with
a OR condition that checks in either tables more efficiently.
2021-10-26 10:16:38 +03:00
Martin Brennan f6528afa01
DEV: Add uploadHandler support to composer-upload-uppy mixin (#14692)
This commit adds uploadHandler support to composer uploads using
uppy. The only things we have that are using this are discourse-brightcove and
discourse-video, which both pop modal windows to handle the file upload and
completely leave out all the composer-type flows. This implementation simply
follows the existing one, where if a single file is uploaded and there
is a matching upload handler we take control away from uppy and hand
it off to the upload handler.

Trying to get this kind of thing working within uppy would require a few
changes because they have no way to restrict uploaders to certain file types
and with the way their uploaders are run it doesn't look like it would be easy
to add this either, so I don't think this is worth the work unless at some
point in the future we plan to have more upload handler integrations.

I also fixed an issue with `cleanUpComposerUploadHandler` which is used
in tests to reset the state of `uploadHandlers` in the composer. This
was doing `uploadHandlers = []` to clear that array, but that creates
a brand new array so anything else referencing the original array will
lose that reference. Better to set `uploadHandlers.length = 0` to
clear it. This was breaking the tests I added to see if upload handlers
were working.
2021-10-26 11:22:33 +10:00
Roman Rizzi 436edbb51a
DEV: Only set `tap_failed_tests_only` to true for CI. (#14710)
It may seem like the command crashed when running tests locally since we get no feedback until it finishes running all the tests.
2021-10-25 16:24:47 -03:00
janzenisaac dd5b0543c7
FEATURE: Add fullscreen-tables to post (#14709)
Overflown tables will have a "expand table" option added to open x table in a modal
2021-10-25 14:06:28 -05:00
Penar Musaraj 116982fca9
FIX: Correct tracking context for some category routes (#14685)
We were previously showing the "n new or updated topics" alert on
category routes like `/c/category-slug/ID/none` on every new/unread
topic update. This PR looks up the category by ID, which should be more
precise.
2021-10-25 15:05:00 -04:00
Jarek Radosz facf7d6f56
DEV: Don't leak auth methods between tests (#14708) 2021-10-25 15:25:39 +02:00
dependabot[bot] d6c39e54cf
Build(deps): Bump rubocop from 1.22.1 to 1.22.2 (#14705)
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.22.1 to 1.22.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.22.1...v1.22.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-25 14:41:45 +02:00
dependabot[bot] b02f003c68
Build(deps): Bump json from 2.6.0 to 2.6.1 (#14704)
Bumps [json](https://github.com/flori/json) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/flori/json/releases)
- [Changelog](https://github.com/flori/json/blob/master/CHANGES.md)
- [Commits](https://github.com/flori/json/compare/v2.6.0...v2.6.1)

---
updated-dependencies:
- dependency-name: json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-25 14:41:12 +02:00
David Taylor 9ac6f1d3bb
FIX: Include the Vary:Accept header on all Accept-based responses (#14647)
By default, Rails only includes the Vary:Accept header in responses when the Accept: header is included in the request. This means that proxies/browsers may cache a response to a request with a missing Accept header, and then later serve that cached version for a request which **does** supply the Accept header. This can lead to some very unexpected behavior in browsers.

This commit adds the Vary:Accept header for all requests, even if the Accept header is not present in the request. If a format parameter (e.g. `.json` suffix) is included in the path, then the Accept header is still omitted. (The format parameter takes precedence over any Accept: header, so the response is no longer varies based on the Accept header)
2021-10-25 12:53:50 +01:00
Joffrey JAFFEUX cbd7898d1d
DEV: removes jquery usage from time formatter (#14700) 2021-10-25 11:00:15 +02:00
Joffrey JAFFEUX c7099342ff
DEV: uses vanilla js for fixture qunit helper (#14703) 2021-10-25 10:59:58 +02:00
Joffrey JAFFEUX c0300b13e3
DEV: replaces jquery call by vanilla js in uploader tests (#14702) 2021-10-25 10:49:14 +02:00
Joffrey JAFFEUX cc68eb825b
DEV: drops jquery usage from ajax wizards lib (#14694) 2021-10-25 10:24:53 +02:00
Joffrey JAFFEUX 05dda755ed
DEV: removes jquery usage from linkSeenMentions codepath (#14695) 2021-10-25 10:24:37 +02:00
Joffrey JAFFEUX b18c01e3c6
DEV: prevents flakky spec when deleting plugin (#14701)
Not reseting the registry could lead to assets still being registered for example.

This flakky spec was reprdocible with this call: `bundle exec rspec --seed 9472 spec/components/discourse_plugin_registry_spec.rb spec/components/svg_sprite/svg_sprite_spec.rb`

Which would trigger the following error:

```
Failures:

  1) DiscoursePluginRegistry#register_asset registers vendored_core_pretty_text properly
     Failure/Error: expect(registry.javascripts.count).to eq(0)

       expected: 0
            got: 1

       (compared using ==)
     # ./spec/components/discourse_plugin_registry_spec.rb:248:in `block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:280:in `block (2 levels) in <top (required)>'
     # /Users/joffreyjaffeux/.gem/ruby/2.7.3/gems/webmock-3.14.0/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
```
2021-10-25 10:24:21 +02:00
Bianca Nenciu 261edcebcb
FIX: Allow every tag for watched words (#14684)
If a watched word was restricted to a category, new rules for that
watched word could not be created.
2021-10-25 10:53:42 +03:00
Martin Brennan 2461ed303c
DEV: Move loadLibs to explicit install message in media-optimization-worker (#14707)
Previously, `loadLibs` was called inside the `optimize` function of
the media-optimization-worker, which meant that it could be hit
multiple times causing load errors (as seen in b69c2f7311)

This commit moves that call to a specific message handler (the `install` message)
for the service worker, and refactors the service for the media-optimization-worker
to wait for this installation to complete before continuing with processing
image optimizations.

This way, we know for sure based on promises and worker messages
that the worker is installed and has all required libraries
loaded before we continue on with attempting any processing. The
change made in b69c2f7311 is no
longer needed with this commit.
2021-10-25 13:17:43 +10:00
Jeff Wong 8c17f5b72c
FEATURE: include user custom fields in base exporter (#14690)
Add user custom fields in base exporter, allows Discourse->Discourse exports to
transfer user custom fields
2021-10-22 10:02:56 -07:00
Penar Musaraj 689a3711c0
DEV: Remove a few unused icons (#14696) 2021-10-22 12:03:58 -04:00
David Taylor 00c6d16dce
DEV: Make PresenceChannel timeout configurable per-channel (#14697) 2021-10-22 16:24:55 +01:00
Joffrey JAFFEUX 76a9ca99a8
DEV: removes jquery usage from onebox (#14683) 2021-10-22 13:15:46 +02:00
Alan Guo Xiang Tan 6544e3b02a
DEV: Remove useless ordering when searching within a topic. (#14676)
Searching within a topic currently does not make use of PG search and
we're simply doing an `ilike` against the post raw. Furthermore,
`Post#post_number` is already unique within a topic so the other
ordering will never ever be used. This change simply makes the query
cleaner to read.
2021-10-22 10:38:21 +08:00
Alan Guo Xiang Tan d1201d6188
DEV: Pass topic to `TopicView.add_post_custom_fields_allowlister` (#14678)
Allows custom fields to be loaded based on the attributes of a topic.
2021-10-22 10:22:09 +08:00
dependabot[bot] c7703cec2f
Build(deps): Bump zeitwerk from 2.5.0 to 2.5.1 (#14688)
Bumps [zeitwerk](https://github.com/fxn/zeitwerk) from 2.5.0 to 2.5.1.
- [Release notes](https://github.com/fxn/zeitwerk/releases)
- [Changelog](https://github.com/fxn/zeitwerk/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fxn/zeitwerk/compare/v2.5.0...v2.5.1)

---
updated-dependencies:
- dependency-name: zeitwerk
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-22 10:21:50 +08:00
dependabot[bot] fbced6cd85
Build(deps): Bump image_optim from 0.31.0 to 0.31.1 (#14689)
Bumps [image_optim](https://github.com/toy/image_optim) from 0.31.0 to 0.31.1.
- [Release notes](https://github.com/toy/image_optim/releases)
- [Changelog](https://github.com/toy/image_optim/blob/master/CHANGELOG.markdown)
- [Commits](https://github.com/toy/image_optim/compare/v0.31.0...v0.31.1)

---
updated-dependencies:
- dependency-name: image_optim
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-22 10:21:33 +08:00
Martin Brennan fffbb69606
DEV: Remove enable_experimental_image_uploader site setting (#14691)
This setting was already removed in the UI and the DB in
2364626ded,
but I forgot to remove the actual setting from yml.
2021-10-22 09:39:49 +10:00
Martin Brennan 7290a74aa6
DEV: Add new bookmarks:changed app event (#14674)
This new app event will fire whenever a bookmark is created,
edited, or deleted for a post or topic, and replaces these old
app events which had inconsistent APIs:

* page:bookmark-post-toggled
* topic:bookmark-toggled

When the event is triggered, the arguments are in this order:

1. bookmark - The bookmark record created or changed. Will be null
              if the bookmark was deleted.
2. target   - Object with target (post or topic) and targetId (post ID
              or topic ID)
2021-10-22 09:38:02 +10:00
Martin Brennan 2b40049abb
FIX: Remove superfluous topic allowed users on group invite (#14656)
When inviting a group to a topic, there may be members of
the group already in the topic as topic allowed users. These
can be safely removed from the topic, because they are implicitly
allowed in the topic based on their group membership.

Also, this prevents issues with group SMTP emails, which rely
on the topic_allowed_users of the topic to send to and cc's
for emails, and if there are members of the group as topic_allowed_users
then that complicates things and causes odd behaviour.

We also ensure that the OP of the topic is not removed from
the topic_allowed_users when a group they belong to is added,
as it will make it harder to add them back later.
2021-10-22 08:57:51 +10:00
Jeff Wong 6192189fd2
DEV: allow composer option to skip jumping to a post on save (#14675)
* DEV: allow composer option to skip jumping to a post on save

* DEV: refactor js safe access in jump logic

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2021-10-21 13:46:04 -07:00
Joshua Rosenfeld 61a7fbdd9e
FIX: Correct site setting name (#14686) 2021-10-21 16:32:27 -04:00
Simon Cossar 7eea58ca9e
Update copy of the max_new_accounts_per_registration_ip description to indicate that the setting can be disabled (#14687) 2021-10-21 13:15:04 -07:00
Jarek Radosz 451cd4ec3f
DEV: Fix thor deprecation warning (#14680)
```
Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `DiscourseCLI`
```
2021-10-21 21:01:05 +02:00
Osama Sayegh 70fa67a9e1
FIX: Don't leak unhashed user API keys to redis (#14682)
User API keys (not the same thing as admin API keys) are currently
leaked to redis when rate limits are applied to them since redis is the
backend for rate limits in Discourse and the API keys are included in
the redis keys that are used to track usage of user API keys in the last
24 hours.

This commit stops the leak by using a SHA-256 representation of the user
API key instead of the key itself to form the redis key.

We don't need to manually delete the existing redis keys that contain
unhashed user API keys because they're not long-lived and will be
automatically deleted within 48 hours after this commit is deployed to
your Discourse instance.
2021-10-21 19:43:26 +03:00
Jarek Radosz 3b90d7de66
FIX: 2N+1 sql in admin /api/keys endpoint (#14679) 2021-10-21 17:00:17 +02:00
Penar Musaraj db53c6b248
UX: Add special case for user search when in a topic (#14669) 2021-10-21 10:34:50 -04:00
Robin Ward e15bd194fd UX: Sometimes the footer would show up while refreshing a list route
This happens because the state of `canLoadMore` is not cleared as the
refresh occurs, which is enough to make the page think a footer should
be displayed.

No tests here because it's tricky to test refreshing and none of our
existing acceptance tests seem to.
2021-10-21 09:04:27 -04:00
David Taylor b57b079ff2
DEV: Update discourse-presence plugin to use new PresenceChannel system (#14519)
This removes all custom controllers and redis/messagebus logic from discourse-presence, and replaces it with core's new PresenceChannel system.

All functionality should be retained. This implementation should scale much better to large numbers of users, reduce the number of HTTP requests made by clients, and reduce the volume of messages on the MessageBus.

For more information on PresenceChannel, see 31db8352
2021-10-21 12:42:46 +01:00
Joffrey JAFFEUX 80ec6f09d3
DEV: removes unnecessary caret position code (#14665)
We don't support any browser needing this for very long: https://caniuse.com/?search=selectionStart

I'm keeping some protection so It doesn’t crash but ultimately `element.selectionStart` should be enough.

Im not removing this in the commit, but the `caret_position.js` file seems barely used.
2021-10-21 10:06:31 +02:00
Alan Guo Xiang Tan a9d6b23802
DEV: Remove code that is no longer valid. (#14657)
The vote post action type was removed in 96aca6d7e6

Follow-up to 96aca6d7e6.
2021-10-21 10:47:22 +08:00