mirror of
https://github.com/mastodon/mastodon.git
synced 2024-09-19 11:55:15 +00:00
Add Conversation#to_message_id
for class/id/date portion of conversation thread header
This commit is contained in:
parent
ca8e892c1a
commit
c3f0ce4b31
|
@ -84,9 +84,9 @@ class NotificationMailer < ApplicationMailer
|
|||
def thread_by_conversation(conversation)
|
||||
return if conversation.nil?
|
||||
|
||||
msg_id = "<conversation-#{conversation.id}.#{conversation.created_at.strftime('%Y-%m-%d')}@#{Rails.configuration.x.local_domain}>"
|
||||
message_id = "<#{conversation.to_message_id}@#{Rails.configuration.x.local_domain}>"
|
||||
|
||||
headers['In-Reply-To'] = msg_id
|
||||
headers['References'] = msg_id
|
||||
headers['In-Reply-To'] = message_id
|
||||
headers['References'] = message_id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,4 +18,8 @@ class Conversation < ApplicationRecord
|
|||
def local?
|
||||
uri.nil?
|
||||
end
|
||||
|
||||
def to_message_id
|
||||
"#{self.class.name.downcase}-#{id}.#{created_at.to_date}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,4 +12,13 @@ RSpec.describe Conversation do
|
|||
expect(Fabricate(:conversation, uri: 'abc').local?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe '#to_message_id' do
|
||||
it 'converts the conversation details into a string ID' do
|
||||
conversation = described_class.new(id: 123, created_at: DateTime.new(2024, 1, 1))
|
||||
|
||||
expect(conversation.to_message_id)
|
||||
.to eq('conversation-123.2024-01-01')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue