* WIP * adding initial creategroup endpoint * fetching by group source * fixing startup error * updating create endpoint to take an array of user_ids, this will allow us to create the group with one request * adding delete group endpoint and appropriate test * adding source param for getGroups * adding add members and delete members endpoints * locking down crud endpoints to only be allowed for custom groups * user search stuff * allowing remoteid be null by changing field to pointer * code cleanup and store level tests * adding new tests and removing unused endpoint * resolving conflicts * Adds authz check for group. * Adds authz checks to groups APIs. * Updated create group authz tests. * Updates delete group tests. * Tests create group. * Adds some tests and validations. * adding new parameter so I can get users not in a group * Fixed all lint warnings. * Fix type. * fixing search users not in group * Fixes some lint errors. * Moves entry in JSON array. * Fixed SQL query. * Fixes permission migration test. * Fixes migration test. * Fixes some group store tests. * Fix test. * Fix test. * Revert lint change. * Migrated CreateWithUserIds to sqlx. * Adds tests for GetMember; migrates implementation to sqlx. * Tests GetNonMemberUsersPage and hanles wrong group id. * Fixes test. * Switches GetMaster to GetMasterX. * Switches GetReplica to GetReplicaX. * Fixes logic. * Fixes shadow declaration. * Adds include_member_count to get group API endpoint. * Adds filter_has_member param to getGroups. * Fixes. * Removes array of group sources. * fixing error * Testing reverting CreateWithUserIds back to gorp. * Added websocket event for CreateGroupWithUserIds. * Changed a few response status codes. Switched to correct permission. * Added member count to ws payload for group when updating or creating. * Adds feature flag checks for custom groups. * Added middleware function to require license. Added config to disable custom groups. * Change for function signature change of executePossiblyEmptyQuery. * Lint fixes. * Adds telemetry none comment. * Adds translations. * Migrated to sqlx. * Temp. removal of translation. * Fixed typo. * Added an intermediary model to query with a field that is now ignored by sqlx on read queries. * Re-used existing store struct. * Inludes member count. * Fix for merge error.' * Require license for group endpoints. * Updates translations. * Fix shadow declaration. * Renames permissions. Switches to new method to retrieve remoteid. * Added WS events for upsert and delete member(s). * Added new store error type ErrUniqueConstraint. * Added EnableCustonGroups to the client config. * Sanitized some user records. * Added parameter to include_total_count for listing groups. * Added translations. * adding deleteAt field to getByUsers query * Revert sanitize. * Added uniqueness constraint error to UpdateGroup. * Removed the FutureFeatures flag so that the feature is not enabled on old Enterprise licenses. * Renamed function. * Updates authz check for user search related to groups. * Removed debug statement. * Removed unused app method. * Added telemetry for enable_custom_groups. * Returns early from nil license. * Updates test. * Returned early to avoid nesting in (*SqlGroupStore).checkUserExist. Switched to reading from replica in (*SqlGroupStore).GetMember. Handled JSON marshal error in (*Client4).UpsertGroupMembers * Switched to SanitizeProfile. * Switched to model.NewInt. * Switched from status NotImplemented to Forbidden for missing license. * Removed deactivated users from 'exists' set. * Revert gotool update. * Ignored lint error that I think is invalid. * Added the approprate access tag for disabling custom groups. * Revert change to response status. * Fixed refactor mistake. * Limited the group member WS events to individual users. * Removed WS event of deleted groups. * Updated license check for searchUsers endpoint. * Switched from license feature to license sku. * Update app/group.go Co-authored-by: Claudio Costa <cstcld91@gmail.com> * Update app/group.go Co-authored-by: Claudio Costa <cstcld91@gmail.com> * Remove linter ignore comment. * Added function to create sku-specific license. * Fixed typo. Removed comment. * Fixed for wrong type. * Added missing param to client. Removed unnecessary props setting. Added test for retrieving groups by source. * Updated some tests now that we're validating group membership not created for deactivated user. * Fix for groups endpoint returning all group types by default. * Changes constant names. Adds migration for all users to manage custom group members. * Removes requirement for manage_system permission to filter user search by group. * Added migration mock. * Removes default permissions from custom_group_user role. * Fixes migration. * Fixes emoji migration test. * fixing issue with member counts * fixing search issue for deleted members Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local> Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.fritz.box> Co-authored-by: Claudio Costa <cstcld91@gmail.com>
154 строки
4.2 KiB
Go
154 строки
4.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"reflect"
|
|
"strconv"
|
|
)
|
|
|
|
type FeatureFlags struct {
|
|
// Exists only for unit and manual testing.
|
|
// When set to a value, will be returned by the ping endpoint.
|
|
TestFeature string
|
|
// Exists only for testing bool functionality. Boolean feature flags interpret "on" or "true" as true and
|
|
// all other values as false.
|
|
TestBoolFeature bool
|
|
|
|
// Toggle on and off scheduled jobs for cloud user limit emails see MM-29999
|
|
CloudDelinquentEmailJobsEnabled bool
|
|
|
|
// Toggle on and off support for Collapsed Threads
|
|
CollapsedThreads bool
|
|
|
|
// Enable the remote cluster service for shared channels.
|
|
EnableRemoteClusterService bool
|
|
|
|
// AppsEnabled toggles the Apps framework functionalities both in server and client side
|
|
AppsEnabled bool
|
|
|
|
// AppBarEnabled toggles the App Bar component on client side
|
|
AppBarEnabled bool
|
|
|
|
// Feature flags to control plugin versions
|
|
PluginPlaybooks string `plugin_id:"playbooks"`
|
|
PluginApps string `plugin_id:"com.mattermost.apps"`
|
|
PluginFocalboard string `plugin_id:"focalboard"`
|
|
|
|
PermalinkPreviews bool
|
|
|
|
// Enable the Global Header
|
|
GlobalHeader bool
|
|
|
|
// Determine whether when a user gets created, they'll have noisy notifications e.g. Send desktop notifications for all activity
|
|
NewAccountNoisy bool
|
|
|
|
// Enable Calls plugin support in the mobile app
|
|
CallsMobile bool
|
|
|
|
// A dash separated list for feature flags to turn on for Boards
|
|
BoardsFeatureFlags string
|
|
|
|
// A/B test for the add members to channel button, possible values = ("top", "bottom")
|
|
AddMembersToChannel string
|
|
|
|
// Enable Create First Channel
|
|
GuidedChannelCreation bool
|
|
|
|
// Determine after which duration in hours to send a second invitation to someone that didn't join after the initial invite, possible values = ("48", "72")
|
|
ResendInviteEmailInterval string
|
|
|
|
// A/B test for whether radio buttons or toggle button is more effective in in-screen invite to team modal ("none", "toggle")
|
|
InviteToTeam string
|
|
|
|
CustomGroups bool
|
|
|
|
// Enable inline post editing
|
|
InlinePostEditing bool
|
|
|
|
// Enable DataRetention for Boards
|
|
BoardsDataRetention bool
|
|
|
|
NormalizeLdapDNs bool
|
|
|
|
// Enable special onboarding flow for first admin
|
|
UseCaseOnboarding bool
|
|
|
|
// Enable Workspace optimization dashboard
|
|
WorkspaceOptimizationDashboard bool
|
|
|
|
// Enable GraphQL feature
|
|
GraphQL bool
|
|
}
|
|
|
|
func (f *FeatureFlags) SetDefaults() {
|
|
f.TestFeature = "off"
|
|
f.TestBoolFeature = false
|
|
f.CloudDelinquentEmailJobsEnabled = false
|
|
f.CollapsedThreads = true
|
|
f.EnableRemoteClusterService = false
|
|
f.AppsEnabled = false
|
|
f.AppBarEnabled = false
|
|
f.PluginApps = ""
|
|
f.PluginFocalboard = ""
|
|
f.PermalinkPreviews = true
|
|
f.GlobalHeader = true
|
|
f.NewAccountNoisy = false
|
|
f.CallsMobile = false
|
|
f.BoardsFeatureFlags = ""
|
|
f.AddMembersToChannel = "top"
|
|
f.GuidedChannelCreation = false
|
|
f.ResendInviteEmailInterval = ""
|
|
f.InviteToTeam = "none"
|
|
f.CustomGroups = true
|
|
f.InlinePostEditing = false
|
|
f.BoardsDataRetention = false
|
|
f.NormalizeLdapDNs = false
|
|
f.UseCaseOnboarding = false
|
|
f.WorkspaceOptimizationDashboard = false
|
|
f.GraphQL = false
|
|
}
|
|
func (f *FeatureFlags) Plugins() map[string]string {
|
|
rFFVal := reflect.ValueOf(f).Elem()
|
|
rFFType := reflect.TypeOf(f).Elem()
|
|
|
|
pluginVersions := make(map[string]string)
|
|
for i := 0; i < rFFVal.NumField(); i++ {
|
|
rFieldVal := rFFVal.Field(i)
|
|
rFieldType := rFFType.Field(i)
|
|
|
|
pluginId, hasPluginId := rFieldType.Tag.Lookup("plugin_id")
|
|
if !hasPluginId {
|
|
continue
|
|
}
|
|
|
|
pluginVersions[pluginId] = rFieldVal.String()
|
|
}
|
|
|
|
return pluginVersions
|
|
}
|
|
|
|
// ToMap returns the feature flags as a map[string]string
|
|
// Supports boolean and string feature flags.
|
|
func (f *FeatureFlags) ToMap() map[string]string {
|
|
refStructVal := reflect.ValueOf(*f)
|
|
refStructType := reflect.TypeOf(*f)
|
|
ret := make(map[string]string)
|
|
for i := 0; i < refStructVal.NumField(); i++ {
|
|
refFieldVal := refStructVal.Field(i)
|
|
if !refFieldVal.IsValid() {
|
|
continue
|
|
}
|
|
refFieldType := refStructType.Field(i)
|
|
switch refFieldType.Type.Kind() {
|
|
case reflect.Bool:
|
|
ret[refFieldType.Name] = strconv.FormatBool(refFieldVal.Bool())
|
|
default:
|
|
ret[refFieldType.Name] = refFieldVal.String()
|
|
}
|
|
}
|
|
|
|
return ret
|
|
}
|