Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH104] Check when the error when cleaning a setting post is not found #105

Merged
merged 1 commit into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server/mscalendar/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ func (c *mscalendar) PrintSettings(userID string) {
}

func (c *mscalendar) ClearSettingsPosts(userID string) {
c.SettingsPanel.Clear(userID)
err := c.SettingsPanel.Clear(userID)
if err != nil {
c.Logger.Warnf("error clearing settings posts, " + err.Error())
}
}

func NewSettingsPanel(bot bot.Bot, panelStore settingspanel.PanelStore, settingStore settingspanel.SettingStore, settingsHandler, pluginURL string, getTimezone func(userID string) (string, error)) settingspanel.Panel {
Expand Down
9 changes: 7 additions & 2 deletions server/utils/settingspanel/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

"github.com/mattermost/mattermost-plugin-mscalendar/server/utils/bot"
"github.com/mattermost/mattermost-plugin-mscalendar/server/utils/kvstore"
"github.com/mattermost/mattermost-server/v5/model"
)

Expand Down Expand Up @@ -91,7 +92,7 @@ func (p *panel) URL() string {
func (p *panel) Print(userID string) {
err := p.cleanPreviousSettingsPosts(userID)
if err != nil {
p.logger.Errorf("could not clean previous setting post")
p.logger.Errorf("could not clean previous setting post, " + err.Error())
}

sas := []*model.SlackAttachment{}
Expand Down Expand Up @@ -136,13 +137,17 @@ func (p *panel) ToPost(userID string) (*model.Post, error) {

func (p *panel) cleanPreviousSettingsPosts(userID string) error {
postID, err := p.store.GetPanelPostID(userID)
if err == kvstore.ErrNotFound {
return nil
}

if err != nil {
return err
}

err = p.poster.DeletePost(postID)
if err != nil {
p.logger.Errorf("could not delete setting post")
p.logger.Errorf("could not delete setting post, %s", err)
}

err = p.store.DeletePanelPostID(userID)
Expand Down