Skip to content

Commit e6e08e4

Browse files
encoding ids
1 parent b91fa97 commit e6e08e4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/sentry/api/endpoints/organization_intercom_jwt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
RpcUserOrganizationContext,
1717
)
1818
from sentry.utils import jwt
19+
from sentry.utils.hashlib import md5_text
1920

2021
logger = logging.getLogger(__name__)
2122

@@ -70,7 +71,7 @@ def get(
7071
now = int(datetime.datetime.now(datetime.UTC).timestamp())
7172
exp = now + JWT_VALIDITY_WINDOW_SECONDS
7273
# intercom creates chat history based on this ID so we need one per (org, user) pair
73-
intercom_user_id = f"{user.id}-{organization.id}"
74+
intercom_user_id = md5_text(f"{user.id}-{organization.id}").hexdigest()
7475

7576
# Build JWT claims - user_id is required by Intercom
7677
claims = {

tests/sentry/api/endpoints/test_organization_intercom_jwt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from sentry.testutils.cases import APITestCase
22
from sentry.testutils.silo import control_silo_test
33
from sentry.utils import jwt
4+
from sentry.utils.hashlib import md5_text
45

56

67
@control_silo_test
@@ -27,7 +28,7 @@ def test_get_jwt_without_secret_configured(self) -> None:
2728
def test_get_jwt_success(self) -> None:
2829
"""With feature flag and secret configured, should return JWT and user data."""
2930
test_secret = "test-intercom-secret-key"
30-
intercom_user_id = f"{self.user.id}-{self.organization.id}"
31+
intercom_user_id = md5_text(f"{self.user.id}-{self.organization.id}").hexdigest()
3132

3233
with (
3334
self.feature("organizations:intercom-support"),

0 commit comments

Comments
 (0)