Skip to content

Commit

Permalink
Use custom domains in emails (invites, alerts, reports) and public UR…
Browse files Browse the repository at this point in the history
…Ls (#5515)
  • Loading branch information
begelundmuller committed Aug 26, 2024
1 parent a8e33f3 commit 284a905
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions admin/server/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (s *Server) GetAlertMeta(ctx context.Context, req *adminv1.GetAlertMetaRequ
}

return &adminv1.GetAlertMetaResponse{
OpenUrl: s.admin.URLs.AlertOpen(org.Name, proj.Name, req.Alert),
EditUrl: s.admin.URLs.AlertEdit(org.Name, proj.Name, req.Alert),
OpenUrl: s.admin.URLs.WithCustomDomain(org.CustomDomain).AlertOpen(org.Name, proj.Name, req.Alert),
EditUrl: s.admin.URLs.WithCustomDomain(org.CustomDomain).AlertEdit(org.Name, proj.Name, req.Alert),
QueryForAttributes: attrPB,
}, nil
}
Expand Down
7 changes: 6 additions & 1 deletion admin/server/magic_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func (s *Server) IssueMagicAuthToken(ctx context.Context, req *adminv1.IssueMagi
return nil, status.Error(codes.InvalidArgument, err.Error())
}

org, err := s.admin.DB.FindOrganization(ctx, proj.OrganizationID)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to find organization for project: %v", err.Error())
}

claims := auth.GetClaims(ctx)
projPerms := claims.ProjectPermissions(ctx, proj.OrganizationID, proj.ID)
if !projPerms.CreateMagicAuthTokens {
Expand Down Expand Up @@ -92,7 +97,7 @@ func (s *Server) IssueMagicAuthToken(ctx context.Context, req *adminv1.IssueMagi
tokenStr := token.Token().String()
return &adminv1.IssueMagicAuthTokenResponse{
Token: tokenStr,
Url: s.admin.URLs.MagicAuthTokenOpen(req.Organization, req.Project, tokenStr),
Url: s.admin.URLs.WithCustomDomain(org.CustomDomain).MagicAuthTokenOpen(req.Organization, req.Project, tokenStr),
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions admin/server/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func (s *Server) AddOrganizationMemberUser(ctx context.Context, req *adminv1.Add
err = s.admin.Email.SendOrganizationInvite(&email.OrganizationInvite{
ToEmail: req.Email,
ToName: "",
AcceptURL: s.admin.URLs.OrganizationInviteAccept(org.Name),
AcceptURL: s.admin.URLs.WithCustomDomain(org.CustomDomain).OrganizationInviteAccept(org.Name),
OrgName: org.Name,
RoleName: role.Name,
InvitedByName: invitedByName,
Expand Down Expand Up @@ -601,7 +601,7 @@ func (s *Server) AddOrganizationMemberUser(ctx context.Context, req *adminv1.Add
err = s.admin.Email.SendOrganizationAddition(&email.OrganizationAddition{
ToEmail: req.Email,
ToName: "",
OpenURL: s.admin.URLs.Organization(org.Name),
OpenURL: s.admin.URLs.WithCustomDomain(org.CustomDomain).Organization(org.Name),
OrgName: org.Name,
RoleName: role.Name,
InvitedByName: invitedByName,
Expand Down
10 changes: 5 additions & 5 deletions admin/server/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ func (s *Server) AddProjectMemberUser(ctx context.Context, req *adminv1.AddProje
err = s.admin.Email.SendProjectInvite(&email.ProjectInvite{
ToEmail: req.Email,
ToName: "",
AcceptURL: s.admin.URLs.ProjectInviteAccept(org.Name, proj.Name),
AcceptURL: s.admin.URLs.WithCustomDomain(org.CustomDomain).ProjectInviteAccept(org.Name, proj.Name),
OrgName: org.Name,
ProjectName: proj.Name,
RoleName: role.Name,
Expand All @@ -825,7 +825,7 @@ func (s *Server) AddProjectMemberUser(ctx context.Context, req *adminv1.AddProje
err = s.admin.Email.SendProjectAddition(&email.ProjectAddition{
ToEmail: req.Email,
ToName: "",
OpenURL: s.admin.URLs.Project(org.Name, proj.Name),
OpenURL: s.admin.URLs.WithCustomDomain(org.CustomDomain).Project(org.Name, proj.Name),
OrgName: org.Name,
ProjectName: proj.Name,
RoleName: role.Name,
Expand Down Expand Up @@ -1049,8 +1049,8 @@ func (s *Server) RequestProjectAccess(ctx context.Context, req *adminv1.RequestP
Email: user.Email,
OrgName: org.Name,
ProjectName: proj.Name,
ApproveLink: s.admin.URLs.ApproveProjectAccess(org.Name, proj.Name, accessReq.ID),
DenyLink: s.admin.URLs.DenyProjectAccess(org.Name, proj.Name, accessReq.ID),
ApproveLink: s.admin.URLs.WithCustomDomain(org.CustomDomain).ApproveProjectAccess(org.Name, proj.Name, accessReq.ID),
DenyLink: s.admin.URLs.WithCustomDomain(org.CustomDomain).DenyProjectAccess(org.Name, proj.Name, accessReq.ID),
})
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
Expand Down Expand Up @@ -1139,7 +1139,7 @@ func (s *Server) ApproveProjectAccess(ctx context.Context, req *adminv1.ApproveP
err = s.admin.Email.SendProjectAccessGranted(&email.ProjectAccessGranted{
ToEmail: user.Email,
ToName: user.DisplayName,
OpenURL: s.admin.URLs.Project(org.Name, proj.Name),
OpenURL: s.admin.URLs.WithCustomDomain(org.CustomDomain).Project(org.Name, proj.Name),
OrgName: org.Name,
ProjectName: proj.Name,
})
Expand Down
6 changes: 3 additions & 3 deletions admin/server/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func (s *Server) GetReportMeta(ctx context.Context, req *adminv1.GetReportMetaRe
}

return &adminv1.GetReportMetaResponse{
OpenUrl: s.admin.URLs.ReportOpen(org.Name, proj.Name, req.Report, req.ExecutionTime.AsTime()),
ExportUrl: s.admin.URLs.ReportExport(org.Name, proj.Name, req.Report),
EditUrl: s.admin.URLs.ReportEdit(org.Name, proj.Name, req.Report),
OpenUrl: s.admin.URLs.WithCustomDomain(org.CustomDomain).ReportOpen(org.Name, proj.Name, req.Report, req.ExecutionTime.AsTime()),
ExportUrl: s.admin.URLs.WithCustomDomain(org.CustomDomain).ReportExport(org.Name, proj.Name, req.Report),
EditUrl: s.admin.URLs.WithCustomDomain(org.CustomDomain).ReportEdit(org.Name, proj.Name, req.Report),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion proto/rill/admin/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ message Project {
string prod_olap_dsn = 11;
int64 prod_slots = 12;
string prod_deployment_id = 13;
string frontend_url = 16;
string frontend_url = 16; // Note: Does NOT incorporate the parent org's custom domain.
int64 prod_ttl_seconds = 18;
map<string, string> annotations = 20;
string prod_version = 21;
Expand Down

0 comments on commit 284a905

Please sign in to comment.