Repository: getsentry/sentry

Issue:
[Project Transfer] Request Approval Email Uses Incorrect Customer Subdomain
r### Environment

SaaS (https://sentry.io/)

### Version

n/a

### Link

[relevant transaction](https://sentry.sentry.io/discover/javascript:31e672a100fd44f5ab3ac36d4be4dbd3/?field=title&field=event.type&field=project&field=user.display&field=timestamp&field=replayId&homepage=true&name=All+Events&project=11276&query=url%3A%22https%3A%2F%2Fmagiclamp-mobile-website-appli.sentry.io%2F%2A%22&sort=-timestamp&statsPeriod=14d&yAxis=count%28%29)

### DSN

n/a

### Steps to Reproduce

1. Org A requests a project transfer - supplies an owner email for Org B
2. Org B owner clicks link in resulting "Request for Project Transfer" email
3. Link directs Org B owner to **org-a**.sentry.io/accept-transfer/?data=<some_hash>

### Expected Result

...
3. Link directs Org B owner to **org-b**.sentry.io/accept-transfer/?data=<some_hash>

### Actual Result

Because Org B owner is not authenticated with orb-a.sentry.io they're asked to login, which will result in a variety of issues.

Here's [a transaction where this happened](https://sentry.sentry.io/discover/javascript:31e672a100fd44f5ab3ac36d4be4dbd3/)


Discussion:
Assigning to @getsentry/support for [routing](https://open.sentry.io/triage/#2-route), due by **<time datetime=2023-02-17T22:00:00.000Z>Friday, February 17th at 17:00</time> (yyz)**. ⏲️
Routing to @getsentry/enterprise for [triage](https://develop.sentry.dev/processing-tickets/#3-triage), due by **<time datetime=2023-02-22T01:00:00.000Z>Tuesday, February 21st at 5:00 pm</time> (sfo)**. ⏲️

Resolving patch:
diff --git a/src/sentry/api/endpoints/project_transfer.py b/src/sentry/api/endpoints/project_transfer.py
--- a/src/sentry/api/endpoints/project_transfer.py
+++ b/src/sentry/api/endpoints/project_transfer.py
@@ -13,6 +13,7 @@
 from sentry.api.decorators import sudo_required
 from sentry.models import OrganizationMember
 from sentry.utils.email import MessageBuilder
+from sentry.utils.http import absolute_uri
 from sentry.utils.signing import sign
 
 delete_logger = logging.getLogger("sentry.deletions.api")
@@ -79,9 +80,7 @@ def post(self, request: Request, project) -> Response:
             "from_org": project.organization.name,
             "project_name": project.slug,
             "request_time": timezone.now(),
-            "url": organization.absolute_url(
-                "/accept-transfer/", query=urlencode({"data": url_data})
-            ),
+            "url": absolute_uri(f"/accept-transfer/?{urlencode({'data': url_data})}"),
             "requester": request.user,
         }
         MessageBuilder(


Test patch:
diff --git a/tests/sentry/api/endpoints/test_project_transfer.py b/tests/sentry/api/endpoints/test_project_transfer.py
--- a/tests/sentry/api/endpoints/test_project_transfer.py
+++ b/tests/sentry/api/endpoints/test_project_transfer.py
@@ -41,7 +41,7 @@ def test_transfer_project(self):
 
             assert response.status_code == 204
             assert len(mail.outbox) == 1
-            assert organization.absolute_url("/accept-transfer/?") in mail.outbox[0].body
+            assert "http://testserver/accept-transfer/?" in mail.outbox[0].body
 
     def test_transfer_project_owner_from_team(self):
         project = self.create_project()