Fix shadowed variables in app package: Part 2 of 3 (#10001)

Follow up on #10000
Этот коммит содержится в:
Hanzei
2019-01-25 17:33:21 +01:00
коммит произвёл GitHub
родитель 9168482623
Коммит 954112102e
4 изменённых файлов: 21 добавлений и 18 удалений

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

@@ -62,7 +62,8 @@ func (me *HeaderProvider) DoCommand(a *App, args *model.CommandArgs, message str
case model.CHANNEL_GROUP, model.CHANNEL_DIRECT:
// Modifying the header is not linked to any specific permission for group/dm channels, so just check for membership.
channelMember, err := a.GetChannelMember(args.ChannelId, args.Session.UserId)
var channelMember *model.ChannelMember
channelMember, err = a.GetChannelMember(args.ChannelId, args.Session.UserId)
if err != nil || channelMember == nil {
return &model.CommandResponse{
Text: args.T("api.command_channel_header.permission.app_error"),

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

@@ -5,7 +5,6 @@ package app
import (
"encoding/json"
"errors"
"io"
"net/http"
"os"
@@ -13,6 +12,7 @@ import (
"strings"
"github.com/mattermost/mattermost-server/model"
"github.com/pkg/errors"
)
func (a *App) BulkExport(writer io.Writer, file string, pathToEmojiDir string, dirNameToExportEmoji string) *model.AppError {
@@ -404,8 +404,6 @@ func (a *App) createDirForEmoji(file string, dirName string) string {
// Copies emoji files from 'data/emoji' dir to 'exported_emoji' dir
func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir string) error {
var err error
fromPath, err := os.Open(emojiImagePath)
if fromPath == nil || err != nil {
return errors.New("Error reading " + emojiImagePath + "file")
@@ -414,12 +412,16 @@ func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir s
emojiDir := pathToDir + "/" + emojiId
if _, err := os.Stat(emojiDir); os.IsNotExist(err) {
os.Mkdir(emojiDir, os.ModePerm)
}
if err != nil {
return errors.New("Error creating directory for the emoji " + err.Error())
if _, err = os.Stat(emojiDir); err != nil {
if !os.IsNotExist(err) {
return errors.Wrapf(err, "Error fetching file info of emoji directory %v", emojiDir)
}
if err = os.Mkdir(emojiDir, os.ModePerm); err != nil {
return errors.Wrapf(err, "Error creating emoji directory %v", emojiDir)
}
}
toPath, err := os.OpenFile(emojiDir+"/image", os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
return errors.New("Error creating the image file " + err.Error())

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

@@ -45,8 +45,7 @@ func (a *App) AuthenticateUserForLogin(id, loginId, password, mfaToken string, l
}()
if len(password) == 0 {
err := model.NewAppError("AuthenticateUserForLogin", "api.user.login.blank_pwd.app_error", nil, "", http.StatusBadRequest)
return nil, err
return nil, model.NewAppError("AuthenticateUserForLogin", "api.user.login.blank_pwd.app_error", nil, "", http.StatusBadRequest)
}
// Get the MM user we are trying to login

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

@@ -317,13 +317,14 @@ func ShouldSendPushNotification(user *model.User, channelNotifyProps model.Strin
func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps model.StringMap, post *model.Post, wasMentioned bool) bool {
userNotifyProps := user.NotifyProps
userNotify := userNotifyProps[model.PUSH_NOTIFY_PROP]
channelNotify, ok := channelNotifyProps[model.PUSH_NOTIFY_PROP]
channelNotify, _ := channelNotifyProps[model.PUSH_NOTIFY_PROP]
if channelNotify == "" {
channelNotify = model.CHANNEL_NOTIFY_DEFAULT
}
// If the channel is muted do not send push notifications
if channelMuted, ok := channelNotifyProps[model.MARK_UNREAD_NOTIFY_PROP]; ok {
if channelMuted == model.CHANNEL_MARK_UNREAD_MENTION {
return false
}
if channelNotifyProps[model.MARK_UNREAD_NOTIFY_PROP] == model.CHANNEL_MARK_UNREAD_MENTION {
return false
}
if post.IsSystemMessage() {
@@ -338,7 +339,7 @@ func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps m
return false
}
if userNotify == model.USER_NOTIFY_MENTION && (!ok || channelNotify == model.CHANNEL_NOTIFY_DEFAULT) && !wasMentioned {
if userNotify == model.USER_NOTIFY_MENTION && channelNotify == model.CHANNEL_NOTIFY_DEFAULT && !wasMentioned {
return false
}
@@ -348,7 +349,7 @@ func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps m
}
if userNotify == model.USER_NOTIFY_NONE &&
(!ok || channelNotify == model.CHANNEL_NOTIFY_DEFAULT) {
channelNotify == model.CHANNEL_NOTIFY_DEFAULT {
return false
}