From 0f20849b6a7b0766eebc6a7f6bfad91d4f6159a5 Mon Sep 17 00:00:00 2001 From: Scott Lee Davis Date: Sat, 4 May 2019 21:10:29 -0700 Subject: [PATCH] clarified URL name vs. siteURL --- server/activate.go | 2 +- server/http.go | 4 ++-- server/list.go | 38 +++++++++++++++++++------------------- server/plugin.go | 2 +- server/reminder.go | 12 ++++++------ server/scheduler.go | 6 +++--- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/server/activate.go b/server/activate.go index e82b66d..b47974c 100755 --- a/server/activate.go +++ b/server/activate.go @@ -54,7 +54,7 @@ func (p *Plugin) OnActivate() error { p.emptyTime = time.Time{}.AddDate(1, 1, 1) p.supportedLocales = []string{"en"} p.ServerConfig = p.API.GetConfig() - p.siteURL = "http://127.0.0.1" + fmt.Sprintf("%s", *p.ServerConfig.ServiceSettings.ListenAddress) + p.URL = "http://127.0.0.1" + fmt.Sprintf("%s", *p.ServerConfig.ServiceSettings.ListenAddress) p.Run() diff --git a/server/http.go b/server/http.go index 9a6421b..7424a46 100755 --- a/server/http.go +++ b/server/http.go @@ -143,7 +143,7 @@ func (p *Plugin) handleDialog(w http.ResponseWriter, req *http.Request) { "occurrence_id": r.Reminder.Occurrences[0].Id, "action": "delete/ephemeral", }, - URL: fmt.Sprintf("%s/plugins/%s/delete/ephemeral", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete/ephemeral", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.delete"), @@ -156,7 +156,7 @@ func (p *Plugin) handleDialog(w http.ResponseWriter, req *http.Request) { "occurrence_id": r.Reminder.Occurrences[0].Id, "action": "view/ephemeral", }, - URL: fmt.Sprintf("%s/plugins/%s/view/ephemeral", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/view/ephemeral", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.view.reminders"), diff --git a/server/list.go b/server/list.go index 41496ac..9a75828 100755 --- a/server/list.go +++ b/server/list.go @@ -247,8 +247,8 @@ func (p *Plugin) listControl( T, _ := p.translation(user) - if p.siteURL == "" { - p.API.LogError("SiteURL not set.") + if p.URL == "" { + p.API.LogError("URL not set.") return []*model.SlackAttachment{} } reminderCount := map[string]interface{}{ @@ -280,7 +280,7 @@ func (p *Plugin) listControl( "action": "next/reminders", "offset": endOffset + 1, }, - URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.next.reminders", reminderCount), @@ -295,7 +295,7 @@ func (p *Plugin) listControl( "action": "previous/reminders", "offset": offset - RemindersPerPage, }, - URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.previous.reminders", reminderCount), @@ -310,7 +310,7 @@ func (p *Plugin) listControl( "action": "previous/reminders", "offset": offset - RemindersPerPage, }, - URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.previous.reminders", reminderCount), @@ -322,7 +322,7 @@ func (p *Plugin) listControl( "action": "next/reminders", "offset": endOffset + 1, }, - URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/next/reminders", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.next.reminders", reminderCount), @@ -340,7 +340,7 @@ func (p *Plugin) listControl( Context: model.StringInterface{ "action": "view/complete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/view/complete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/view/complete/list", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.view.complete"), @@ -352,7 +352,7 @@ func (p *Plugin) listControl( Context: model.StringInterface{ "action": "delete/complete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/delete/complete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete/complete/list", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.delete.complete"), @@ -366,7 +366,7 @@ func (p *Plugin) listControl( Context: model.StringInterface{ "action": "close/list", }, - URL: fmt.Sprintf("%s/plugins/%s/close/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/close/list", p.URL, manifest.Id), }, Name: T("button.close.list"), Type: "action", @@ -383,8 +383,8 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder location := p.location(user) T, _ := p.translation(user) - if p.siteURL == "" { - p.API.LogError("SiteURL not set.") + if p.URL == "" { + p.API.LogError("URL not set.") return &model.SlackAttachment{} } reminder := p.findReminder(reminders, occurrence) @@ -424,7 +424,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "complete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/complete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/complete/list", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.complete"), @@ -436,7 +436,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "delete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.URL, manifest.Id), }, Name: T("button.delete"), Type: model.POST_ACTION_TYPE_BUTTON, @@ -460,7 +460,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "delete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.URL, manifest.Id), }, Name: T("button.delete"), Type: model.POST_ACTION_TYPE_BUTTON, @@ -484,7 +484,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "complete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/complete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/complete/list", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.complete"), @@ -496,7 +496,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "delete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.URL, manifest.Id), }, Name: T("button.delete"), Type: model.POST_ACTION_TYPE_BUTTON, @@ -508,7 +508,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "snooze/list", }, - URL: fmt.Sprintf("%s/plugins/%s/snooze/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/snooze/list", p.URL, manifest.Id), }, Name: T("button.snooze"), Type: "select", @@ -554,7 +554,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "complete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/complete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/complete/list", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.complete"), @@ -566,7 +566,7 @@ func (p *Plugin) addAttachment(user *model.User, occurrence Occurrence, reminder "occurrence_id": occurrence.Id, "action": "delete/list", }, - URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete/list", p.URL, manifest.Id), }, Name: T("button.delete"), Type: model.POST_ACTION_TYPE_BUTTON, diff --git a/server/plugin.go b/server/plugin.go index 3830e3a..37d991b 100755 --- a/server/plugin.go +++ b/server/plugin.go @@ -16,7 +16,7 @@ type Plugin struct { ServerConfig *model.Config - siteURL string + URL string remindUserId string diff --git a/server/reminder.go b/server/reminder.go index 3b7a642..126768e 100755 --- a/server/reminder.go +++ b/server/reminder.go @@ -114,8 +114,8 @@ func (p *Plugin) TriggerReminders() { "Message": reminder.Message, } - if p.siteURL == "" { - p.API.LogError("SiteURL not set.") + if p.URL == "" { + p.API.LogError("URL not set.") return } @@ -140,7 +140,7 @@ func (p *Plugin) TriggerReminders() { "occurrence_id": occurrence.Id, "action": "complete", }, - URL: fmt.Sprintf("%s/plugins/%s/complete", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/complete", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.complete"), @@ -152,7 +152,7 @@ func (p *Plugin) TriggerReminders() { "occurrence_id": occurrence.Id, "action": "delete", }, - URL: fmt.Sprintf("%s/plugins/%s/delete", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete", p.URL, manifest.Id), }, Name: T("button.delete"), Type: "action", @@ -164,7 +164,7 @@ func (p *Plugin) TriggerReminders() { "occurrence_id": occurrence.Id, "action": "snooze", }, - URL: fmt.Sprintf("%s/plugins/%s/snooze", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/snooze", p.URL, manifest.Id), }, Name: T("button.snooze"), Type: "select", @@ -215,7 +215,7 @@ func (p *Plugin) TriggerReminders() { "occurrence_id": occurrence.Id, "action": "snooze", }, - URL: fmt.Sprintf("%s/plugins/%s/snooze", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/snooze", p.URL, manifest.Id), }, Name: T("button.snooze"), Type: "select", diff --git a/server/scheduler.go b/server/scheduler.go index 0265f83..4e3902a 100755 --- a/server/scheduler.go +++ b/server/scheduler.go @@ -85,7 +85,7 @@ func (p *Plugin) ScheduleReminder(request *ReminderRequest, channelId string) (* "occurrence_id": request.Reminder.Occurrences[0].Id, "action": "delete/ephemeral", }, - URL: fmt.Sprintf("%s/plugins/%s/delete/ephemeral", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/delete/ephemeral", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.delete"), @@ -98,7 +98,7 @@ func (p *Plugin) ScheduleReminder(request *ReminderRequest, channelId string) (* "occurrence_id": request.Reminder.Occurrences[0].Id, "action": "view/ephemeral", }, - URL: fmt.Sprintf("%s/plugins/%s/view/ephemeral", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/view/ephemeral", p.URL, manifest.Id), }, Type: model.POST_ACTION_TYPE_BUTTON, Name: T("button.view.reminders"), @@ -117,7 +117,7 @@ func (p *Plugin) InteractiveSchedule(triggerId string, user *model.User) { dialogRequest := model.OpenDialogRequest{ TriggerId: triggerId, - URL: fmt.Sprintf("%s/plugins/%s/dialog", p.siteURL, manifest.Id), + URL: fmt.Sprintf("%s/plugins/%s/dialog", p.URL, manifest.Id), Dialog: model.Dialog{ Title: T("schedule.reminder"), CallbackId: model.NewId(),