MM-54123 Add group to channel (#22954)
* adding group members to channel initial commit * adding group to channel functionality along with add new team members * fixing circular dependency * fixing e2e and other optimizations * adding e2e tests for adding group members to channels * cypress lint * fixing comments * adding count to button * improvements * adjusting some stuff from PR comments * remove ability to add user to team, update message for non-team members * remove adding to team from add groups functionality * update misspelled variable * lint and unit test fixes * add tests, cleanup * lint fix * revert package-lock.json * fixes for cypress tests * rename TeamInviteBanner to TeamWarningBanner, since invites are no longer allowed * update for warning * lint fixes * cleanup * fix failing e2e tests * update messages to not use markdown --------- Co-authored-by: Scott Bishel <scott.bishel@mattermost.com> Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -117,6 +117,7 @@ func getGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
group, appErr := c.App.GetGroup(c.Params.GroupId, &model.GetGroupOpts{
|
||||
IncludeMemberCount: c.Params.IncludeMemberCount,
|
||||
IncludeMemberIDs: c.Params.IncludeMemberIDs,
|
||||
}, restrictions)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
@@ -998,6 +999,7 @@ func getGroups(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
Source: source,
|
||||
FilterHasMember: c.Params.FilterHasMember,
|
||||
IncludeTimezones: includeTimezones,
|
||||
IncludeMemberIDs: c.Params.IncludeMemberIDs,
|
||||
IncludeArchived: includeArchived,
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,17 @@ func (a *App) GetGroup(id string, opts *model.GetGroupOpts, viewRestrictions *mo
|
||||
}
|
||||
}
|
||||
|
||||
if opts != nil && opts.IncludeMemberIDs {
|
||||
users, err := a.Srv().Store().Group().GetMemberUsers(id)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetGroup", "app.member_count", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
group.MemberIDs = append(group.MemberIDs, user.Id)
|
||||
}
|
||||
}
|
||||
|
||||
if opts != nil && opts.IncludeMemberCount {
|
||||
memberCount, err := a.Srv().Store().Group().GetMemberCountWithRestrictions(id, viewRestrictions)
|
||||
if err != nil {
|
||||
@@ -636,6 +647,19 @@ func (a *App) GetGroups(page, perPage int, opts model.GroupSearchOpts, viewRestr
|
||||
return nil, model.NewAppError("GetGroups", "app.select_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if opts.IncludeMemberIDs {
|
||||
for _, group := range groups {
|
||||
users, err := a.Srv().Store().Group().GetMemberUsers(group.Id)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetGroup", "app.member_count", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
group.MemberIDs = append(group.MemberIDs, user.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return groups, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ type Params struct {
|
||||
NotAssociatedToChannel string
|
||||
Paginate *bool
|
||||
IncludeMemberCount bool
|
||||
IncludeMemberIDs bool
|
||||
NotAssociatedToGroup string
|
||||
ExcludeDefaultChannels bool
|
||||
LimitAfter int
|
||||
@@ -218,6 +219,7 @@ func ParamsFromRequest(r *http.Request) *Params {
|
||||
}
|
||||
|
||||
params.IncludeMemberCount, _ = strconv.ParseBool(query.Get("include_member_count"))
|
||||
params.IncludeMemberIDs, _ = strconv.ParseBool(query.Get("include_member_ids"))
|
||||
params.NotAssociatedToGroup = query.Get("not_associated_to_group")
|
||||
params.ExcludeDefaultChannels, _ = strconv.ParseBool(query.Get("exclude_default_channels"))
|
||||
params.GroupIDs = query.Get("group_ids")
|
||||
|
||||
Ссылка в новой задаче
Block a user