mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 17:53:55 +08:00
Allow staff to pin important messages in chat channels. Pinned messages appear in a dedicated panel accessible from the channel navbar. Members of allowed groups (admins/moderators by default) can pin and unpin messages via the message actions menu. Pinned messages show "pinned by" attribution, track unread state per user, and auto-unpin when the original message is trashed. Real-time updates via MessageBus keep the pinned list in sync. Gated behind the chat_pinned_messages upcoming change (experimental).
20 lines
611 B
Ruby
Vendored
20 lines
611 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class CreateChatPinnedMessages < ActiveRecord::Migration[7.2]
|
|
def change
|
|
create_table :chat_pinned_messages do |t|
|
|
t.bigint :chat_message_id, null: false
|
|
t.bigint :chat_channel_id, null: false
|
|
t.bigint :pinned_by_id, null: false
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :chat_pinned_messages, :chat_message_id, unique: true
|
|
add_index :chat_pinned_messages,
|
|
%i[chat_channel_id created_at],
|
|
order: {
|
|
created_at: :desc,
|
|
},
|
|
name: "idx_chat_pinned_messages_channel_created"
|
|
end
|
|
end
|