forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamargs.go
32 lines (27 loc) · 790 Bytes
/
teamargs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package main
import (
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
)
func getTeamsFromTeamArgs(teamArgs []string) []*model.Team {
teams := make([]*model.Team, 0, len(teamArgs))
for _, teamArg := range teamArgs {
team := getTeamFromTeamArg(teamArg)
teams = append(teams, team)
}
return teams
}
func getTeamFromTeamArg(teamArg string) *model.Team {
var team *model.Team
if result := <-app.Srv.Store.Team().GetByName(teamArg); result.Err == nil {
team = result.Data.(*model.Team)
}
if team == nil {
if result := <-app.Srv.Store.Team().Get(teamArg); result.Err == nil {
team = result.Data.(*model.Team)
}
}
return team
}