From f2e9fd4312b16b88e104ce307cce956bd392d85d Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille Date: Wed, 7 Apr 2021 19:01:43 +0200 Subject: [PATCH 1/3] Add a settings to control URL substitution This substitution is known to break Linux experience. While the raw URL is also known to work on Windows. In some circumstance, it could be desirable to not subtitute URLs. --- README.md | 2 ++ plugin.json | 7 +++++++ server/configuration.go | 2 ++ server/meeting.go | 12 ++++++++++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f88d235..4d630ed 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ Go to Settings --> Scroll down to the Plugins section, and click on Webex Plugin Insert the Webex Meetings URL for your organization. It is often in the format of `.my.webex.com` or `.webex.com`. +Depending on your situation, you will want to disable the URL conversion (known unsupported on some case with Linux clients). + ## Usage Easily start and join Webex meetings directly from Mattermost diff --git a/plugin.json b/plugin.json index f217ab0..cbe930e 100644 --- a/plugin.json +++ b/plugin.json @@ -30,6 +30,13 @@ "help_text": "The hostname for your team's Webex site. For example: teamsite.webex.com.", "placeholder": "teamsite.webex.com", "default": null + }, + { + "key": "UrlConversion", + "display_name": "Convert Webex URLs:", + "type": "bool", + "help_text": "Enable or disable the conversion of URL: replace /meet/ by /join/ or /start/.", + "default": true } ] } diff --git a/server/configuration.go b/server/configuration.go index 3cd25b2..288f975 100644 --- a/server/configuration.go +++ b/server/configuration.go @@ -28,6 +28,8 @@ import ( type configuration struct { SiteHost string `json:"sitehost"` + UrlConversion bool `json:"UrlConversion"` + // siteName is the SiteHost up to .webex.com // Eg., for testsite.my.webex.com, siteName would be: testsite.my siteName string diff --git a/server/meeting.go b/server/meeting.go index a04488b..7838e00 100644 --- a/server/meeting.go +++ b/server/meeting.go @@ -73,11 +73,19 @@ func (p *Plugin) startMeetingFromRoomURL(details meetingDetails) (*meetingPosts, } func (p *Plugin) makeJoinURL(meetingURL string) string { - return strings.Replace(meetingURL, "webex.com/meet/", "webex.com/join/", 1) + if p.getConfiguration().UrlConversion { + return strings.Replace(meetingURL, "webex.com/meet/", "webex.com/join/", 1) + } else { + return meetingURL + } } func (p *Plugin) makeStartURL(meetingURL string) string { - return strings.Replace(meetingURL, "webex.com/meet/", "webex.com/start/", 1) + if p.getConfiguration().UrlConversion { + return strings.Replace(meetingURL, "webex.com/meet/", "webex.com/start/", 1) + } else { + return meetingURL + } } func (p *Plugin) getURLFromRoomID(roomID string) (string, error) { From e42ec9d18e357c4ad955c280fbc87bbd74b5774a Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Thu, 27 May 2021 14:04:21 +0200 Subject: [PATCH 2/3] Fix linter issues --- server/configuration.go | 2 +- server/meeting.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/configuration.go b/server/configuration.go index 288f975..0f3e926 100644 --- a/server/configuration.go +++ b/server/configuration.go @@ -28,7 +28,7 @@ import ( type configuration struct { SiteHost string `json:"sitehost"` - UrlConversion bool `json:"UrlConversion"` + URLConversion bool `json:"url_conversion"` // siteName is the SiteHost up to .webex.com // Eg., for testsite.my.webex.com, siteName would be: testsite.my diff --git a/server/meeting.go b/server/meeting.go index 7838e00..3b74d01 100644 --- a/server/meeting.go +++ b/server/meeting.go @@ -73,19 +73,19 @@ func (p *Plugin) startMeetingFromRoomURL(details meetingDetails) (*meetingPosts, } func (p *Plugin) makeJoinURL(meetingURL string) string { - if p.getConfiguration().UrlConversion { - return strings.Replace(meetingURL, "webex.com/meet/", "webex.com/join/", 1) - } else { - return meetingURL + if p.getConfiguration().URLConversion { + meetingURL = strings.Replace(meetingURL, "webex.com/meet/", "webex.com/join/", 1) } + + return meetingURL } func (p *Plugin) makeStartURL(meetingURL string) string { - if p.getConfiguration().UrlConversion { - return strings.Replace(meetingURL, "webex.com/meet/", "webex.com/start/", 1) - } else { - return meetingURL + if p.getConfiguration().URLConversion { + meetingURL = strings.Replace(meetingURL, "webex.com/meet/", "webex.com/start/", 1) } + + return meetingURL } func (p *Plugin) getURLFromRoomID(roomID string) (string, error) { From da9f7bb2c46a7642f2bed6c28a931ab551d76d41 Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Wed, 14 Jul 2021 15:29:34 +0200 Subject: [PATCH 3/3] Fix test --- server/http_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/http_test.go b/server/http_test.go index d4c7276..6aa9fba 100644 --- a/server/http_test.go +++ b/server/http_test.go @@ -184,8 +184,9 @@ func TestPlugin(t *testing.T) { p := Plugin{} p.setConfiguration(&configuration{ - SiteHost: tc.SiteHost, - siteName: parseSiteNameFromSiteHost(tc.SiteHost), + SiteHost: tc.SiteHost, + siteName: parseSiteNameFromSiteHost(tc.SiteHost), + URLConversion: true, }) p.SetAPI(api)