FIX: adds post_quote as placeholder (#29083)

The script `send_chat_message` when used with the `post_created_edited` trigger now accepts `{{post_quote}}` as placeholder for the value of `message`.

This is made possible by a new method in `utils`. Usage:

```ruby
  placeholders["foo"] = utils.build_quote(post)
```
This commit is contained in:
Joffrey JAFFEUX
2024-10-08 21:55:11 +09:00
committed by GitHub
parent 9825bde811
commit 268213a93c
4 changed files with 104 additions and 8 deletions

View File

@ -463,6 +463,7 @@ after_initialize do
field :sender, component: :user
placeholder :channel_name
placeholder :post_quote, triggerable: :post_created_edited
triggerables %i[recurring topic_tags_changed post_created_edited]
@ -471,6 +472,10 @@ after_initialize do
channel = Chat::Channel.find_by(id: fields.dig("chat_channel_id", "value"))
placeholders = { channel_name: channel.title(sender) }.merge(context["placeholders"] || {})
if context["kind"] == "post_created_edited"
placeholders[:post_quote] = utils.build_quote(context["post"])
end
creator =
::Chat::CreateMessage.call(
chat_channel_id: channel.id,