summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-05-02 12:57:32 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-05-02 12:57:32 -0400
commitf8ed606a5ff4e1c4bc71514b5604de0cbaa09feb (patch)
tree906bdb6743d781e6e3ce3506e9f9bc9c76e91067 /api/channel.go
parent6f1489b7882db6d95a05e43294d0107435974eba (diff)
downloadchat-f8ed606a5ff4e1c4bc71514b5604de0cbaa09feb.tar.gz
chat-f8ed606a5ff4e1c4bc71514b5604de0cbaa09feb.tar.bz2
chat-f8ed606a5ff4e1c4bc71514b5604de0cbaa09feb.zip
Fixing edit direct channel header (#2842)
Diffstat (limited to 'api/channel.go')
-rw-r--r--api/channel.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/api/channel.go b/api/channel.go
index 5f0d03246..b034e94ba 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -113,7 +113,7 @@ func createDirectChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if sc, err := CreateDirectChannel(c, userId); err != nil {
+ if sc, err := CreateDirectChannel(c.Session.UserId, userId); err != nil {
c.Err = err
return
} else {
@@ -121,19 +121,14 @@ func createDirectChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
-func CreateDirectChannel(c *Context, otherUserId string) (*model.Channel, *model.AppError) {
- if len(otherUserId) != 26 {
- return nil, model.NewLocAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, otherUserId)
- }
-
+func CreateDirectChannel(userId string, otherUserId string) (*model.Channel, *model.AppError) {
uc := Srv.Store.User().Get(otherUserId)
channel := new(model.Channel)
channel.DisplayName = ""
- channel.Name = model.GetDMNameFromIds(otherUserId, c.Session.UserId)
+ channel.Name = model.GetDMNameFromIds(otherUserId, userId)
- channel.TeamId = c.TeamId
channel.Header = ""
channel.Type = model.CHANNEL_DIRECT
@@ -142,13 +137,11 @@ func CreateDirectChannel(c *Context, otherUserId string) (*model.Channel, *model
}
cm1 := &model.ChannelMember{
- UserId: c.Session.UserId,
- Roles: model.CHANNEL_ROLE_ADMIN,
+ UserId: userId,
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
cm2 := &model.ChannelMember{
UserId: otherUserId,
- Roles: "",
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
@@ -274,7 +267,7 @@ func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
channel := cresult.Data.(*model.Channel)
// Don't need to do anything channel member, just wanted to confirm it exists
- if !c.HasPermissionsToTeam(channel.TeamId, "updateChannelHeader") {
+ if channel.TeamId != "" && !c.HasPermissionsToTeam(channel.TeamId, "updateChannelHeader") {
return
}
oldChannelHeader := channel.Header