mirror of
https://github.com/discourse/discourse.git
synced 2026-08-14 13:58:53 +08:00
Promotes the posts query-string filter that previously lived in
discourse-ai's `Research::Filter` to a core `PostsFilter` class so it
can
be shared across core and plugins. The parser gains alias support
(`categories`, `exclude_category`, `exclude_tag`, `created_after`, ...),
`-`/`=`/`-=` exclusion prefixes, an `option_info` helper for
autocomplete,
and an `add_filter`/`remove_filter` extension API backed by a new
`posts_filter_options` plugin modifier.
Consumers are updated to build on the shared class:
* discourse-ai: `Research::Filter` becomes a thin subclass, the
researcher
tool documents the new exclusion syntax, and the report context
generator builds its relation from a PostsFilter query string instead of
hand-rolled SQL.
* discourse-assign: registers an `assigned_to:` filter (supporting
`nobody`, `*` and usernames) and contributes its autocomplete entry.
* discourse-workflows: adds an `action:post` node with create/get/list
operations built on PostsFilter, and extracts a shared `PostHelper`
mixin
reused by the existing create_post node.
Adds core locale strings and specs for the new class.
We also added two new APIs to node context to facilitate working with
posts:
#### `exec_ctx.create_post`
Creates a post while enforcing workflow actor permissions and preventing
recursive workflow execution.
```rb
post =
exec_ctx.create_post(
user: author,
raw: "Reply body",
topic_id: topic_id,
reply_to_post_number: reply_to_post_number,
)
```
Arguments:
- `user:` required `User` object used as the post author.
- `raw:` required raw post body.
- `topic_id:` required topic id where the post should be created.
- `reply_to_post_number:` optional post number to reply to.
The helper verifies that the author can see the topic, rejects closed or
archived topics, and creates the post with `skip_workflows: true`.
#### `exec_ctx.serialize_post`
Serializes a post into the standard Discourse Workflows post output
shape.
```rb
data =
exec_ctx.serialize_post(
post,
guardian: actor.guardian,
include_raw: true,
include_cooked: false,
)
```
Arguments:
- `post` required `Post` record.
- `guardian:` optional guardian used for permission-aware fields such as
visible tags. Defaults to the system guardian.
- `include_raw:` optional boolean. Defaults to `true`.
- `include_cooked:` optional boolean. Defaults to `false`.
Use this helper whenever a workflow node outputs post data. It keeps
post outputs consistent across action and trigger nodes.
---------
Co-authored-by: discourse-patch-triage[bot] <272280883+discourse-patch-triage[bot]@users.noreply.github.com>
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
|
||
|---|---|---|
| .. | ||
| artifact_update_strategies | ||
| tool_runner | ||
| tools | ||
| agent.rb | ||
| artist.rb | ||
| bot.rb | ||
| bot_context.rb | ||
| chat_thread_titler.rb | ||
| concept_deduplicator.rb | ||
| concept_finder.rb | ||
| concept_matcher.rb | ||
| content_creator.rb | ||
| creative.rb | ||
| custom_prompt.rb | ||
| designer.rb | ||
| discourse_helper.rb | ||
| discover.rb | ||
| emotion_classifier.rb | ||
| forum_researcher.rb | ||
| general.rb | ||
| github_helper.rb | ||
| image_captioner.rb | ||
| locale_detector.rb | ||
| markdown_table_generator.rb | ||
| post_illustrator.rb | ||
| post_raw_translator.rb | ||
| proofreader.rb | ||
| report_runner.rb | ||
| researcher.rb | ||
| sentiment_classifier.rb | ||
| settings_explorer.rb | ||
| short_summarizer.rb | ||
| short_text_translator.rb | ||
| smart_dates.rb | ||
| spam_detector.rb | ||
| sql_helper.rb | ||
| summarizer.rb | ||
| titles_generator.rb | ||
| tool_runner.rb | ||
| topic_title_translator.rb | ||
| translator.rb | ||
| tutor.rb | ||
| web_artifact_creator.rb | ||