discourse/plugins/chat
Alan Guo Xiang Tan 9c39053d6f
FIX: Ensure order when moving chat messages to another channel (#21447)
What is the problem?

Previously, this was the query used to move change messages into another
channel.

```
INSERT INTO chat_messages(
  chat_channel_id, user_id, last_editor_id, message, cooked, cooked_version, created_at, updated_at
)
SELECT :destination_channel_id,
        user_id,
        last_editor_id,
        message,
        cooked,
        cooked_version,
        CLOCK_TIMESTAMP(),
        CLOCK_TIMESTAMP()
FROM chat_messages
WHERE id IN (:message_ids)
RETURNING id
```

The problem is that this incorrectly assumes that the insertion will be based on the order of `message_ids`. However, that
is not the case as PostgreSQL provides no such guarantee. Instead we need to explicitly order the messages to ensure
the right order of insertion.

This problem was discovered by a flaky test which exposed the non-guarantee order of insertion.
2023-05-09 10:37:12 +08:00
..
app DEV: converts models to native classes (#21418) 2023-05-08 18:24:41 +02:00
assets UI: thread panel sizing/spacing on mobile (#21440) 2023-05-09 00:17:42 +02:00
config UX: groups deleted messages (#21411) 2023-05-05 17:08:33 +02:00
db DEV: Chat thread reply counter cache (#21050) 2023-04-11 15:40:25 +10:00
lib FIX: Ensure order when moving chat messages to another channel (#21447) 2023-05-09 10:37:12 +08:00
public
spec DEV: more resilient spec (#21436) 2023-05-08 21:10:57 +02:00
test/javascripts DEV: converts models to native classes (#21418) 2023-05-08 18:24:41 +02:00
plugin.rb DEV: Improve add_to_serializer include_* options (#21220) 2023-04-24 12:17:51 +01:00
README.md DEV: Chat service object initial implementation (#19814) 2023-02-13 13:09:57 +01:00

This plugin is still in active development and may change frequently

Documentation

The Discourse Chat plugin adds chat functionality to your Discourse so it can natively support both long-form and short-form communication needs of your online community.

For user documentation, see Discourse Chat.

For developer documentation, see Discourse Documentation.