Skip to content

fix issue not show icon start call in chaneel - #1221

Open
davoodf1995 wants to merge 1 commit into
mattermost:mainfrom
davoodf1995:main
Open

fix issue not show icon start call in chaneel#1221
davoodf1995 wants to merge 1 commit into
mattermost:mainfrom
davoodf1995:main

Conversation

@davoodf1995

Copy link
Copy Markdown

…icense checker

  • Updated session tests to allow calls in DMs only for unlicensed cloud environments and added a new test for self-hosted deployments.
  • Modified the LicenseChecker to support group calls in self-hosted deployments without requiring a Professional license, based on environment variables.

Summary

Ticket Link

Screenshots

Release Note


…icense checker

- Updated session tests to allow calls in DMs only for unlicensed cloud environments and added a new test for self-hosted deployments.
- Modified the LicenseChecker to support group calls in self-hosted deployments without requiring a Professional license, based on environment variables.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

GroupCallsAllowed() is updated to explicitly handle the MM_CALLS_GROUP_CALLS_ALLOWED env var and unconditionally permit group calls on self-hosted (non-cloud) deployments, while cloud deployments still require a Professional license. Session tests are adjusted to reflect the cloud-vs-self-hosted distinction, and the frontend dropdown button visibility is updated to show for group-call-allowed or DM/GM channels.

Changes

Group Calls: Self-Hosted Unrestricted

Layer / File(s) Summary
GroupCallsAllowed() self-hosted vs. cloud branching
server/enterprise/license.go
Replaces the prior single-expression check with explicit "true"/"false" env var handling, then allows all self-hosted deployments unconditionally and enforces isAtLeastProfessionalLicensed() only for cloud.
Session tests for cloud-unlicensed DM and self-hosted open channel
server/session_test.go
Updates the existing DM subtest to mock a starter+cloud licence, and adds a new self-hosted subtest that mocks an empty licence and asserts addUserSession succeeds on an open channel.
ChannelHeaderDropdownButton show prop includes group calls or DM/GM
webapp/src/components/channel_header_dropdown_button/index.ts
Expands the show prop logic in mapStateToProps to permit display when areGroupCallsAllowed(state) is true or the channel is a DM/GM via isDmGmChannel, and adds the corresponding imports.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title refers to showing a call icon in a channel, which is partially addressed by the PR changes to the channel header dropdown button component, but misses the primary changes regarding license checker and session test updates. Clarify the title to better reflect the main focus: either the call icon visibility fix or the license/session test changes. Consider a title like 'Allow group calls in self-hosted deployments based on license checker' or 'Fix call icon visibility with updated license and session handling'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description adequately explains the key changes: session test updates for DMs with cloud/self-hosted distinction, and license checker modifications for self-hosted group calls without Professional licensing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
server/session_test.go (1)

171-185: ⚡ Quick win

Subtest name overstates coverage (“all channels”).

This case only asserts model.ChannelTypeOpen. Please either rename it to match what it verifies, or add private/group/direct cases so it actually validates “all channels” on self-hosted.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/session_test.go` around lines 171 - 185, The test subtest "allow calls
in all channels on self-hosted" is misleading because the addUserSession call at
the end only tests with model.ChannelTypeOpen, not all channel types. Either
rename the subtest to accurately describe that it only tests open channels, or
expand the test to include additional assertions for private, group, and direct
channel types (model.ChannelTypePrivate, model.ChannelTypeGroup,
model.ChannelTypeDirect) to match the "all channels" claim in the test name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/session_test.go`:
- Around line 109-113: To stabilize the flaky tests, you need to pin the
MM_CALLS_GROUP_CALLS_ALLOWED environment variable in both test subtests to
ensure they don't depend on the runner's environment configuration. For the
"allow calls in DMs only on unlicensed cloud" subtest (at lines 109-113) and the
other affected subtest (at lines 171-175), use Go's testing utilities (such as
t.Setenv) to explicitly set the MM_CALLS_GROUP_CALLS_ALLOWED environment
variable to the expected value at the start of each subtest, ensuring the
GroupCallsAllowed() function behavior is consistent regardless of the host
environment's settings.

In `@webapp/src/components/channel_header_dropdown_button/index.ts`:
- Line 18: The code is using isDmGmChannel which includes both direct message
and group message channels, but the backend only permits direct message channels
to be callable when group calls are disallowed on unlicensed cloud. Replace the
isDmGmChannel import and its usage at line 26 with a function or check that only
verifies direct message channels (excluding group message channels) to align the
UI behavior with the backend policy that blocks group channels from being
callable.

---

Nitpick comments:
In `@server/session_test.go`:
- Around line 171-185: The test subtest "allow calls in all channels on
self-hosted" is misleading because the addUserSession call at the end only tests
with model.ChannelTypeOpen, not all channel types. Either rename the subtest to
accurately describe that it only tests open channels, or expand the test to
include additional assertions for private, group, and direct channel types
(model.ChannelTypePrivate, model.ChannelTypeGroup, model.ChannelTypeDirect) to
match the "all channels" claim in the test name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 696ccb76-9723-4346-a549-2a88f7973520

