slack_import: Fix thread conversion condition.

Currently, threads in Slack direct messages will increment the
`thread_counter` variable inside the thread conversion logic. Since we
don't treat thread messages in Slack DMs differently than any other DM,
threads in DM will only falsely increment the thread topic names in
channels.

This adds a condition that checks if the Slack message is a DM or not
before executing the thread conversion logic.

(cherry picked from commit d5e28bcd28)
This commit is contained in:
PieterCK
2025-03-06 18:01:41 +07:00
committed by Tim Abbott
parent af3eefb951
commit 36339b6998

View File

@@ -1005,7 +1005,7 @@ def channel_message_to_zerver_message(
# threads each generate a unique topic labeled by the date and
# a counter among topics on that day.
topic_name = "imported from Slack"
if convert_slack_threads and "thread_ts" in message:
if convert_slack_threads and not is_direct_message_type and "thread_ts" in message:
thread_ts = datetime.fromtimestamp(float(message["thread_ts"]), tz=timezone.utc)
thread_ts_str = thread_ts.strftime(r"%Y/%m/%d %H:%M:%S")
# The topic name is "2015-08-18 Slack thread 2", where the counter at the end is to disambiguate