From b507a598c50676ac4b1ba0bbe483819ec33c5a6e Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Tue, 2 Apr 2019 17:11:05 -0500 Subject: add bangtags to reply-all thead, insert zws; handle fencing in braces --- app/models/status.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/status.rb b/app/models/status.rb index 37ceb1a9c..dcf53a5ea 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -570,8 +570,9 @@ class Status < ApplicationRecord return if text&.nil? return unless '#!'.in?(text) chunks = [] - text.split(/(#![\w:]+)/).each do |chunk| + text.split(/(#!(?:[\w:-]+|{[\w:-]+}))/).each do |chunk| if chunk.start_with?("#!") + chunk.sub!(/{(.*)}$/, '\1') case chunk[2..-1].downcase when 'permalink' chunks << TagManager.instance.url_for(self) @@ -593,6 +594,15 @@ class Status < ApplicationRecord mentions.uniq! mentions.sort! chunks << mentions.join(' ') + when 'thread:reall' + if conversation_id.present? + mention_ids = Status.where(conversation_id: conversation_id).flat_map { |s| s.mentions.pluck(:account_id) } + mention_ids.uniq! + mentions = Account.where(id: mention_ids).map { |a| "@#{a.username}" } + chunks << mentions.join(' ') + end + when 'char:zws' + chunks << "\u200c" else chunks << chunk end -- cgit