📥 Commits

Reviewing files that changed from the base of the PR and between afcfe15 and 1e1e9fe.

📒 Files selected for processing (3)
  • server/enterprise/license.go
  • server/session_test.go
  • webapp/src/components/channel_header_dropdown_button/index.ts

Comment thread server/session_test.go
Comment on lines +109 to 113
t.Run("allow calls in DMs only on unlicensed cloud", func(t *testing.T) {
defer mockAPI.AssertExpectations(t)
defer mockMetrics.AssertExpectations(t)
defer ResetTestStore(t, p.store)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Stabilize these tests by pinning MM_CALLS_GROUP_CALLS_ALLOWED.

Both subtests rely on the default branch of GroupCallsAllowed(), but they never set/reset the env var. If the runner environment sets MM_CALLS_GROUP_CALLS_ALLOWED, these expectations can flip and become flaky.

Suggested fix
 t.Run("allow calls in DMs only on unlicensed cloud", func(t *testing.T) {
+    t.Setenv("MM_CALLS_GROUP_CALLS_ALLOWED", "")
     defer mockAPI.AssertExpectations(t)
     defer mockMetrics.AssertExpectations(t)
     defer ResetTestStore(t, p.store)
@@
 t.Run("allow calls in all channels on self-hosted", func(t *testing.T) {
+    t.Setenv("MM_CALLS_GROUP_CALLS_ALLOWED", "")
     defer mockAPI.AssertExpectations(t)
     defer mockMetrics.AssertExpectations(t)
     defer ResetTestStore(t, p.store)

Also applies to: 171-175

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/session_test.go` around lines 109 - 113, To stabilize the flaky tests,
you need to pin the MM_CALLS_GROUP_CALLS_ALLOWED environment variable in both
test subtests to ensure they don't depend on the runner's environment
configuration. For the "allow calls in DMs only on unlicensed cloud" subtest (at
lines 109-113) and the other affected subtest (at lines 171-175), use Go's
testing utilities (such as t.Setenv) to explicitly set the
MM_CALLS_GROUP_CALLS_ALLOWED environment variable to the expected value at the
start of each subtest, ensuring the GroupCallsAllowed() function behavior is
consistent regardless of the host environment's settings.

isLimitRestricted,
maxParticipants,
} from 'src/selectors';
import {isDmGmChannel} from 'src/utils';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

GM channels are being shown as callable where backend still blocks them on unlicensed cloud.

Line 26 uses isDmGmChannel(channel), which includes GM. But backend policy still only exempts direct channels when group calls are disallowed, and the updated backend tests still expect group channels to fail. This creates a UI/backend contract mismatch.

Suggested fix
-import {isDmGmChannel} from 'src/utils';
@@
-        show: callsShowButton(state, channel?.id) && (areGroupCallsAllowed(state) || isDmGmChannel(channel)),
+        show: callsShowButton(state, channel?.id) && (areGroupCallsAllowed(state) || channel?.type === 'D'),

Also applies to: 26-26

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webapp/src/components/channel_header_dropdown_button/index.ts` at line 18,
The code is using isDmGmChannel which includes both direct message and group
message channels, but the backend only permits direct message channels to be
callable when group calls are disallowed on unlicensed cloud. Replace the
isDmGmChannel import and its usage at line 26 with a function or check that only
verifies direct message channels (excluding group message channels) to align the
UI behavior with the backend policy that blocks group channels from being
callable.

@bgardner8008

Copy link
Copy Markdown
Contributor

Thanks for the contribution! A few concerns from review, most significant first:

1. server/enterprise/license.goMM_CALLS_GROUP_CALLS_ALLOWED=false now hard-disables group calls even for licensed servers (regression).
The old logic was isAtLeastProfessionalLicensed() || env=="true", so a Professional/Enterprise/cloud-paid server kept group calls regardless of the env var. The new code returns false immediately when the var is "false", before the license check. Any operator who set MM_CALLS_GROUP_CALLS_ALLOWED=false (previously a no-op for licensed servers) would now lose group calls entirely — this turns a soft override into one that beats a paid license.

2. server/enterprise/license.go — the !IsCloud(...) branch removes the Professional-license requirement for group calls on all self-hosted deployments.
This is a licensing-policy change rather than just an icon fix: every unlicensed self-hosted server would now get group calls for free, where previously Professional (or the env var) was required. This is much broader than "show the missing button" and would need product/licensing sign-off before it could merge.

3. webapp/src/components/channel_header_dropdown_button/index.ts — uses isDmGmChannel where the server only exempts DMs.
The server gate in server/session.go (channelType != model.ChannelTypeDirect && !GroupCallsAllowed()errGroupCallsNotAllowed) exempts only ChannelTypeDirect; a GM is not exempt. The sibling channel_header_button.tsx correctly uses isDMChannel(channel). With isDmGmChannel (DM or GM), when group calls aren't allowed the dropdown button appears in a GM, the user clicks "Start call," and the server rejects it. This should use isDMChannel to match the server gate and the sibling component.

@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants