mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* MM-64486: Remove telemetry Remove telemetry from Mattermost. We're no longer relying on Rudder upstream, and no longer making use of this information. * recover mock for SystemStore.Get * Fix TestClearPushNotificationSync by adding missing SystemStore mock The test was failing because the SystemStore mock was missing the Get() method that's required by the ServerId() function. Added the missing mock to return a StringMap with SystemServerId. * fix mocking issue * Remove now-unused telemetry and constants * Remove "Disable telemetry events" debug setting * Remove empty functions * Remove most "Telemetry tracking removed" comments * Remove remains of DataPrefetch telemetry * Remove now-unused prop from InviteMembersButton * Remove trackDotMenuEvent * Remove some more leftover comments * Remove lingering logic related to trackingLocation * Remove now-unused argument from useCopyText * Remove lingering telemetry references from PreparingWorkspace * fixup Remove trackDotMenuEvent * Remove lingering telemetry references from signup page and password check * Update snapshots and fix test broken by my changes * Fix unintended behavior change in thread list filtering Remove handleSetFilter wrapper that was accidentally modified during telemetry removal. The function was calling clear() when switching to unread filter, which was not the original behavior. Use setFilter directly instead, restoring the original functionality. * Remove unused useOpenDowngradeModal hook The useOpenDowngradeModal hook was not being used anywhere in the codebase. * Remove unused expandableLink from useExpandOverageUsersCheck The expandableLink return value was not being used by any components. * Re-add missing TeamLinkClicked performance telemetry The mark(Mark.TeamLinkClicked) call was accidentally removed from the handleSwitch function. This telemetry is needed for Looker-based performance tracking. * drop LogSettings.VerboseDiagnostics --------- Co-authored-by: Harrison Healey <[email protected]> Co-authored-by: Mattermost Build <[email protected]>
147 lines
5.1 KiB
Go
147 lines
5.1 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/v8/channels/store"
|
|
)
|
|
|
|
func (ch *Channels) License() *model.License {
|
|
return ch.srv.License()
|
|
}
|
|
|
|
func (ch *Channels) RequestTrialLicenseWithExtraFields(requesterID string, trialRequest *model.TrialLicenseRequest) *model.AppError {
|
|
requester, err := ch.srv.userService.GetUser(requesterID)
|
|
if err != nil {
|
|
var nfErr *store.ErrNotFound
|
|
switch {
|
|
case errors.As(err, &nfErr):
|
|
return model.NewAppError("RequestTrialLicense", MissingAccountError, nil, "", http.StatusNotFound).Wrap(err)
|
|
default:
|
|
return model.NewAppError("RequestTrialLicense", "app.user.get_by_username.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
|
}
|
|
}
|
|
|
|
if ch.srv.Cloud.ValidateBusinessEmail(requesterID, trialRequest.ContactEmail) != nil {
|
|
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request.business-email", nil, "", http.StatusBadRequest)
|
|
}
|
|
|
|
// Create a new struct only using the fields from the request that are allowed to be set by the client
|
|
sanitizedRequest := &model.TrialLicenseRequest{
|
|
ServerID: ch.srv.ServerId(),
|
|
Name: requester.GetDisplayName(model.ShowFullName),
|
|
Email: requester.Email,
|
|
SiteName: *ch.srv.platform.Config().TeamSettings.SiteName,
|
|
SiteURL: *ch.srv.platform.Config().ServiceSettings.SiteURL,
|
|
Users: trialRequest.Users,
|
|
TermsAccepted: trialRequest.TermsAccepted,
|
|
ReceiveEmailsAccepted: trialRequest.ReceiveEmailsAccepted,
|
|
ContactName: trialRequest.ContactName,
|
|
ContactEmail: trialRequest.ContactEmail,
|
|
CompanyName: trialRequest.CompanyName,
|
|
CompanySize: trialRequest.CompanySize,
|
|
CompanyCountry: trialRequest.CompanyCountry,
|
|
ServerVersion: model.CurrentVersion,
|
|
}
|
|
|
|
if !sanitizedRequest.IsValid() {
|
|
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
|
|
}
|
|
|
|
return ch.srv.platform.RequestTrialLicense(sanitizedRequest)
|
|
}
|
|
|
|
// Deprecated: Use RequestTrialLicenseWithExtraFields instead. This function remains to support the Plugin API.
|
|
func (ch *Channels) RequestTrialLicense(requesterID string, users int, termsAccepted bool, receiveEmailsAccepted bool) *model.AppError {
|
|
if !termsAccepted {
|
|
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request.terms-not-accepted", nil, "", http.StatusBadRequest)
|
|
}
|
|
|
|
if users == 0 {
|
|
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
|
|
}
|
|
|
|
requester, err := ch.srv.userService.GetUser(requesterID)
|
|
if err != nil {
|
|
var nfErr *store.ErrNotFound
|
|
switch {
|
|
case errors.As(err, &nfErr):
|
|
return model.NewAppError("RequestTrialLicense", MissingAccountError, nil, "", http.StatusNotFound).Wrap(err)
|
|
default:
|
|
return model.NewAppError("RequestTrialLicense", "app.user.get_by_username.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
|
}
|
|
}
|
|
|
|
trialLicenseRequest := &model.TrialLicenseRequest{
|
|
ServerID: ch.srv.ServerId(),
|
|
Name: requester.GetDisplayName(model.ShowFullName),
|
|
Email: requester.Email,
|
|
SiteName: *ch.srv.platform.Config().TeamSettings.SiteName,
|
|
SiteURL: *ch.srv.platform.Config().ServiceSettings.SiteURL,
|
|
Users: users,
|
|
TermsAccepted: termsAccepted,
|
|
ReceiveEmailsAccepted: receiveEmailsAccepted,
|
|
}
|
|
|
|
return ch.srv.platform.RequestTrialLicense(trialLicenseRequest)
|
|
}
|
|
|
|
// JWTClaims custom JWT claims with the needed information for the
|
|
// renewal process
|
|
type JWTClaims struct {
|
|
LicenseID string `json:"license_id"`
|
|
ActiveUsers int64 `json:"active_users"`
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
func (s *Server) License() *model.License {
|
|
return s.platform.License()
|
|
}
|
|
|
|
func (s *Server) LoadLicense() {
|
|
s.platform.LoadLicense()
|
|
}
|
|
|
|
func (s *Server) SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
|
|
return s.platform.SaveLicense(licenseBytes)
|
|
}
|
|
|
|
func (s *Server) SetLicense(license *model.License) bool {
|
|
return s.platform.SetLicense(license)
|
|
}
|
|
|
|
func (s *Server) ValidateAndSetLicenseBytes(b []byte) error {
|
|
return s.platform.ValidateAndSetLicenseBytes(b)
|
|
}
|
|
|
|
func (s *Server) SetClientLicense(m map[string]string) {
|
|
s.platform.SetClientLicense(m)
|
|
}
|
|
|
|
func (s *Server) ClientLicense() map[string]string {
|
|
return s.platform.ClientLicense()
|
|
}
|
|
|
|
func (s *Server) RemoveLicense() *model.AppError {
|
|
return s.platform.RemoveLicense()
|
|
}
|
|
|
|
func (s *Server) AddLicenseListener(listener func(oldLicense, newLicense *model.License)) string {
|
|
return s.platform.AddLicenseListener(listener)
|
|
}
|
|
|
|
func (s *Server) RemoveLicenseListener(id string) {
|
|
s.platform.RemoveLicenseListener(id)
|
|
}
|
|
|
|
func (s *Server) GetSanitizedClientLicense() map[string]string {
|
|
return s.platform.GetSanitizedClientLicense()
|
|
}
|