discourse/lib
Loïc Guitaut 9e9abe0a82 DEV: Unify params access in services
Currently, there are two ways (kind of) for accessing `params` inside a
service:
- when there is no contract or it hasn’t been reached yet, `params` is
  just the hash that was provided to the service. To access a key, you
  have to use the bracket notation `params[:my_key]`.
- when there is a contract and it has been executed successfully,
  `params` now references the contract and the attributes are accessible
  using methods (`params.my_key`).

This patch unifies how `params` exposes its attributes. Now, even if
there is no contract at all in a service, `params` will expose its
attributes through methods, that way things are more consistent.

This patch also makes sure there is always a `params` object available
even when no `params` key is provided to the service (this allows a
contract to fail because its attributes are blank instead of having the
service raising an error because it doesn’t find `params` in its context).
2024-12-13 11:13:18 +01:00
..
action_dispatch/session
active_support_type_extensions
auth
autospec
backup_restore
common_passwords
compression
content_security_policy
demon
discourse_dev
discourse_webauthn
email
email_controller_helper
emoji
faker
file_store
final_destination
freedom_patches
generators
guardian
i18n
imap
import
import_export
middleware
migration
onebox
plugin
pretty_text
rate_limiter
reviewable
scheduler
search
second_factor
seed_data
service
sidekiq
site_settings
stylesheet
summarization
tasks
theme_settings_manager
theme_store
topic_query
turbo_tests
validators
wizard
admin_confirmation.rb
admin_constraint.rb
admin_user_index_query.rb
age_words.rb
archetype.rb
auth.rb
backup_restore.rb
badge_posts_view_manager.rb
badge_queries.rb
base62.rb
bookmark_manager.rb
bookmark_query.rb
bookmark_reminder_notification_handler.rb
bookmarks_bulk_action.rb
browser_detection.rb
cache.rb
canonical_url.rb
category_badge.rb
chrome_installed_checker.rb
color_math.rb
comment_migration.rb
common_passwords.rb
composer_messages_finder.rb
configurable_urls.rb
content_buffer.rb
content_security_policy.rb
cooked_post_processor.rb
cooked_processor_mixin.rb
crawler_detection.rb
csrf_token_verifier.rb
current_user.rb
custom_renderer.rb
db_helper.rb
directory_helper.rb
discourse_connect_base.rb
discourse_connect_provider.rb
discourse_dev.rb
discourse_diff.rb
discourse_event.rb
discourse_hub.rb
discourse_ip_info.rb
discourse_js_processor.rb
discourse_logstash_logger.rb
discourse_plugin_registry.rb
discourse_redis.rb
discourse_sourcemapping_url_processor.rb
discourse_tagging.rb
discourse_updates.rb
discourse_webauthn.rb
discourse.rb
disk_space.rb
distributed_cache.rb
distributed_memoizer.rb
distributed_mutex.rb
edit_rate_limiter.rb
email_backup_token.rb
email_cook.rb
email_templates_finder.rb
email_updater.rb
email.rb
ember_cli.rb
encodings.rb
enum_site_setting.rb
enum.rb
excerpt_parser.rb
external_upload_helpers.rb
feed_element_installer.rb
feed_item_accessor.rb
file_helper.rb
filter_best_posts.rb
final_destination.rb
flag_query.rb
flag_settings.rb
gaps.rb
gc_stat_instrumenter.rb
git_repo.rb
git_url.rb
git_utils.rb
global_path.rb
group_lookup.rb
guardian.rb
has_errors.rb
highlight_js.rb
hijack.rb
homepage_constraint.rb
homepage_helper.rb
html_prettify.rb
html_to_markdown.rb
http_language_parser.rb
http_user_agent_encoder.rb
image_sizer.rb
import_export.rb
inline_oneboxer.rb
job_time_spacer.rb
js_locale_helper.rb
json_error.rb
letter_avatar.rb
markdown_linker.rb
mem_info.rb
message_bus_diags.rb
method_profiler.rb
mini_scheduler_long_running_job_logger.rb
mini_sql_multisite_connection.rb
mobile_detection.rb
new_post_manager.rb
new_post_result.rb
notification_levels.rb
onebox.rb
oneboxer.rb
onpdiff.rb
password_hasher.rb
pbkdf2.rb
permalink_constraint.rb
pinned_check.rb
plain_text_to_markdown.rb
plugin_gem.rb
plugin.rb
post_action_creator.rb
post_action_destroyer.rb
post_action_result.rb
post_action_type_view.rb
post_creator.rb
post_destroyer.rb
post_jobs_enqueuer.rb
post_locker.rb
post_merger.rb
post_revisor.rb
presence_channel.rb
pretty_text.rb
promotion.rb
quote_comparer.rb
quote_rewriter.rb
rake_helpers.rb
rate_limiter.rb
read_only_mixin.rb
require_dependency_backward_compatibility.rb
retrieve_title.rb
route_format.rb
route_matcher.rb
rtl.rb
s3_cors_rulesets.rb
s3_helper.rb
s3_inventory.rb
score_calculator.rb
screening_model.rb
search.rb
secure_session.rb
secure_upload_endpoint_helpers.rb
service.rb
shrink_uploaded_image.rb
sidekiq_logster_reporter.rb
sidekiq_long_running_job_logger.rb
signal_trap_logger.rb
site_icon_manager.rb
site_setting_extension.rb
slug.rb
smtp_provider_overrides.rb
socket_server.rb
spam_handler.rb
staff_constraint.rb
staff_message_format.rb
statistics.rb
suggested_topics_builder.rb
svg_sprite.rb
system_message.rb
temporary_db.rb
temporary_redis.rb
text_cleaner.rb
text_sentinel.rb
theme_javascript_compiler.rb
theme_metadata.rb
theme_modifier_helper.rb
theme_resolver.rb
theme_settings_manager.rb
theme_settings_object_validator.rb
theme_settings_parser.rb
theme_settings_validator.rb
theme_translation_manager.rb
theme_translation_parser.rb
timeline_lookup.rb
tiny_japanese_segmenter.rb
topic_creator.rb
topic_list_responder.rb
topic_publisher.rb
topic_query_params.rb
topic_query.rb
topic_retriever.rb
topic_subtype.rb
topic_upload_security_manager.rb
topic_view.rb
topics_bulk_action.rb
topics_filter.rb
truncate_logs_formatter.rb
trust_level.rb
turbo_tests.rb
twitter_api.rb
unicorn_logstash_patch.rb
unread.rb
upload_creator.rb
upload_fixer.rb
upload_markdown.rb
upload_recovery.rb
upload_security.rb
url_helper.rb
user_comm_screener.rb
user_lookup.rb
user_name_suggester.rb
vary_header.rb
version.rb
wizard.rb
work_queue.rb
xml_cleaner.rb