discourse/plugins/chat/app/models/chat_mention.rb
Roman Rizzi 082cd13909
FIX: Delete associated notifications when trashing chat messages. (#20144)
Deleting a message with a mention doesn't clear the associated notification, confusing the mentioned user.

There are different chat notification types, but we only care about `chat_mentioned` since `chat_quoted` is associated with a post, and `chat_message` is only for push notifications.

Unfortunately, this change doesn't fix the chat bubble getting out of sync when a message gets deleted since we track unread/mentions count with an integer, making it a bit hard to manipulate. We can follow up later if we consider it necessary.
2023-02-03 12:52:13 -03:00

24 lines
603 B
Ruby

# frozen_string_literal: true
class ChatMention < ActiveRecord::Base
belongs_to :user
belongs_to :chat_message
belongs_to :notification, dependent: :destroy
end
# == Schema Information
#
# Table name: chat_mentions
#
# id :bigint not null, primary key
# chat_message_id :integer not null
# user_id :integer not null
# notification_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# chat_mentions_index (chat_message_id,user_id,notification_id) UNIQUE
#