Commit Graph

3545 Commits

Author SHA1 Message Date
chapoi
8d1867688f
UX: add padding bottom to chat index list (#29096) 2024-10-07 07:09:27 +02:00
Jan Cernik
1da97de7f0
SECURITY: Correctly parse URLs in chat excerpts 2024-10-07 11:48:41 +08:00
Penar Musaraj
d959bfdc61
UX: Improve bottom padding to chat index on mobile (#29086)
Minor adjustment to #29082
2024-10-04 11:33:38 -04:00
chapoi
c13ca6eb19
UX: chat index mini refactor (#29082) 2024-10-04 08:10:36 -04:00
David Battersby
9eaf908e63
DEV: cleanup chat desktop notification data (#28943)
Makes channel_id and is_direct_message_channel consistent across desktop notifications, which also removes the need to lookup the channel from Chat Notification Manager.
2024-10-03 12:43:17 +04:00
Loïc Guitaut
ad8f46f4f1 DEV: Make params explicit for services in controllers 2024-10-03 16:56:39 +09:00
Loïc Guitaut
fc1c5f6a8d DEV: Have contract take a block in services
Currently in services, the `contract` step is only used to define where
the contract will be called in the execution flow. Then, a `Contract`
class has to be defined with validations in it.

This patch allows the `contract` step to take a block containing
validations, attributes, etc. directly. No need to then open a
`Contract` class later in the service.

It also has a nice side effect, as it’s now easy to define multiples
contracts inside the same service. Before, we had the `class_name:`
option, but it wasn’t really useful as you had to redefine a complete
new contract class.
Now, when using a name for the contract other than `default`, a new
contract will be created automatically using the provided name.

Example:
```ruby
contract(:user) do
  attribute :user_id, :integer

  validates :user_id, presence: true
end
```
This will create a `UserContract` class and use it, also putting the
resulting contract in `context[:user_contract]`.
2024-10-02 17:00:01 +09:00
Discourse Translator Bot
76ad581f67 Update translations 2024-10-02 08:55:44 +02:00
Jarek Radosz
41c3c5745e
DEV: Fix optionalService in decorator form (#29042)
…and remove unused injections
2024-10-01 14:12:34 +02:00
Régis Hanol
252dcfbfa6
FIX: create an automation with forced_triggerable enabled (#29030)
When trying to create a new automation based on a scriptable that has "force_triggerable" enable, it would break because of a typo in the code.

This fixes the typo and add a spec to ensure this code path is tested.
2024-09-30 17:42:00 +02:00
Martin Brennan
73f42e110a
FIX: Unscoped plugin config page actions outlet (#29026)
In 61c1d35f17 I added a
PluginOutlet to AdminPluginConfigPage. This was intended to be
used as a way to render actions buttons inside the header of
a plugin that has a custom admin UI page. This worked, but
since the outlet was generically named, as soon as one plugin
used it the button would show on all plugins.

This fixes the immediate issue by naming the outlet based
on the plugin, then having each plugin specify their own
outlet to render into. There may be a nicer way to do this,
but for now this stops the bleeding.
2024-09-30 14:35:23 +10:00
Loïc Guitaut
afdb1ac0a0 DEV: Disallow default params in service steps
With the current implementation, a service step can be written as:
```ruby
def my_step(a_default_value: 2)
  …
end
```
That’s a pattern we want to avoid as default values (if needed) should
be probably defined in a contract.

This patch makes a service raise an exception if a default value is
encountered.
2024-09-19 14:47:55 +02:00
Alan Guo Xiang Tan
848af05537
DEV: Fix failing system tests (#28970)
We are seeing the following error on CI:

```
Errno::EADDRNOTAVAIL:
  Failed to open TCP connection to localhost:31337 (Cannot assign requested address - connect(2) for "localhost" port 31337)
```

This is because the job being enqueued makes a HTTP request to the Rails
server but Capybara doesn't start the Rails server until a session is
actually required. Therefore, we need to enqueue the job after we are
sure that a session has been started.
2024-09-19 10:12:38 +08:00
David Battersby
4bfe78d1e6
UX: remove alias from chat direct message channel titles (#28958)
Makes usernames in Chat Direct Message channels consistent with other areas of the app by removing the alias.
2024-09-18 22:18:46 +04:00
Loïc Guitaut
05b8ff436c DEV: Introduce a Service::ActionBase class for service actions
This will help to enforce a consistent pattern for creating service
actions.

This patch also namespaces actions and policies, making everything
related to a service available directly in
`app/services/<concept-name>`, making things more consistent at that
level too.
2024-09-18 17:02:46 +02:00
Joffrey JAFFEUX
e4e2bc7add
DEV: replaces subtitle by description (#28881)
Description should be above the field and that makes subtitle useless.

Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
2024-09-18 11:14:59 +02:00
Bianca Nenciu
dd5502f166
PERF: Cache serialized voters at topic view level (#28894)
This commit introduces a way to fetch the "serialized voters" for
multiple polls.

* Use a single query to fetch voters for all types of polls

* Refactor to introduce all_serialized_voters

* Cache serialized voters
2024-09-18 12:01:40 +03:00
chapoi
9b383e3729
UX: chat composer style tweaks (#28938) 2024-09-18 02:45:44 +02:00
Joffrey JAFFEUX
2aca41914a
FEATURE: supports mark tag in chat messages (#28949)
This brings feature parity with posts where you can use this tag.
2024-09-17 20:52:34 +02:00
Gabriel Grubba
e926a07c83
FEATURE: increasing name length in automation (#28945)
Updates from 30 to 100 the maximum length of the name of an automation.

Adds tests for validating the maximum length of the name of an automation.
2024-09-17 13:16:44 -03:00
chapoi
0923f5e3a7
UX: small colour change to chat composer insert button (#28904) 2024-09-17 03:31:55 +02:00
Osama Sayegh
4406bbb020
FIX: Prevent recurring automations from getting stalled under specific conditions (#28913)
Under certain conditions, a recurring automation can end up in a state with no pending automation records, causing it to not execute again until manually triggered.

We use the `RRule` gem to calculate the next execution date and time for recurring automations. The gem takes the interval, frequency, start date, and a time range, and returns all dates/times within this range that meet the recurrence rule. For example:

```ruby
RRule::Rule
  .new("FREQ=DAILY;INTERVAL=1", dtstart: Time.parse("2023-01-01 07:30:00 UTC"))
  .between(Time.zone.now, Time.zone.now + 2.days)
# => [Sat, 14 Sep 2024 07:30:00.000000000 UTC +00:00, Sun, 15 Sep 2024 07:30:00.000000000 UTC +00:00]
```

However, if the time component of the first point provided to `.between()` is slightly ahead of the start date (e.g., `dtstart`), the first date/time returned by `RRule` can fall outside the specified range by the same subsecond amount. For instance:

```ruby
RRule::Rule
  .new("FREQ=DAILY;INTERVAL=1", dtstart: Time.parse("2023-01-01 07:30:00 UTC"))
  .between(Time.parse("2023-01-01 07:30:00.999 UTC"), Time.parse("2023-01-03 07:30:00 UTC"))
  .first
# => Sun, 01 Jan 2023 07:30:00.000000000 UTC +00:00
```

Here, the start date/time given to `.between()` is 999 milliseconds after 07:30:00, but the first date returned is exactly 07:30:00 without the 999 milliseconds. This causes the next recurring date to fall into the past if the automation executes within a subsecond of the start time, leading to the automation stalling.

I'm not sure why `RRule` does this, but it seems intentional judging by the source of the `.between()` method:

b9911b7147/lib/rrule/rule.rb (L28-L32)

This commit fixes the issue by selecting the first date ahead of the current time from the list returned by `RRule`, rather than the first date directly.

Internal topic: t/138045.
2024-09-16 18:23:26 +03:00
David Battersby
b60f4606e5
FEATURE: allow names in chat channel title (#28843)
This change adds full names to direct message channel titles when the following conditions are met:

- SiteSetting.enable_names = true
- SiteSetting.display_name_on_posts = true
- SiteSetting.prioritize_username_in_ux = false

If a user's full name is blank, it will fallback to their username in both 1-1 channels and Group DM channels.
2024-09-16 18:12:13 +04:00
David Battersby
d7293eafef
DEV: add spec for chat drawer channel lists (#28927)
Adds a spec for chat channels lists in desktop drawer mode.
2024-09-16 12:15:21 +04:00
David Taylor
e7e9c99568
DEV: Drop ScrollTracker component (#28911)
Restoring scroll position is now handled by the route-scroll-manager service, so this is unneeded
2024-09-13 19:19:40 +01:00
Kris
a914d3230b
DEV: remap all core icons for fontawesome 6 upgrade (#28715)
Followup to 7d8974d02f

Co-authored-by: David Taylor <david@taylorhq.com>
2024-09-13 16:50:52 +01:00
David Battersby
e9b7663798
UX: sort chat channels by activity in desktop drawer (#28822)
This change sorts the desktop chat channels by activity in drawer mode, and keeps sidebar channel list sorted by slug.
2024-09-13 10:14:37 +04:00
chapoi
b59056780c
UX: upodate stying of chat composer focused state (#28900) 2024-09-13 07:34:40 +02:00
Jarek Radosz
896f116443
DEV: Fix random typos (#28891) 2024-09-12 23:25:34 +02:00
Jarek Radosz
6bc9153a0d
DEV: Remove duplicated tests (#28889) 2024-09-12 23:20:49 +02:00
Jarek Radosz
4d484d89d0
DEV: Add a missing service injection (#28890) 2024-09-12 23:20:33 +02:00
Loïc Guitaut
b806dce13d DEV: Refactor suspend/silence user services
- fetch models inside services
- validate `user_id` in contracts
- use policy objects
- extract more logic to actions
- write specs for services and action
2024-09-12 10:28:48 +02:00
Jarek Radosz
18fca966c5
FIX: Incorrect titles in two components (#28865) 2024-09-11 22:45:41 +02:00
Bianca Nenciu
d63ffe22f4
DEV: Track SQL queries from MiniSql (#28824)
`track_sql_queries` only returned queries that were executed by
ActiveRecord. All queries executed through DB.exec, DB.query and others
were not returned.
2024-09-11 10:14:53 +03:00
Osama Sayegh
91ba2a4aab
DEV: Add debug logging for automation recurring trigger (#28829)
We're seeing a problem where some recurring automations end up in a state where they don't have any `pending_automations` records scheduled which effectively makes the recurring automation dead. We need to add some debugging to figure out what might be causing this problem.

Internal topic: t/138045.
2024-09-11 01:29:15 +03:00
Penar Musaraj
1a88728d39
FIX: Poll voters list wasn't expanding properly (#28823) 2024-09-10 11:46:12 -04:00
Bianca Nenciu
9b0300a647
PERF: Preload voters_count and has_voted (#28808)
These fields are often used when serializing topics which may contain
multiple polls. On average, serializing a poll took 2+N queries where N
is the number of options. This change reduces the number of queries to
3, one for each field (Poll#voters_count, PollOption#voters_count and
Poll#has_voted?).
2024-09-10 18:41:08 +03:00
Robert
88e1690d86
FIX: poll preview list styling remove redundant bullets (#28592) 2024-09-10 10:54:59 +02:00
David Battersby
c697e70892
FIX: prevent chat channel not found ajax error (#28818)
On occasion we get an error popup on desktop due to the channel not being found.

This change means that we only check the cached channels in ChatChannelsManager for the matching channel id, but we skip doing manual lookup which results in ajax popup when it fails.
2024-09-10 11:52:25 +04:00
Martin Brennan
61c1d35f17
FEATURE: Convert chat plugin UI to new show plugin and admin UI guidelines (#28632)
This commit converts the current chat plugin UI into the
new "show plugin" UI already followed by AI and Gamification.

In the process, I also:

* Made a dedicated /new route to create new webhooks
* Converted the webhook form to FormKit
* Made some fixes and improvements to the `AdminPluginConfigPage`, `AdminPageHeader`,
   and `AdminPageSubheader` generic components, so more plugins can
   adopt the UI guidelines too. This includes adding a header outlet so plugins
   can add action buttons to the plugin show page header.
* Fixes the submit button loading state for FormKit (by Joffrey)

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2024-09-10 15:16:16 +10:00
David Taylor
7d8974d02f
UX: Upgrade to fontawesome 6.6.0 (#28778)
This upgrade is designed to be fully backwards-compatible. Any icon names which have changed will be automatically remapped to the new name. For now, this will happen silently. In future, once core & official themes/plugins have been updated, we will start raising deprecation errors to help theme/plugin authors update their code.

Extracted from https://github.com/discourse/discourse/pull/28715

Announcement at https://meta.discourse.org/t/were-upgrading-our-icons-to-font-awesome-6/325349

Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
2024-09-09 14:40:56 +01:00
Kris
deb751dfe3
UX: remove btn-default class from chat thread tracking dropdown (#28789) 2024-09-06 15:14:29 -05:00
David Taylor
348abeecb1
DEV: Use icon-rendering API for local-dates (#28788)
This makes local-dates compatible with the fa6 upgrade in https://github.com/discourse/discourse/pull/28778
2024-09-06 20:51:57 +01:00
Joffrey JAFFEUX
ad7d5426d8
FIX: supports groups field in post_created_edited (#28783)
⚠️ This commit is a revert of a revert due to a migration which was causing `{}` metadata to be transformed into `{"value": [null]}`. The new migration shouldn't cause this and will also clean the existing errors, there shouldn't  be any data loss given the affected fields where not containing actual data. We might want to stop storing these empty fields in the future.

To achieve it, this commit does the following:
- create a new `groups field`, ideally we would have reused the existing group field, but many automations now have the expectation that this field will return a group id and not an array of group ids, which makes it a dangerous change
- alter the code in `post_created_edited` to use this new groups field and change the logic to use an array
- migrate the existing group fields post_created_edited automations to change name from `restricted_group` to `restricted_groups`, the component from `group` to `groups` and the metadata from `{"value": integer}` to `{"value": [integer]}`

<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2024-09-06 17:22:42 +02:00
David Battersby
2a5e1aa8e6
FEATURE: only play chat sound when chat badge icon is shown (#28387)
Every time a desktop chat sound plays, there should be some visual cue as to why the sound was played in the first place.

This change follows the chat indicator preference:

- All New Messages - a blue dot is shown for all messages, so we attempt to play a sound every time
- Direct Messages, Mentions and Watched Threads - a green dot is shown for all urgent messages, so we attempt to play a sound for urgent chat notifications
- Only Mentions - only play chat sounds when user is mentioned
- Never - we never play chat sounds, as user wouldn’t know why the sound was played
2024-09-06 18:25:25 +04:00
Gabriel Grubba
a98d3d40f2
FEATURE: Add user to topic_tags_changed event (#28714)
* FEATURE: Add user to topic_tags_changed event

Add user to topic_tags_changed event context
Update automation plugin with new arguments in event
Update tests for new arguments

relates to https://github.com/discourse/discourse-chat-integration/pull/214

* DEV: change variable name for better readability

changed `tags` to be payload and used `values_at` to get the values of the keys
2024-09-06 11:23:30 -03:00
Joffrey JAFFEUX
5f5680dbaf
Revert "FIX: supports groups field in post_created_edited (#28773)" (#28781)
This reverts commit eb3a1c7217.
2024-09-06 16:10:53 +02:00
Joffrey JAFFEUX
eb3a1c7217
FIX: supports groups field in post_created_edited (#28773)
To achieve this this commit does the following:
- create a new `groups field, ideally we would have reused the existing group field, but many automations now have the expectation that this field will return a group id and not an array of group ids, which makes it a dangerous change
- alter the code in `post_created_edited` to use this new groups field and change the logic to use an array
- migrate the existing group fields post_created_edited automations to change name from `restricted_group` to `restricted_groups`, the component from `group` to `groups` and the metadata from `{"value": integer}` to `{"value": [integer]}`
2024-09-06 15:04:19 +02:00
David Battersby
a193bf4360
UX: update chat channel sorting (#28760)
Reverts chat channel sorting changes made in #28731 due to desktop sidebar.
2024-09-05 20:58:15 +04:00
Joffrey JAFFEUX
9b630c8cca
DEV: adds post_created_edited suport to chat (#28757) 2024-09-05 17:17:18 +02:00