Fix shadowed variables in app package: Part 2 of 3 (#10001)
Follow up on #10000
Этот коммит содержится в:
@@ -62,7 +62,8 @@ func (me *HeaderProvider) DoCommand(a *App, args *model.CommandArgs, message str
|
|||||||
|
|
||||||
case model.CHANNEL_GROUP, model.CHANNEL_DIRECT:
|
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.
|
// 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 {
|
if err != nil || channelMember == nil {
|
||||||
return &model.CommandResponse{
|
return &model.CommandResponse{
|
||||||
Text: args.T("api.command_channel_header.permission.app_error"),
|
Text: args.T("api.command_channel_header.permission.app_error"),
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -13,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"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 {
|
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
|
// Copies emoji files from 'data/emoji' dir to 'exported_emoji' dir
|
||||||
func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir string) error {
|
func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir string) error {
|
||||||
var err error
|
|
||||||
|
|
||||||
fromPath, err := os.Open(emojiImagePath)
|
fromPath, err := os.Open(emojiImagePath)
|
||||||
if fromPath == nil || err != nil {
|
if fromPath == nil || err != nil {
|
||||||
return errors.New("Error reading " + emojiImagePath + "file")
|
return errors.New("Error reading " + emojiImagePath + "file")
|
||||||
@@ -414,12 +412,16 @@ func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir s
|
|||||||
|
|
||||||
emojiDir := pathToDir + "/" + emojiId
|
emojiDir := pathToDir + "/" + emojiId
|
||||||
|
|
||||||
if _, err := os.Stat(emojiDir); os.IsNotExist(err) {
|
if _, err = os.Stat(emojiDir); err != nil {
|
||||||
os.Mkdir(emojiDir, os.ModePerm)
|
if !os.IsNotExist(err) {
|
||||||
|
return errors.Wrapf(err, "Error fetching file info of emoji directory %v", emojiDir)
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return errors.New("Error creating directory for the emoji " + err.Error())
|
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)
|
toPath, err := os.OpenFile(emojiDir+"/image", os.O_RDWR|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Error creating the image file " + err.Error())
|
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 {
|
if len(password) == 0 {
|
||||||
err := model.NewAppError("AuthenticateUserForLogin", "api.user.login.blank_pwd.app_error", nil, "", http.StatusBadRequest)
|
return nil, model.NewAppError("AuthenticateUserForLogin", "api.user.login.blank_pwd.app_error", nil, "", http.StatusBadRequest)
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the MM user we are trying to login
|
// Get the MM user we are trying to login
|
||||||
|
|||||||
@@ -317,14 +317,15 @@ func ShouldSendPushNotification(user *model.User, channelNotifyProps model.Strin
|
|||||||
func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps model.StringMap, post *model.Post, wasMentioned bool) bool {
|
func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps model.StringMap, post *model.Post, wasMentioned bool) bool {
|
||||||
userNotifyProps := user.NotifyProps
|
userNotifyProps := user.NotifyProps
|
||||||
userNotify := userNotifyProps[model.PUSH_NOTIFY_PROP]
|
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 the channel is muted do not send push notifications
|
||||||
if channelMuted, ok := channelNotifyProps[model.MARK_UNREAD_NOTIFY_PROP]; ok {
|
if channelNotifyProps[model.MARK_UNREAD_NOTIFY_PROP] == model.CHANNEL_MARK_UNREAD_MENTION {
|
||||||
if channelMuted == model.CHANNEL_MARK_UNREAD_MENTION {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if post.IsSystemMessage() {
|
if post.IsSystemMessage() {
|
||||||
return false
|
return false
|
||||||
@@ -338,7 +339,7 @@ func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps m
|
|||||||
return false
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +349,7 @@ func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps m
|
|||||||
}
|
}
|
||||||
|
|
||||||
if userNotify == model.USER_NOTIFY_NONE &&
|
if userNotify == model.USER_NOTIFY_NONE &&
|
||||||
(!ok || channelNotify == model.CHANNEL_NOTIFY_DEFAULT) {
|
channelNotify == model.CHANNEL_NOTIFY_DEFAULT {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user