discourse/plugins/chat/lib/chat
Loïc Guitaut 41584ab40c DEV: Provide user input to services using params key
Currently in services, we don’t make a distinction between input
parameters, options and dependencies.

This can lead to user input modifying the service behavior, whereas it
was not the developer intention.

This patch addresses the issue by changing how data is provided to
services:
- `params` is now used to hold all data coming from outside (typically
  user input from a controller) and a contract will take its values from
  `params`.
- `options` is a new key to provide options to a service. This typically
  allows changing a service behavior at runtime. It is, of course,
  totally optional.
- `dependencies` is actually anything else provided to the service (like
  `guardian`) and available directly from the context object.

The `service_params` helper in controllers has been updated to reflect
those changes, so most of the existing services didn’t need specific
changes.

The options block has the same DSL as contracts, as it’s also based on
`ActiveModel`. There aren’t any validations, though. Here’s an example:
```ruby
options do
  attribute :allow_changing_hidden, :boolean, default: false
end
```
And here’s an example of how to call a service with the new keys:
```ruby
MyService.call(params: { key1: value1, … }, options: { my_option: true }, guardian:, …)
```
2024-10-25 09:57:59 +02:00
..
bookmark_extension.rb DEV: Refactor STI/polymorphic associations in chat (#20789) 2023-04-17 15:41:56 +02:00
category_extension.rb DEV: Refactor STI/polymorphic associations in chat (#20789) 2023-04-17 15:41:56 +02:00
channel_archive_service.rb FEATURE: Add threads support to chat archives (#24325) 2023-11-27 15:47:35 +01:00
channel_fetcher.rb DEV: Provide user input to services using params key 2024-10-25 09:57:59 +02:00
channel_hashtag_data_source.rb FEATURE: Async load of category and chat hashtags (#25526) 2024-02-12 12:07:14 +02:00
channel_membership_manager.rb FEATURE: Auto-remove users without permission from channel (#20344) 2023-03-22 10:19:59 +10:00
duplicate_message_validator.rb
engine.rb DEV: Update chat scheduled job loading to match skeleton (#26853) 2024-05-02 19:20:00 +01:00
group_extension.rb DEV: Redesign chat mentions (#24752) 2024-01-17 15:24:01 +04:00
guardian_extensions.rb FIX: trashed channel thread view bug (#29192) 2024-10-14 17:45:50 +04:00
mailer.rb FIX: chat mailer log noise (#28616) 2024-08-29 11:39:08 -03:00
message_bookmarkable.rb FIX: Show deleted bookmark reminders in user bookmarks menu (#25905) 2024-02-29 09:03:49 +10:00
message_mover.rb DEV: Provide user input to services using params key 2024-10-25 09:57:59 +02:00
message_processor.rb DEV: Rename with_secure_uploads? to should_secure_uploads? on Post (#26549) 2024-04-09 13:23:11 +10:00
message_rate_limiter.rb
message_reactor.rb
messages_exporter.rb FIX: Chat messages exporter (#25461) 2024-01-30 18:37:11 +04:00
notification_consolidation_extension.rb FEATURE: Add ability to watch chat threads (#28639) 2024-09-02 16:45:55 +04:00
notification_levels.rb FIX: Chat NotificationLevels extension breaking in prod (#21484) 2023-05-10 18:46:06 +02:00
notifier.rb FIX: delay chat notify watching job (#28386) 2024-08-15 18:08:30 +04:00
onebox_handler.rb DEV: Revert guardian changes (#24742) 2023-12-06 16:37:32 +10:00
outgoing_web_hook_extension.rb FEATURE: granular webhooks (#23070) 2023-10-09 03:35:31 +00:00
parsed_mentions.rb DEV: better highlighting of mentions (#28403) 2024-08-20 14:37:28 +02:00
plugin_instance_extension.rb
post_notification_handler.rb
review_queue.rb FIX: Create a reviewable when flagging a chat message for 'something else' (#23264) 2023-08-25 17:38:27 +08:00
reviewable_extension.rb DEV: Refactor STI/polymorphic associations in chat (#20789) 2023-04-17 15:41:56 +02:00
secure_uploads_compatibility.rb
seeder.rb
slack_compatibility.rb
statistics.rb DEV: Add new chat metrics (#23872) 2024-01-04 16:10:03 +04:00
transcript_service.rb FIX: Do not display chat replies as threads in transcripts (#24768) 2023-12-15 09:50:43 -03:00
user_extension.rb DEV: Redesign chat mentions (#24752) 2024-01-17 15:24:01 +04:00
user_notifications_extension.rb FIX: show group based notifications in chat summary email (#27641) 2024-07-01 12:47:38 +04:00
user_option_extension.rb FEATURE: encourage users to set chat thread titles (#26617) 2024-04-29 17:20:01 +08:00