Fix panics caused by race in notification code (#8652)
Этот коммит содержится в:
коммит произвёл
Elias Nahum
родитель
4921fda79f
Коммит
514033f14c
@@ -179,6 +179,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
|||||||
|
|
||||||
if a.Config().EmailSettings.SendEmailNotifications {
|
if a.Config().EmailSettings.SendEmailNotifications {
|
||||||
for _, id := range mentionedUsersList {
|
for _, id := range mentionedUsersList {
|
||||||
|
if profileMap[id] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
userAllowsEmails := profileMap[id].NotifyProps[model.EMAIL_NOTIFY_PROP] != "false"
|
userAllowsEmails := profileMap[id].NotifyProps[model.EMAIL_NOTIFY_PROP] != "false"
|
||||||
if channelEmail, ok := channelMemberNotifyPropsMap[id][model.EMAIL_NOTIFY_PROP]; ok {
|
if channelEmail, ok := channelMemberNotifyPropsMap[id][model.EMAIL_NOTIFY_PROP]; ok {
|
||||||
if channelEmail != model.CHANNEL_NOTIFY_DEFAULT {
|
if channelEmail != model.CHANNEL_NOTIFY_DEFAULT {
|
||||||
@@ -279,6 +283,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
|||||||
|
|
||||||
if sendPushNotifications {
|
if sendPushNotifications {
|
||||||
for _, id := range mentionedUsersList {
|
for _, id := range mentionedUsersList {
|
||||||
|
if profileMap[id] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
var status *model.Status
|
var status *model.Status
|
||||||
var err *model.AppError
|
var err *model.AppError
|
||||||
if status, err = a.GetStatus(id); err != nil {
|
if status, err = a.GetStatus(id); err != nil {
|
||||||
@@ -291,6 +299,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, id := range allActivityPushUserIds {
|
for _, id := range allActivityPushUserIds {
|
||||||
|
if profileMap[id] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := mentionedUserIds[id]; !ok {
|
if _, ok := mentionedUserIds[id]; !ok {
|
||||||
var status *model.Status
|
var status *model.Status
|
||||||
var err *model.AppError
|
var err *model.AppError
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ func TestSendNotifications(t *testing.T) {
|
|||||||
UserId: th.BasicUser.Id,
|
UserId: th.BasicUser.Id,
|
||||||
ChannelId: th.BasicChannel.Id,
|
ChannelId: th.BasicChannel.Id,
|
||||||
Message: "@" + th.BasicUser2.Username,
|
Message: "@" + th.BasicUser2.Username,
|
||||||
|
Type: model.POST_ADD_TO_CHANNEL,
|
||||||
|
Props: map[string]interface{}{model.POST_PROPS_ADDED_USER_ID: "junk"},
|
||||||
}, true)
|
}, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user