forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamargs.go
32 lines (27 loc) · 831 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/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
)
func getTeamsFromTeamArgs(a *app.App, teamArgs []string) []*model.Team {
teams := make([]*model.Team, 0, len(teamArgs))
for _, teamArg := range teamArgs {
team := getTeamFromTeamArg(a, teamArg)
teams = append(teams, team)
}
return teams
}
func getTeamFromTeamArg(a *app.App, teamArg string) *model.Team {
var team *model.Team
if result := <-a.Srv.Store.Team().GetByName(teamArg); result.Err == nil {
team = result.Data.(*model.Team)
}
if team == nil {
if result := <-a.Srv.Store.Team().Get(teamArg); result.Err == nil {
team = result.Data.(*model.Team)
}
}
return team
}