Fixing joining of channels via permalinks for system admins. (#4409)

Этот коммит содержится в:
Christopher Speller
2016-11-01 13:23:26 -04:00
коммит произвёл GitHub
родитель b4002ba55f
Коммит 98131a293a

Просмотреть файл

@@ -1329,16 +1329,15 @@ func getPermalinkTmp(c *Context, w http.ResponseWriter, r *http.Request) {
} }
post := list.Posts[list.Order[0]] post := list.Posts[list.Order[0]]
if !HasPermissionToChannelContext(c, post.ChannelId, model.PERMISSION_READ_CHANNEL) { // Because we confuse permissions and membership in Mattermost's model, we have to just
// If we don't have permissions attempt to join the channel to fix the problem // try to join the channel without checking if we already have permission to it. This is
if err, _ := JoinChannelById(c, c.Session.UserId, post.ChannelId); err != nil { // because system admins have permissions to every channel but are not nessisary a member
// On error just return with permissions error // of every channel. If we checked here then system admins would skip joining the channel and
c.Err = err // error when they tried to view it.
return if err, _ := JoinChannelById(c, c.Session.UserId, post.ChannelId); err != nil {
} else { // On error just return with permissions error
// If we sucessfully joined the channel then clear the permissions error and continue c.Err = err
c.Err = nil return
}
} }
if HandleEtag(list.Etag(), w, r) { if HandleEtag(list.Etag(), w, r) {