Created
October 18, 2024 06:01
-
-
Save Tampa/090bb7ff89c0e15a4570b6c4d9de7736 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subject: [PATCH] Stop paywalling things | |
--- | |
server/configuration.go | 3 -- | |
server/enterprise/license.go | 4 -- | |
server/session.go | 26 +-------- | |
server/session_test.go | 54 ------------------- | |
server/telemetry.go | 37 +++---------- | |
.../src/components/channel_header_button.tsx | 4 +- | |
webapp/src/selectors.ts | 2 - | |
webapp/src/slash_commands.tsx | 9 ---- | |
webapp/src/types/types.ts | 1 - | |
9 files changed, 10 insertions(+), 130 deletions(-) | |
diff --git a/server/configuration.go b/server/configuration.go | |
index 9e959cb..3839750 100644 | |
--- a/server/configuration.go | |
+++ b/server/configuration.go | |
@@ -135,8 +135,6 @@ type clientConfig struct { | |
HostControlsAllowed bool | |
// When set to true it enables using the AV1 codec to encode screen sharing tracks. | |
EnableAV1 *bool | |
- // Let the server determine whether or not group calls are allowed (through license checks or otherwise) | |
- GroupCallsAllowed bool | |
} | |
type adminClientConfig struct { | |
@@ -516,7 +514,6 @@ func (p *Plugin) getClientConfig(c *configuration) clientConfig { | |
SkuShortName: skuShortName, | |
HostControlsAllowed: p.licenseChecker.HostControlsAllowed(), | |
EnableAV1: c.EnableAV1, | |
- GroupCallsAllowed: p.licenseChecker.GroupCallsAllowed(), | |
} | |
} | |
diff --git a/server/enterprise/license.go b/server/enterprise/license.go | |
index 23a55d2..368a832 100644 | |
--- a/server/enterprise/license.go | |
+++ b/server/enterprise/license.go | |
@@ -56,7 +56,3 @@ func (e *LicenseChecker) TranscriptionsAllowed() bool { | |
func (e *LicenseChecker) HostControlsAllowed() bool { | |
return e.isAtLeastE10Licensed() | |
} | |
- | |
-func (e *LicenseChecker) GroupCallsAllowed() bool { | |
- return e.isAtLeastE10Licensed() || os.Getenv("MM_CALLS_GROUP_CALLS_ALLOWED") == "true" | |
-} | |
diff --git a/server/session.go b/server/session.go | |
index eb9edfe..19b91b7 100644 | |
--- a/server/session.go | |
+++ b/server/session.go | |
@@ -22,9 +22,6 @@ const ( | |
msgChSize = 50 | |
) | |
-var ( | |
- errGroupCallsNotAllowed = fmt.Errorf("unlicensed servers only allow calls in DMs") | |
-) | |
type session struct { | |
userID string | |
@@ -100,23 +97,8 @@ func (p *Plugin) addUserSession(state *callState, callsEnabled *bool, userID, co | |
}() | |
// If there is an ongoing call, we can let anyone join. | |
- if state == nil { | |
- if err := p.userCanStartOrJoin(userID, callsEnabled, ct); err != nil { | |
- if errors.Is(err, errGroupCallsNotAllowed) { | |
- T := p.getTranslationFunc("") | |
- // Sending a message for unsupported clients (e.g. older mobile apps). | |
- p.API.SendEphemeralPost( | |
- userID, | |
- &model.Post{ | |
- UserId: p.getBotID(), | |
- ChannelId: channelID, | |
- Message: T("app.add_user_session.group_calls_not_allowed_error"), | |
- }, | |
- ) | |
- } | |
- return nil, err | |
- } | |
- } | |
+ if state == nil && !p.userCanStartOrJoin(userID, callsEnabled) { | |
+ return nil, fmt.Errorf("calls are not enabled") | |
if state == nil { | |
state = &callState{ | |
@@ -253,10 +235,6 @@ func (p *Plugin) userCanStartOrJoin(userID string, enabled *bool, channelType mo | |
// otherwise (not explicitly enabled and not default enabled), only sysadmins can start | |
// TODO: look to see what logic we should lift to the joinCall fn | |
- if channelType != model.ChannelTypeDirect && !p.licenseChecker.GroupCallsAllowed() { | |
- return errGroupCallsNotAllowed | |
- } | |
- | |
cfg := p.getConfiguration() | |
explicitlyEnabled := enabled != nil && *enabled | |
diff --git a/server/session_test.go b/server/session_test.go | |
index e0f8410..981ff35 100644 | |
--- a/server/session_test.go | |
+++ b/server/session_test.go | |
@@ -106,58 +106,4 @@ func TestAddUserSession(t *testing.T) { | |
require.Equal(t, retState, retState2) | |
}) | |
- t.Run("allow calls in DMs only when unlicensed", func(t *testing.T) { | |
- defer mockAPI.AssertExpectations(t) | |
- defer mockMetrics.AssertExpectations(t) | |
- defer ResetTestStore(t, p.store) | |
- | |
- mockAPI.On("GetConfig").Return(&model.Config{}, nil).Times(6) | |
- mockAPI.On("GetLicense").Return(&model.License{}, nil).Times(3) | |
- | |
- t.Run("public channel", func(t *testing.T) { | |
- mockAPI.On("SendEphemeralPost", "userA", &model.Post{ | |
- ChannelId: "channelID", | |
- Message: "app.add_user_session.group_calls_not_allowed_error", | |
- }).Return(nil).Once() | |
- | |
- retState, err := p.addUserSession(nil, model.NewBool(true), "userA", "connA", "channelID", "", model.ChannelTypeOpen) | |
- require.Equal(t, errGroupCallsNotAllowed, err) | |
- require.Nil(t, retState) | |
- }) | |
- | |
- t.Run("private channel", func(t *testing.T) { | |
- mockAPI.On("SendEphemeralPost", "userA", &model.Post{ | |
- ChannelId: "channelID", | |
- Message: "app.add_user_session.group_calls_not_allowed_error", | |
- }).Return(nil).Once() | |
- | |
- retState, err := p.addUserSession(nil, model.NewBool(true), "userA", "connA", "channelID", "", model.ChannelTypePrivate) | |
- require.Equal(t, errGroupCallsNotAllowed, err) | |
- require.Nil(t, retState) | |
- }) | |
- | |
- t.Run("group channel", func(t *testing.T) { | |
- mockAPI.On("SendEphemeralPost", "userA", &model.Post{ | |
- ChannelId: "channelID", | |
- Message: "app.add_user_session.group_calls_not_allowed_error", | |
- }).Return(nil).Once() | |
- | |
- retState, err := p.addUserSession(nil, model.NewBool(true), "userA", "connA", "channelID", "", model.ChannelTypeGroup) | |
- require.Equal(t, errGroupCallsNotAllowed, err) | |
- require.Nil(t, retState) | |
- }) | |
- | |
- t.Run("direct channel", func(t *testing.T) { | |
- mockMetrics.On("IncWebSocketEvent", "out", wsEventCallHostChanged).Once() | |
- mockAPI.On("PublishWebSocketEvent", wsEventCallHostChanged, mock.Anything, | |
- &model.WebsocketBroadcast{UserId: "userA", ChannelId: "channelID", ReliableClusterSend: true}).Once() | |
- | |
- retState, err := p.addUserSession(nil, model.NewBool(true), "userA", "connA", "channelID", "", model.ChannelTypeDirect) | |
- require.NoError(t, err) | |
- require.NotNil(t, retState) | |
- require.Equal(t, map[string]struct{}{"userA": {}}, retState.Props.Participants) | |
- require.Len(t, retState.sessions, 1) | |
- require.NotNil(t, retState.sessions["connA"]) | |
- }) | |
- }) | |
} | |
diff --git a/server/telemetry.go b/server/telemetry.go | |
index c6f8add..3479ff3 100644 | |
--- a/server/telemetry.go | |
+++ b/server/telemetry.go | |
@@ -109,9 +109,7 @@ func (p *Plugin) track(ev string, props map[string]any) { | |
skus := eventToSkusMap[ev] | |
if ev == evCallStarted && props != nil { | |
- if ct, _ := props["ChannelType"].(model.ChannelType); ct != model.ChannelTypeDirect { | |
- skus = professionalSKUs | |
- } | |
+ return nil; | |
} | |
ctx := &analytics.Context{ | |
@@ -123,9 +121,6 @@ func (p *Plugin) track(ev string, props map[string]any) { | |
}, | |
} | |
- if err := p.telemetry.Track(ev, props, ctx); err != nil { | |
- p.LogError(err.Error()) | |
- } | |
} | |
func (p *Plugin) uninitTelemetry() error { | |
@@ -140,31 +135,13 @@ func (p *Plugin) uninitTelemetry() error { | |
func (p *Plugin) initTelemetry(enableDiagnostics *bool) error { | |
p.mut.Lock() | |
defer p.mut.Unlock() | |
- if p.telemetry == nil && enableDiagnostics != nil && *enableDiagnostics { | |
- p.LogDebug("Initializing telemetry") | |
- // setup telemetry | |
- client, err := telemetry.NewClient(telemetry.ClientConfig{ | |
- WriteKey: rudderWriteKey, | |
- DataplaneURL: rudderDataplaneURL, | |
- DiagnosticID: p.API.GetDiagnosticId(), | |
- DefaultProps: map[string]any{ | |
- "ServerVersion": p.API.GetServerVersion(), | |
- "PluginVersion": manifest.Version, | |
- "PluginBuild": buildHash, | |
- }, | |
- }) | |
- if err != nil { | |
- return err | |
- } | |
- p.telemetry = client | |
- } else if p.telemetry != nil && (enableDiagnostics == nil || !*enableDiagnostics) { | |
- p.LogDebug("Deinitializing telemetry") | |
- // destroy telemetry | |
- if err := p.telemetry.Close(); err != nil { | |
- return err | |
- } | |
- p.telemetry = nil | |
+ | |
+ // destroy telemetry | |
+ if err := p.telemetry.Close(); err != nil { | |
+ return err | |
} | |
+ p.telemetry = nil | |
+ | |
return nil | |
} | |
diff --git a/webapp/src/components/channel_header_button.tsx b/webapp/src/components/channel_header_button.tsx | |
index bd1353d..1fbc756 100644 | |
--- a/webapp/src/components/channel_header_button.tsx | |
+++ b/webapp/src/components/channel_header_button.tsx | |
@@ -8,7 +8,6 @@ import {useSelector} from 'react-redux'; | |
import CompassIcon from 'src/components/icons/compassIcon'; | |
import {Header, Spinner, SubHeader} from 'src/components/shared'; | |
import { | |
- areGroupCallsAllowed, | |
callsShowButton, | |
channelIDForCurrentCall, | |
clientConnecting, | |
@@ -37,14 +36,13 @@ const ChannelHeaderButton = () => { | |
const maxCallParticipants = useSelector(maxParticipants); | |
const isChannelArchived = channel && channel.delete_at > 0; | |
const isClientConnecting = useSelector(clientConnecting); | |
- const callsAllowed = useSelector(areGroupCallsAllowed) || isDMChannel(channel); | |
const {formatMessage} = useIntl(); | |
const [joining, setJoining] = useState(false); // doesn't matter, will be set below | |
const onClick = () => setJoining(hasCall); | |
- if (!show || !channel || !callsAllowed) { | |
+ if (!show || !channel) { | |
return null; | |
} | |
diff --git a/webapp/src/selectors.ts b/webapp/src/selectors.ts | |
index 551b6e3..2f0747f 100644 | |
--- a/webapp/src/selectors.ts | |
+++ b/webapp/src/selectors.ts | |
@@ -578,8 +578,6 @@ export const isAtLeastProfessional = (state: GlobalState): boolean => { | |
export const areHostControlsAllowed = (state: GlobalState): boolean => callsConfig(state).HostControlsAllowed; | |
-export const areGroupCallsAllowed = (state: GlobalState): boolean => callsConfig(state).GroupCallsAllowed; | |
- | |
export const adminStats = (state: GlobalState) => state.entities.admin.analytics; | |
export const getChannelUrlAndDisplayName = (state: GlobalState, channel?: Channel) => { | |
diff --git a/webapp/src/slash_commands.tsx b/webapp/src/slash_commands.tsx | |
index eb08542..016de99 100644 | |
--- a/webapp/src/slash_commands.tsx | |
+++ b/webapp/src/slash_commands.tsx | |
@@ -21,7 +21,6 @@ import * as Telemetry from 'src/types/telemetry'; | |
import {getClientLogs, logDebug} from './log'; | |
import { | |
- areGroupCallsAllowed, | |
channelHasCall, | |
channelIDForCurrentCall, | |
hostIDForCallInChannel, | |
@@ -58,14 +57,6 @@ export default async function slashCommandsHandler(store: Store, joinCall: joinC | |
channel = res.data; | |
} | |
- if (!isDMChannel(channel) && !areGroupCallsAllowed(store.getState())) { | |
- store.dispatch(displayGenericErrorModal( | |
- defineMessage({defaultMessage: 'Unable to join call'}), | |
- defineMessage({defaultMessage: 'Calls are only available in DM channels.'}), | |
- )); | |
- return {}; | |
- } | |
- | |
if (subCmd === 'start') { | |
if (channelHasCall(store.getState(), args.channel_id)) { | |
store.dispatch(displayGenericErrorModal( | |
diff --git a/webapp/src/types/types.ts b/webapp/src/types/types.ts | |
index 33b4ed2..0b16ad9 100644 | |
--- a/webapp/src/types/types.ts | |
+++ b/webapp/src/types/types.ts | |
@@ -21,7 +21,6 @@ export const CallsConfigDefault: CallsConfig = { | |
HostControlsAllowed: false, | |
EnableAV1: false, | |
TranscribeAPI: TranscribeAPI.WhisperCPP, | |
- GroupCallsAllowed: false, | |
}; | |
export type ChannelState = { | |
-- | |
2.45.2.windows.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment