Add option for multiple local-only emojis through the DEFAULT_LOCAL_ONLY_EMOJI and ALTERNATIVE_LOCAL_ONLY_EMOJI env vars

This commit is contained in:
CSDUMMI 2023-05-05 17:16:36 +02:00
parent c18884de32
commit 28663c07f7
2 changed files with 13 additions and 2 deletions

View File

@ -301,3 +301,10 @@ MAX_POLL_OPTION_CHARS=100
# -----------------------
IP_RETENTION_PERIOD=31556952
SESSION_RETENTION_PERIOD=31556952
# Local-only Emoji
# **Always add old local-only emojis to the ALTERNATIVE_LOCAL_ONLY_EMOJI**,
# otherwise old local-only messages will become public
# ALTERNATIVE_LOCAL_ONLY_EMOJI is a comma-separated list of alternate emoji to use for local-only messages.
# DEFAULT_LOCAL_ONLY_EMOJI=
# ALTERNATIVE_LOCAL_ONLY_EMOJI=

View File

@ -431,11 +431,15 @@ class Status < ApplicationRecord
def marked_local_only?
# match both with and without U+FE0F (the emoji variation selector)
/#{local_only_emoji}\ufe0f?\z/.match?(content)
/(#{all_local_only_emojis.join('|')})\ufe0f?\z/.match?(content)
end
def local_only_emoji
'👁'
ENV.get('DEFAULT_LOCAL_ONLY_EMOJI', '👁')
end
def all_local_only_emojis
ENV.get('ALTERNATIVE_LOCAL_ONLY_EMOJI', '').split(',').push(local_only_emoji)
end
def status_stat