From 22f2245a26a0414f2c4c79d3852a94504d474714 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 9 Mar 2018 12:16:27 -0500 Subject: ICU-682 Stopped sending out of channel mention warnings for system messages (#8426) --- app/notification.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/notification.go b/app/notification.go index 8cb63fbaf..9a8096bbf 100644 --- a/app/notification.go +++ b/app/notification.go @@ -89,7 +89,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod delete(mentionedUserIds, post.UserId) } - if len(m.OtherPotentialMentions) > 0 { + if len(m.OtherPotentialMentions) > 0 && !post.IsSystemMessage() { if result := <-a.Srv.Store.User().GetProfilesByUsernames(m.OtherPotentialMentions, team.Id); result.Err == nil { outOfChannelMentions := result.Data.([]*model.User) if channel.Type != model.CHANNEL_GROUP { -- cgit v1.2.3-1-g7c22 From 4ae1238bc12537632289960f58e52d3c625d37e3 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 13 Mar 2018 10:32:24 -0400 Subject: Better error handling for failed plugin activation (#8361) --- app/plugin.go | 30 +++++++++++++++++++++--------- app/plugin_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/plugin.go b/app/plugin.go index fe671d26a..22d333679 100644 --- a/app/plugin.go +++ b/app/plugin.go @@ -91,18 +91,11 @@ func (a *App) ActivatePlugins() { active := a.PluginEnv.IsPluginActive(id) if pluginState.Enable && !active { - if err := a.PluginEnv.ActivatePlugin(id); err != nil { - l4g.Error(err.Error()) + if err := a.activatePlugin(plugin.Manifest); err != nil { + l4g.Error("%v plugin enabled in config.json but failing to activate err=%v", plugin.Manifest.Id, err.DetailedError) continue } - if plugin.Manifest.HasClient() { - message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_ACTIVATED, "", "", "", nil) - message.Add("manifest", plugin.Manifest.ClientManifest()) - a.Publish(message) - } - - l4g.Info("Activated %v plugin", id) } else if !pluginState.Enable && active { if err := a.deactivatePlugin(plugin.Manifest); err != nil { l4g.Error(err.Error()) @@ -111,6 +104,21 @@ func (a *App) ActivatePlugins() { } } +func (a *App) activatePlugin(manifest *model.Manifest) *model.AppError { + if err := a.PluginEnv.ActivatePlugin(manifest.Id); err != nil { + return model.NewAppError("activatePlugin", "app.plugin.activate.app_error", nil, err.Error(), http.StatusBadRequest) + } + + if manifest.HasClient() { + message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_ACTIVATED, "", "", "", nil) + message.Add("manifest", manifest.ClientManifest()) + a.Publish(message) + } + + l4g.Info("Activated %v plugin", manifest.Id) + return nil +} + func (a *App) deactivatePlugin(manifest *model.Manifest) *model.AppError { if err := a.PluginEnv.DeactivatePlugin(manifest.Id); err != nil { return model.NewAppError("removePlugin", "app.plugin.deactivate.app_error", nil, err.Error(), http.StatusBadRequest) @@ -301,6 +309,10 @@ func (a *App) EnablePlugin(id string) *model.AppError { return model.NewAppError("EnablePlugin", "app.plugin.not_installed.app_error", nil, "", http.StatusBadRequest) } + if err := a.activatePlugin(manifest); err != nil { + return err + } + a.UpdateConfig(func(cfg *model.Config) { cfg.PluginSettings.PluginStates[id] = &model.PluginState{Enable: true} }) diff --git a/app/plugin_test.go b/app/plugin_test.go index 4794d2704..9ad5dc1fa 100644 --- a/app/plugin_test.go +++ b/app/plugin_test.go @@ -4,8 +4,10 @@ package app import ( + "errors" "net/http" "net/http/httptest" + "strings" "testing" "github.com/gorilla/mux" @@ -195,3 +197,26 @@ func TestPluginCommands(t *testing.T) { require.NotNil(t, err) assert.Equal(t, http.StatusNotFound, err.StatusCode) } + +type pluginBadActivation struct { + testPlugin +} + +func (p *pluginBadActivation) OnActivate(api plugin.API) error { + return errors.New("won't activate for some reason") +} + +func TestPluginBadActivation(t *testing.T) { + th := Setup().InitBasic() + defer th.TearDown() + + th.InstallPlugin(&model.Manifest{ + Id: "foo", + }, &pluginBadActivation{}) + + t.Run("EnablePlugin bad activation", func(t *testing.T) { + err := th.App.EnablePlugin("foo") + assert.NotNil(t, err) + assert.True(t, strings.Contains(err.DetailedError, "won't activate for some reason")) + }) +} -- cgit v1.2.3-1-g7c22 From caf9c2409935124db85daf5b04d61b7a663ebfc8 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 13 Mar 2018 11:03:12 -0500 Subject: MM-9688: Better error message for plugin enabling in HA mode (#8433) * better error message for plugin enabling in HA mode * wording update --- app/plugin.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/plugin.go b/app/plugin.go index 22d333679..6702e9227 100644 --- a/app/plugin.go +++ b/app/plugin.go @@ -318,6 +318,9 @@ func (a *App) EnablePlugin(id string) *model.AppError { }) if err := a.SaveConfig(a.Config(), true); err != nil { + if err.Id == "ent.cluster.save_config.error" { + return model.NewAppError("EnablePlugin", "app.plugin.cluster.save_config.app_error", nil, "", http.StatusInternalServerError) + } return model.NewAppError("EnablePlugin", "app.plugin.config.app_error", nil, err.Error(), http.StatusInternalServerError) } -- cgit v1.2.3-1-g7c22 From bf2038bc41b81d56e15e712f1e6c2bf6c7dd917d Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Thu, 15 Mar 2018 15:42:49 +0100 Subject: [MM-9703] Push notifications are sent for own DM's (#8439) update --- app/notification.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/notification.go b/app/notification.go index 9a8096bbf..bb0c8703f 100644 --- a/app/notification.go +++ b/app/notification.go @@ -55,10 +55,15 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod if channel.Type == model.CHANNEL_DIRECT { var otherUserId string - if userIds := strings.Split(channel.Name, "__"); userIds[0] == post.UserId { - otherUserId = userIds[1] - } else { - otherUserId = userIds[0] + + userIds := strings.Split(channel.Name, "__") + + if userIds[0] != userIds[1] { + if userIds[0] == post.UserId { + otherUserId = userIds[1] + } else { + otherUserId = userIds[0] + } } if _, ok := profileMap[otherUserId]; ok { -- cgit v1.2.3-1-g7c22