diff --git a/Makefile b/Makefile index 02a82c1..1fb6828 100644 --- a/Makefile +++ b/Makefile @@ -70,9 +70,11 @@ endif server: server/.depensure ifneq ($(HAS_SERVER),) mkdir -p server/dist; + mkdir -p server/dist/images; cd server && env GOOS=linux GOARCH=amd64 $(GO) build -o dist/plugin-linux-amd64; cd server && env GOOS=darwin GOARCH=amd64 $(GO) build -o dist/plugin-darwin-amd64; cd server && env GOOS=windows GOARCH=amd64 $(GO) build -o dist/plugin-windows-amd64.exe; + cp images/rss.png server/dist/images/rss.png endif ## Ensures NPM dependencies are installed without having to run this all the time. diff --git a/images/rss.png b/images/rss.png new file mode 100644 index 0000000..24284b6 Binary files /dev/null and b/images/rss.png differ diff --git a/plugin.json b/plugin.json index 860e0ee..a880123 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "id": "rssfeed", "name": "RSSFeed", "description": "This plugin serves as an rss subscription service for Mattermost.", - "version": "0.0.1", + "version": "0.0.2", "server": { "executables": { "linux-amd64": "server/dist/plugin-linux-amd64", @@ -18,7 +18,7 @@ "key": "Heartbeat", "display_name": "Time window betwteen rss feed checks (minutes).", "type": "text", - "help_text": "This is used to set a timer for the system to know when to go check to see if there is any new data in the subscribed rss feeds. Defaults to 15 minutes." + "help_text": "This is used to set a timer for the system to know when to go check to see if there is any new data in the subscribed rss feeds. Defaults to 15 minutes. (Not currently working, defaults to 15 min.)" }, { "key": "Username", diff --git a/server/images/rss.png b/server/images/rss.png new file mode 100644 index 0000000..24284b6 Binary files /dev/null and b/server/images/rss.png differ diff --git a/server/plugin.go b/server/plugin.go index 2771b79..fc0ac6e 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -5,13 +5,14 @@ import ( "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/plugin" + "io/ioutil" + "net/http" "strconv" - //"net/http" "sync" "time" ) -const RSSFEED_ICON_URL = "https://en.wikipedia.org/wiki/RSS#/media/File:Feed-icon.svg" +const RSSFEED_ICON_URL = "https://mattermost.gridprotectionalliance.org/plugins/rssfeed/images/rss.png" const RSSFEED_USERNAME = "RSSFeed Plugin" // RSSFeedPlugin Object @@ -27,35 +28,23 @@ type RSSFeedPlugin struct { } // ServeHTTP hook from mattermost plugin -/* func (p *RSSFeedPlugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - switch path := r.URL.Path; path { - case "/initiate": - go p.setupHeartBeat() - - html := ` - - - - - - -

Completed initializing to RSSFeed. Please close this window.

- - - ` - - w.Header().Set("Content-Type", "text/html") - w.Write([]byte(html)) - + case "/images/rss.png": + data, err := ioutil.ReadFile(string("plugins/rssfeed/server/dist/images/rss.png")) + if err == nil { + w.Header().Set("Content-Type", "image/png") + w.Write(data) + } else { + w.WriteHeader(404) + w.Write([]byte("404 Something went wrong - " + http.StatusText(404))) + p.API.LogInfo("/imags/rss.png err = ", err.Error()) + } default: + w.Header().Set("Content-Type", "application/json") http.NotFound(w, r) } -}*/ +} // OnActivate is a plugin hook from the Mattermost plugin API func (p *RSSFeedPlugin) OnActivate() error { @@ -202,9 +191,9 @@ func (p *RSSFeedPlugin) createBotPost(channelID string, message string, postType Message: message, Type: postType, Props: map[string]interface{}{ - "from_webhook": "true", "override_username": RSSFEED_USERNAME, "override_icon_url": RSSFEED_ICON_URL, + "from_webhook": true, }, }