From 97558f6a6ec4c53fa69035fb430ead209d9c222d Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 13 Jan 2017 13:53:37 -0500 Subject: PLT-4938 Add app package and move logic over from api package (#4931) * Add app package and move logic over from api package * Change app package functions to return errors * Move non-api tests into app package * Fix merge --- cmd/platform/channel.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'cmd/platform/channel.go') diff --git a/cmd/platform/channel.go b/cmd/platform/channel.go index cf5ef61bc..2a10516af 100644 --- a/cmd/platform/channel.go +++ b/cmd/platform/channel.go @@ -6,6 +6,7 @@ import ( "errors" "github.com/mattermost/platform/api" + "github.com/mattermost/platform/app" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" "github.com/spf13/cobra" @@ -117,6 +118,8 @@ func createChannelCmdF(cmd *cobra.Command, args []string) error { team := getTeamFromTeamArg(teamArg) + c := getMockContext() + channel := &model.Channel{ TeamId: team.Id, Name: name, @@ -124,10 +127,10 @@ func createChannelCmdF(cmd *cobra.Command, args []string) error { Header: header, Purpose: purpose, Type: channelType, + CreatorId: c.Session.UserId, } - c := getMockContext() - if _, err := api.CreateChannel(c, channel, false); err != nil { + if _, err := app.CreateChannel(channel, false); err != nil { return err } @@ -197,7 +200,7 @@ func addUserToChannel(channel *model.Channel, user *model.User, userArg string) CommandPrintErrorln("Can't find user '" + userArg + "'") return } - if _, err := api.AddUserToChannel(user, channel); err != nil { + if _, err := app.AddUserToChannel(user, channel); err != nil { CommandPrintErrorln("Unable to add '" + userArg + "' from " + channel.Name + ". Error: " + err.Error()) } } @@ -215,7 +218,7 @@ func deleteChannelsCmdF(cmd *cobra.Command, args []string) error { CommandPrintErrorln("Unable to find channel '" + args[i] + "'") continue } - if result := <-api.Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); result.Err != nil { + if result := <-app.Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); result.Err != nil { CommandPrintErrorln("Unable to delete channel '" + channel.Name + "' error: " + result.Err.Error()) } } @@ -240,7 +243,7 @@ func listChannelsCmdF(cmd *cobra.Command, args []string) error { CommandPrintErrorln("Unable to find team '" + args[i] + "'") continue } - if result := <-api.Srv.Store.Channel().GetAll(team.Id); result.Err != nil { + if result := <-app.Srv.Store.Channel().GetAll(team.Id); result.Err != nil { CommandPrintErrorln("Unable to list channels for '" + args[i] + "'") } else { channels := result.Data.([]*model.Channel) @@ -275,7 +278,7 @@ func restoreChannelsCmdF(cmd *cobra.Command, args []string) error { CommandPrintErrorln("Unable to find channel '" + args[i] + "'") continue } - if result := <-api.Srv.Store.Channel().SetDeleteAt(channel.Id, 0, model.GetMillis()); result.Err != nil { + if result := <-app.Srv.Store.Channel().SetDeleteAt(channel.Id, 0, model.GetMillis()); result.Err != nil { CommandPrintErrorln("Unable to restore channel '" + args[i] + "'") } } -- cgit v1.2.3-1-g7c22