Skip to content

Commit

Permalink
Added rss.png to httpserver and changed version number
Browse files Browse the repository at this point in the history
  • Loading branch information
Billy Ernest committed Mar 16, 2019
1 parent e3f5066 commit 354ed40
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Binary file added images/rss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Binary file added server/images/rss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 16 additions & 27 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 := `
<!DOCTYPE html>
<html>
<head>
<script>
window.close();
</script>
</head>
<body>
<p>Completed initializing to RSSFeed. Please close this window.</p>
</body>
</html>
`
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 {
Expand Down Expand Up @@ -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,
},
}

Expand Down

0 comments on commit 354ed40

Please sign in to comment.