summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/channel.go')
-rw-r--r--app/channel.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/channel.go b/app/channel.go
index 6e11d4e5d..40f21c3a9 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -652,8 +652,10 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
}
var userRequestor *model.User
- if userRequestor, err = a.GetUser(userRequestorId); err != nil {
- return nil, err
+ if userRequestorId != "" {
+ if userRequestor, err = a.GetUser(userRequestorId); err != nil {
+ return nil, err
+ }
}
cm, err := a.AddUserToChannel(user, channel)
@@ -661,7 +663,7 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
return nil, err
}
- if userId == userRequestorId {
+ if userRequestorId == "" || userId == userRequestorId {
a.postJoinChannelMessage(user, channel)
} else {
a.Go(func() {
@@ -669,7 +671,9 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
})
}
- a.UpdateChannelLastViewedAt([]string{channel.Id}, userRequestor.Id)
+ if userRequestor != nil {
+ a.UpdateChannelLastViewedAt([]string{channel.Id}, userRequestor.Id)
+ }
return cm, nil
}