summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-01-19 09:00:13 -0500
committerGitHub <noreply@github.com>2017-01-19 09:00:13 -0500
commitd3a285e64d051aa8d5c4c9854597dfbcce107675 (patch)
treee16ca3d52b6347a754e506aa8cac7457c62d3639 /cmd
parent61b7226533568f3261fc233538ce998bb71a5345 (diff)
downloadchat-d3a285e64d051aa8d5c4c9854597dfbcce107675.tar.gz
chat-d3a285e64d051aa8d5c4c9854597dfbcce107675.tar.bz2
chat-d3a285e64d051aa8d5c4c9854597dfbcce107675.zip
Migrate functions to app package (#5106)
* Refactor and move session logic into app package * Refactor email functions into the app package * Refactor password update into app package * Migrate user functions to app package * Move team functions into app package * Migrate channel functions into app package * Pass SiteURL through to app functions * Update based on feedback
Diffstat (limited to 'cmd')
-rw-r--r--cmd/platform/channel.go3
-rw-r--r--cmd/platform/oldcommands.go17
-rw-r--r--cmd/platform/roles.go6
-rw-r--r--cmd/platform/team.go5
-rw-r--r--cmd/platform/user.go11
5 files changed, 19 insertions, 23 deletions
diff --git a/cmd/platform/channel.go b/cmd/platform/channel.go
index 2a10516af..fd2b097af 100644
--- a/cmd/platform/channel.go
+++ b/cmd/platform/channel.go
@@ -5,7 +5,6 @@ package main
import (
"errors"
- "github.com/mattermost/platform/api"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
@@ -166,7 +165,7 @@ func removeUserFromChannel(channel *model.Channel, user *model.User, userArg str
CommandPrintErrorln("Can't find user '" + userArg + "'")
return
}
- if err := api.RemoveUserFromChannel(user.Id, "", channel); err != nil {
+ if err := app.RemoveUserFromChannel(user.Id, "", channel); err != nil {
CommandPrintErrorln("Unable to remove '" + userArg + "' from " + channel.Name + ". Error: " + err.Error())
}
}
diff --git a/cmd/platform/oldcommands.go b/cmd/platform/oldcommands.go
index faf086cb7..1ff65130c 100644
--- a/cmd/platform/oldcommands.go
+++ b/cmd/platform/oldcommands.go
@@ -319,8 +319,7 @@ func cmdInviteUser() {
}
invites := []string{flagEmail}
- c := getMockContext()
- api.InviteMembers(team, user.GetDisplayName(), invites, c.GetSiteURL())
+ app.SendInviteEmails(team, user.GetDisplayName(), invites, *utils.Cfg.ServiceSettings.SiteURL)
os.Exit(0)
}
@@ -369,7 +368,7 @@ func cmdAssignRole() {
}
if !user.IsInRole(flagRole) {
- api.UpdateUserRoles(user, flagRole)
+ app.UpdateUserRoles(user.Id, flagRole)
}
os.Exit(0)
@@ -547,7 +546,7 @@ func cmdLeaveChannel() {
channel = result.Data.(*model.Channel)
}
- err := api.RemoveUserFromChannel(user.Id, user.Id, channel)
+ err := app.RemoveUserFromChannel(user.Id, user.Id, channel)
if err != nil {
l4g.Error("%v", err)
flushLogAndExit(1)
@@ -712,7 +711,7 @@ func cmdLeaveTeam() {
user = result.Data.(*model.User)
}
- err := api.LeaveTeam(team, user)
+ err := app.LeaveTeam(team, user)
if err != nil {
l4g.Error("%v", err)
@@ -823,7 +822,7 @@ func cmdPermDeleteUser() {
flushLogAndExit(1)
}
- if err := api.PermanentDeleteUser(user); err != nil {
+ if err := app.PermanentDeleteUser(user); err != nil {
l4g.Error("%v", err)
flushLogAndExit(1)
} else {
@@ -866,7 +865,7 @@ func cmdPermDeleteTeam() {
flushLogAndExit(1)
}
- if err := api.PermanentDeleteTeam(team); err != nil {
+ if err := app.PermanentDeleteTeam(team); err != nil {
l4g.Error("%v", err)
flushLogAndExit(1)
} else {
@@ -896,7 +895,7 @@ func cmdPermDeleteAllUsers() {
flushLogAndExit(1)
}
- if err := api.PermanentDeleteAllUsers(); err != nil {
+ if err := app.PermanentDeleteAllUsers(); err != nil {
l4g.Error("%v", err)
flushLogAndExit(1)
} else {
@@ -1033,7 +1032,7 @@ func cmdActivateUser() {
l4g.Error("%v", utils.T("api.user.update_active.no_deactivate_ldap.app_error"))
}
- if _, err := api.UpdateActive(user, !flagUserSetInactive); err != nil {
+ if _, err := app.UpdateActive(user, !flagUserSetInactive); err != nil {
l4g.Error("%v", err)
}
diff --git a/cmd/platform/roles.go b/cmd/platform/roles.go
index 7b635c5a3..a65eb2bd6 100644
--- a/cmd/platform/roles.go
+++ b/cmd/platform/roles.go
@@ -5,7 +5,7 @@ package main
import (
"errors"
- "github.com/mattermost/platform/api"
+ "github.com/mattermost/platform/app"
"github.com/spf13/cobra"
)
@@ -49,7 +49,7 @@ func makeSystemAdminCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Unable to find user '" + args[i] + "'")
}
- if _, err := api.UpdateUserRoles(user, "system_admin system_user"); err != nil {
+ if _, err := app.UpdateUserRoles(user.Id, "system_admin system_user"); err != nil {
return err
}
}
@@ -69,7 +69,7 @@ func makeMemberCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Unable to find user '" + args[i] + "'")
}
- if _, err := api.UpdateUserRoles(user, "system_user"); err != nil {
+ if _, err := app.UpdateUserRoles(user.Id, "system_user"); err != nil {
return err
}
}
diff --git a/cmd/platform/team.go b/cmd/platform/team.go
index 43d0b2582..1dc5d46eb 100644
--- a/cmd/platform/team.go
+++ b/cmd/platform/team.go
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
- "github.com/mattermost/platform/api"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/spf13/cobra"
@@ -125,7 +124,7 @@ func removeUserFromTeam(team *model.Team, user *model.User, userArg string) {
CommandPrintErrorln("Can't find user '" + userArg + "'")
return
}
- if err := api.LeaveTeam(team, user); err != nil {
+ if err := app.LeaveTeam(team, user); err != nil {
CommandPrintErrorln("Unable to remove '" + userArg + "' from " + team.Name + ". Error: " + err.Error())
}
}
@@ -200,5 +199,5 @@ func deleteTeamsCmdF(cmd *cobra.Command, args []string) error {
}
func deleteTeam(team *model.Team) *model.AppError {
- return api.PermanentDeleteTeam(team)
+ return app.PermanentDeleteTeam(team)
}
diff --git a/cmd/platform/user.go b/cmd/platform/user.go
index 4fa4cd36e..fa93e418c 100644
--- a/cmd/platform/user.go
+++ b/cmd/platform/user.go
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
- "github.com/mattermost/platform/api"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
@@ -175,7 +174,7 @@ func changeUserActiveStatus(user *model.User, userArg string, activate bool) {
CommandPrintErrorln(utils.T("api.user.update_active.no_deactivate_ldap.app_error"))
return
}
- if _, err := api.UpdateActive(user, activate); err != nil {
+ if _, err := app.UpdateActive(user, activate); err != nil {
CommandPrintErrorln("Unable to change activation status of user: " + userArg)
}
}
@@ -227,7 +226,7 @@ func userCreateCmdF(cmd *cobra.Command, args []string) error {
}
if system_admin {
- api.UpdateUserRoles(ruser, "system_user system_admin")
+ app.UpdateUserRoles(ruser.Id, "system_user system_admin")
}
CommandPrettyPrintln("Created User")
@@ -262,7 +261,7 @@ func inviteUser(email string, team *model.Team, teamArg string) {
CommandPrintErrorln("Can't find team '" + teamArg + "'")
return
}
- api.InviteMembers(team, "Administrator", invites, *utils.Cfg.ServiceSettings.SiteURL)
+ app.SendInviteEmails(team, "Administrator", invites, *utils.Cfg.ServiceSettings.SiteURL)
CommandPrettyPrintln("Invites may or may not have been sent.")
}
@@ -335,7 +334,7 @@ func deleteUserCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Unable to find user '" + args[i] + "'")
}
- if err := api.PermanentDeleteUser(user); err != nil {
+ if err := app.PermanentDeleteUser(user); err != nil {
return err
}
}
@@ -365,7 +364,7 @@ func deleteAllUsersCommandF(cmd *cobra.Command, args []string) error {
}
}
- if err := api.PermanentDeleteAllUsers(); err != nil {
+ if err := app.PermanentDeleteAllUsers(); err != nil {
return err
} else {
CommandPrettyPrintln("Sucsessfull. All users deleted.")