From 465582bbe5584dd8f8f4a463d06d6bc06caba0e7 Mon Sep 17 00:00:00 2001 From: Scott Lee Davis Date: Fri, 19 Apr 2019 08:47:39 -0700 Subject: [PATCH] siteURL error handling + remind list numbering correction --- plugin.json | 2 +- server/http.go | 1 - server/list.go | 18 ++++++++++++++++-- server/manifest.go | 2 +- server/reminder.go | 4 ++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/plugin.json b/plugin.json index 67ac0c5..3279998 100755 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "id": "com.github.scottleedavis.mattermost-plugin-remind", "name": "Remind Bot Mattermost Plugin", "description": "Sets Reminders", - "version": "0.1.3", + "version": "0.1.4", "server": { "executables": { "linux-amd64": "server/dist/plugin-linux-amd64", diff --git a/server/http.go b/server/http.go index 242f7e5..294d4ed 100755 --- a/server/http.go +++ b/server/http.go @@ -25,7 +25,6 @@ type Action struct { Context *ActionContext `json:"context"` } -// TODO use ephemeral posts when they are no longer not experimental func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) { var action *Action diff --git a/server/list.go b/server/list.go index aaf9a6d..76f21bb 100755 --- a/server/list.go +++ b/server/list.go @@ -247,13 +247,23 @@ func (p *Plugin) listControl( T, _ := p.translation(user) siteURL := fmt.Sprintf("%s", *p.ServerConfig.ServiceSettings.SiteURL) + if siteURL == "" { + p.API.LogError("SiteURL not set.") + return []*model.SlackAttachment{} + } reminderCount := map[string]interface{}{ "ReminderCount": RemindersPerPage, } + start := offset + 1 + stop := endOffset + 1 + if activeReminderCount == 0 { + start = 0 + stop = 0 + } remindersPageCount := map[string]interface{}{ - "Start": offset + 1, - "Stop": endOffset + 1, + "Start": start, + "Stop": stop, "Total": activeReminderCount, } @@ -374,6 +384,10 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder T, _ := p.translation(user) siteURL := fmt.Sprintf("%s", *p.ServerConfig.ServiceSettings.SiteURL) + if siteURL == "" { + p.API.LogError("SiteURL not set.") + return &model.SlackAttachment{} + } reminder := p.findReminder(reminders, occurrence) t := occurrence.Occurrence diff --git a/server/manifest.go b/server/manifest.go index fde7f4b..ec0e366 100755 --- a/server/manifest.go +++ b/server/manifest.go @@ -5,5 +5,5 @@ var manifest = struct { Version string }{ Id: "com.github.scottleedavis.mattermost-plugin-remind", - Version: "0.1.3", + Version: "0.1.4", } diff --git a/server/reminder.go b/server/reminder.go index eb6e406..70f214b 100755 --- a/server/reminder.go +++ b/server/reminder.go @@ -110,6 +110,10 @@ func (p *Plugin) TriggerReminders() { } siteURL := fmt.Sprintf("%s", *p.ServerConfig.ServiceSettings.SiteURL) + if siteURL == "" { + p.API.LogError("SiteURL not set.") + return + } interactivePost := model.Post{ ChannelId: channel.Id,