From 0d1eb02341b43722fb1280986710bfaba29b2e4f Mon Sep 17 00:00:00 2001 From: Farhan Munshi <3207297+fmunshi@users.noreply.github.com> Date: Fri, 8 May 2020 14:19:01 -0400 Subject: [PATCH] [MM-24827] Disable group mentions on e10 or team edition (#14475) * MM-24827 Disable group mentions when ldap groups not enabled * Trigger CI Co-authored-by: mattermod --- app/notification.go | 4 ++++ app/notification_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/app/notification.go b/app/notification.go index 6167633a5c..d1712b85d8 100644 --- a/app/notification.go +++ b/app/notification.go @@ -740,6 +740,10 @@ func (a *App) allowChannelMentions(post *model.Post, numProfiles int) bool { // allowGroupMentions returns whether or not the group mentions are allowed for the given post. func (a *App) allowGroupMentions(post *model.Post) bool { + if license := a.License(); license == nil || !*license.Features.LDAPGroups { + return false + } + if !a.HasPermissionToChannel(post.UserId, post.ChannelId, model.PERMISSION_USE_GROUP_MENTIONS) { return false } diff --git a/app/notification_test.go b/app/notification_test.go index 43d37e8bbe..03bae9bc75 100644 --- a/app/notification_test.go +++ b/app/notification_test.go @@ -999,6 +999,13 @@ func TestAllowGroupMentions(t *testing.T) { post := &model.Post{ChannelId: th.BasicChannel.Id, UserId: th.BasicUser.Id} + t.Run("should return false without ldap groups license", func(t *testing.T) { + allowGroupMentions := th.App.allowGroupMentions(post) + assert.False(t, allowGroupMentions) + }) + + th.App.SetLicense(model.NewTestLicense("ldap_groups")) + t.Run("should return true for a regular post with few channel members", func(t *testing.T) { allowGroupMentions := th.App.allowGroupMentions(post) assert.True(t, allowGroupMentions)