Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

slack_integration: Avoid showing sender username.

PieterCK57c07bcf030d
diff --git a/static/images/integrations/slack/001.png b/static/images/integrations/slack/001.png
index 97ee5b29510..3aaac6a6ae4 100644
Binary files a/static/images/integrations/slack/001.png and b/static/images/integrations/slack/001.png differ
diff --git a/zerver/webhooks/slack/tests.py b/zerver/webhooks/slack/tests.py
index 89568f34f7b..e3db03d1997 100644
--- a/zerver/webhooks/slack/tests.py
+++ b/zerver/webhooks/slack/tests.py
@@ -12,7 +12,7 @@ from zerver.webhooks.slack.view import INVALID_SLACK_TOKEN_MESSAGE
EXPECTED_TOPIC = "Message from Slack"
MESSAGE_WITH_NORMAL_TEXT = "Hello, this is a normal text message"
-USER = "supersecretemail"
+USER = "John Doe"
CHANNEL = "general"
EXPECTED_MESSAGE = "**{user}**: {message}"
TOPIC_WITH_CHANNEL = "channel: {channel}"
@@ -166,9 +166,7 @@ class SlackWebhookTests(WebhookTestCase):
@mock_slack_api_calls
def test_message_with_channel_and_user_mentions(self) -> None:
- message_body = (
- "@**supersecretemail** **#general** message with both channel and user mentions"
- )
+ message_body = "@**John Doe** **#general** message with both channel and user mentions"
expected_message = EXPECTED_MESSAGE.format(user=USER, message=message_body)
self.check_webhook(
"message_with_channel_and_user_mentions",
@@ -237,7 +235,9 @@ class SlackWebhookTests(WebhookTestCase):
@mock_slack_api_calls
def test_message_with_user_mentions(self) -> None:
- message_body = "@**supersecretemail** @**supersecretemail** @**supersecretemail** hello, this is a message with mentions"
+ message_body = (
+ "@**John Doe** @**John Doe** @**John Doe** hello, this is a message with mentions"
+ )
expected_message = EXPECTED_MESSAGE.format(user=USER, message=message_body)
self.check_webhook(
"message_with_user_mentions",
@@ -308,7 +308,7 @@ class SlackWebhookTests(WebhookTestCase):
@mock_slack_api_calls
def test_message_with_complex_formatted_mentions(self) -> None:
- message_body = "@**supersecretemail** **#general** ~~***@**all*****~~"
+ message_body = "@**John Doe** **#general** ~~***@**all*****~~"
expected_message = EXPECTED_MESSAGE.format(user=USER, message=message_body)
self.check_webhook(
"message_with_complex_formatted_mentions",
diff --git a/zerver/webhooks/slack/view.py b/zerver/webhooks/slack/view.py
index a0dd1a67797..5908689b7c2 100644
--- a/zerver/webhooks/slack/view.py
+++ b/zerver/webhooks/slack/view.py
@@ -64,7 +64,7 @@ def get_slack_sender_name(user_id: str, token: str) -> str:
token=token,
user=user_id,
)
- return slack_user_data["name"]
+ return slack_user_data["real_name"]
def convert_slack_user_and_channel_mentions(text: str, app_token: str) -> str: