Finished Frontend notifications, added file prio (needs test), started Settings Button work

This commit is contained in:
2018-01-23 23:21:25 -05:00
parent 5856052f82
commit 52e245d11f
15 changed files with 241 additions and 126 deletions

BIN
downloaded/introducingR.pdf Normal file

Binary file not shown.

View File

@@ -18,6 +18,12 @@ type Message struct {
}
//Next are the messages the server sends to the client
//ServerPushMessage is information (usually logs and status messages) that the server pushes to the client
type ServerPushMessage struct {
MessageType string
MessageLevel string //can be "success", "error", "warn", "info"
Payload string //the actual message
}
//RSSJSONList is a slice of gofeed.Feeds sent to the client
type RSSJSONList struct {

View File

@@ -13,9 +13,6 @@ import (
"github.com/sirupsen/logrus"
)
//Logger is the global variable pulled in from main.go
var Logger *logrus.Logger
//InitializeCronEngine initializes and starts the cron engine so we can add tasks as needed, returns pointer to the engine
func InitializeCronEngine() *cron.Cron {
c := cron.New()

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"time"
@@ -12,10 +13,22 @@ import (
"github.com/anacrolix/torrent/metainfo"
"github.com/asdine/storm"
Storage "github.com/deranjer/goTorrent/storage"
"github.com/gorilla/websocket"
"github.com/mmcdole/gofeed"
"github.com/sirupsen/logrus"
)
//Logger is the injected variable for global logger
var Logger *logrus.Logger
//Conn is the injected variable for the websocket connection
var Conn *websocket.Conn
//CreateServerPushMessage Pushes a message from the server to the client
func CreateServerPushMessage(message ServerPushMessage, conn *websocket.Conn) {
conn.WriteJSON(message)
}
//RefreshSingleRSSFeed refreshing a single RSS feed to send to the client (so no updating database) mainly by updating the torrent list to display any changes
func RefreshSingleRSSFeed(db *storm.DB, RSSFeed Storage.SingleRSSFeed) Storage.SingleRSSFeed { //Todo.. duplicate as cron job... any way to merge these to reduce duplication?
singleRSSFeed := Storage.SingleRSSFeed{URL: RSSFeed.URL, Name: RSSFeed.Name}
@@ -24,6 +37,7 @@ func RefreshSingleRSSFeed(db *storm.DB, RSSFeed Storage.SingleRSSFeed) Storage.S
feed, err := fp.ParseURL(RSSFeed.URL)
if err != nil {
Logger.WithFields(logrus.Fields{"RSSFeedURL": RSSFeed.URL, "error": err}).Error("Unable to parse URL")
CreateServerPushMessage(ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to add Storage Path"}, Conn)
}
for _, RSSTorrent := range feed.Items {
singleRSSTorrent.Link = RSSTorrent.Link
@@ -45,7 +59,8 @@ func ForceRSSRefresh(db *storm.DB, RSSFeedStore Storage.RSSFeedStore) { //Todo..
for _, singleFeed := range RSSFeedStore.RSSFeeds {
feed, err := fp.ParseURL(singleFeed.URL)
if err != nil {
Logger.WithFields(logrus.Fields{"RSSFeedURL": singleFeed.URL, "error": err}).Error("Unable to parse URL")
Logger.WithFields(logrus.Fields{"RSSFeedURL": singleFeed.URL, "error": err}).Error("Unable to parse RSS URL")
CreateServerPushMessage(ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to parse RSS URL"}, Conn)
}
for _, RSSTorrent := range feed.Items {
singleRSSTorrent.Link = RSSTorrent.Link
@@ -74,6 +89,7 @@ func timeOutInfo(clientTorrent *torrent.Torrent, seconds time.Duration) (deleted
return false
case <-timeout: // getting info for torrent has timed out so purging the torrent
Logger.WithFields(logrus.Fields{"clientTorrentName": clientTorrent.Name()}).Error("Forced to drop torrent from timeout waiting for info")
CreateServerPushMessage(ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Timout waiting for torrent info... dropping"}, Conn)
clientTorrent.Drop()
return true
}
@@ -100,6 +116,7 @@ func readTorrentFileFromDB(element *Storage.TorrentLocal, tclient *torrent.Clien
singleTorrent, err = tclient.AddTorrentFromFile(element.TorrentFileName)
if err != nil {
Logger.WithFields(logrus.Fields{"tempfile": element.TorrentFileName, "err": err}).Error("Unable to add Torrent from file!")
CreateServerPushMessage(ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to add Torrent from file!"}, Conn)
}
return singleTorrent
@@ -149,6 +166,7 @@ func StartTorrent(clientTorrent *torrent.Torrent, torrentLocalStorage Storage.To
torrentLocalStorage.TorrentFilePriority = TorrentFilePriorityArray
Storage.AddTorrentLocalStorage(torrentDbStorage, torrentLocalStorage) //writing all of the data to the database
clientTorrent.DownloadAll() //starting the download
CreateServerPushMessage(ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "success", Payload: "Torrent added!"}, Conn)
}
//CreateRunningTorrentArray creates the entire torrent list to pass to client
@@ -247,8 +265,9 @@ func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Sto
}
//CreateFileListArray creates a file list for a single torrent that is selected and sent to the server
func CreateFileListArray(tclient *torrent.Client, selectedHash string) TorrentFileList {
func CreateFileListArray(tclient *torrent.Client, selectedHash string, db *storm.DB) TorrentFileList {
runningTorrents := tclient.Torrents() //don't need running torrent array since we aren't adding or deleting from storage
torrentFileListStorage := Storage.FetchTorrentFromStorage(db, selectedHash)
TorrentFileListSelected := TorrentFileList{}
TorrentFileStruct := TorrentFile{}
for _, singleTorrent := range runningTorrents {
@@ -259,7 +278,11 @@ func CreateFileListArray(tclient *torrent.Client, selectedHash string) TorrentFi
for _, singleFile := range torrentFilesRaw {
TorrentFileStruct.TorrentHashString = tempHash
TorrentFileStruct.FileName = singleFile.DisplayPath()
TorrentFileStruct.FilePath = singleFile.Path()
absFilePath, err := filepath.Abs(singleFile.Path())
if err != nil {
Logger.WithFields(logrus.Fields{"file": singleFile.Path()}).Debug("Unable to create absolute path")
}
TorrentFileStruct.FilePath = absFilePath
PieceState := singleFile.State()
var downloadedBytes int64
for _, piece := range PieceState {
@@ -268,7 +291,12 @@ func CreateFileListArray(tclient *torrent.Client, selectedHash string) TorrentFi
}
}
TorrentFileStruct.FilePercent = fmt.Sprintf("%.2f", float32(downloadedBytes)/float32(singleFile.Length()))
TorrentFileStruct.FilePriority = "Normal" //TODO, figure out how to store this per file in storage and also tie a priority to a file
for i, specificFile := range torrentFileListStorage.TorrentFilePriority { //searching for that specific file in storage
if specificFile.TorrentFilePath == singleFile.DisplayPath() {
TorrentFileStruct.FilePriority = torrentFileListStorage.TorrentFilePriority[i].TorrentFilePriority
}
}
TorrentFileStruct.FileSize = HumanizeBytes(float32(singleFile.Length()))
TorrentFileListSelected.FileList = append(TorrentFileListSelected.FileList, TorrentFileStruct)
}

View File

@@ -18,6 +18,8 @@ let fileList = [];
let RSSList = [];
let RSSTorrentList = [];
let serverMessage = [];
let serverPushMessage = [];
let webSocketState = false;
var torrentListRequest = {
messageType: "torrentListRequest"
@@ -29,7 +31,7 @@ var torrentListRequest = {
//websocket is started in kickwebsocket.js and is picked up here so "ws" is already defined 22
ws.onmessage = function (evt) { //When we recieve a message from the websocket
var serverMessage = JSON.parse(evt.data)
//console.log("message", serverMessage.MessageType)
console.log("message", serverMessage.MessageType)
switch (serverMessage.MessageType) {
case "torrentList":
@@ -125,10 +127,11 @@ ws.onmessage = function (evt) { //When we recieve a message from the websocket
PublishDate: serverMessage.Torrents[i].PubDate,
})
}
break;
case "serverPushMessage":
console.log("Server push notification receieved", evt.data)
serverMessage = [serverMessage.Type, serverMessage.body];
this.props.newServerMessage(serverMessage)
console.log("SERVER PUSHED MESSAGE", serverMessage)
serverPushMessage = [serverMessage.MessageLevel, serverMessage.Payload];
break;
}
}
@@ -197,6 +200,10 @@ class BackendSocket extends React.Component {
() => this.tick(),
2000
);
if (ws.readyState === (ws.CONNECTING || ws.OPEN)){ //checking to make sure we have a websocket connection
webSocketState = true
this.props.webSocketStateUpdate(webSocketState)
}
}
@@ -211,9 +218,17 @@ class BackendSocket extends React.Component {
if (this.props.RSSTorrentList != RSSTorrentList & this.props.RSSModalOpen == true){
this.props.RSSTorrentList(RSSTorrentList) //pushing the new RSSTorrentList to Redux
}
if (this.props.serverPushMessage != serverPushMessage & serverPushMessage[0] != null){
console.log("PROPSSERVER", this.props.serverPushMessage, "SERVERPUSH", serverPushMessage)
this.props.newServerMessage(serverPushMessage)
}
ws.send(JSON.stringify(torrentListRequest))//talking to the server to get the torrent list
if (ws.readyState === ws.CLOSED){ //if our websocket gets closed inform the user
webSocketState = false
this.props.webSocketStateUpdate(webSocketState)
}
//console.log("Torrentlist", torrents)
this.props.setButtonState(this.props.selection) //forcing an update to the buttons
this.props.newTorrentList(torrents) //sending the list of torrents to torrentlist.js
@@ -243,7 +258,7 @@ class BackendSocket extends React.Component {
componentWillReceiveProps (nextProps) {
console.log("Lenght", nextProps.selectionHashes.length, "value", nextProps.selectionHashes)
console.log("Length", nextProps.selectionHashes.length, "value", nextProps.selectionHashes)
if (nextProps.selectionHashes.length === 1){ //if we have a selection pass it on for the tabs to verify
this.selectionHandler(nextProps.selectionHashes, nextProps.selectedTab)
}
@@ -271,6 +286,7 @@ const mapStateToProps = state => {
selection: state.selection,
RSSModalOpen: state.RSSModalOpen,
RSSTorrentList: state.RSSTorrentList,
serverPushMessage: state.serverPushMessage
};
}
@@ -285,7 +301,8 @@ const mapDispatchToProps = dispatch => {
setButtonState: (buttonState) => dispatch({type: actionTypes.SET_BUTTON_STATE, buttonState}),
newRSSFeedStore: (RSSList) => dispatch({type: actionTypes.NEW_RSS_FEED_STORE, RSSList}),
RSSTorrentList: (RSSTorrentList) => dispatch({type: actionTypes.RSS_TORRENT_LIST, RSSTorrentList}),
newServerMessage: (serverMessage) => dispatch({type: actionTypes.SERVER_MESSAGE, serverMessage}),
newServerMessage: (serverPushMessage) => dispatch({type: actionTypes.SERVER_MESSAGE, serverPushMessage}),
webSocketStateUpdate: (webSocketState) => dispatch({type: actionTypes.WEBSOCKET_STATE, webSocketState}),
//changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection}),//forcing an update to the buttons
}

View File

@@ -38,10 +38,7 @@ class FileTab extends React.Component {
fileSelection: [],
selected: [],
};
this.changeColumnOrder = columnOrder => this.setState({columnOrder});
this.changeColumnWidths = columnWidths => this.setState({columnWidths});
this.changeSorting = sorting => this.setState({sorting});
@@ -58,41 +55,41 @@ class FileTab extends React.Component {
selectedRows.push(this.props.fileList[element]) //pushing the selected rows out of torrentlist
});
this.setState({fileSelection: selectedRows})
}
}
}
sendPriorityRequest = (priority, sendfileNames) => {
sendPriorityRequest = (priority, selectionHash) => {
let filePaths = []
this.state.fileSelection.forEach(element => {
console.log("element", element)
sendFileNames.push(element.FilePath)
filePaths.push(element.FilePath)
})
let setFilePriority = {
MessageType: "setFilePriority",
Payload: sendFileNames,
MessageDetail: priority,
MessageDetailTwo: selectionHash,
Payload: filePaths,
}
console.log(JSON.stringify(setFilePriority))
ws.send(JSON.stringify(setFilePriority))
}
setHighPriority = () => {
let priorty = "High"
let priority = "High"
let selectionHash = this.props.selectionHashes[0] //getting the first element (should be the only one)
let sendFileNames = [selectionHash, "High"]// adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
this.sendPriorityRequest(priority, selectionHash)
}
setNormalPriority = () => {
let priorty = "Normal"
let priority = "Normal"
let selectionHash = this.props.selectionHashes[0] //getting the first element (should be the only one)
let sendFileNames = [selectionHash, "Normal"]// adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
this.sendPriorityRequest(priority, selectionHash)
}
setCancelPriority = () => {
let priorty = "Cancel"
let priority = "Cancel"
let selectionHash = this.props.selectionHashes[0] //getting the first element (should be the only one)
let sendFileNames = [selectionHash, "Cancel"]// adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
this.sendPriorityRequest(priority, selectionHash)
}
render() {
return (
//Buttons here
@@ -140,15 +137,11 @@ const mapStateToProps = state => {
return {
selectionHashes: state.selectionHashes,
fileList: state.fileList,
//fileSelectionNames: state.fileSelectionNames,
};
}
const mapDispatchToProps = dispatch => {
return {
//changeFileSelection: (fileSelection) => dispatch({type: actionTypes.CHANGE_FILE_SELECTION, fileSelection}),
sendSelectionHashes: (selectionHashes) => dispatch({type: actionTypes.SELECTION_HASHES, selectionHashes}),
}
}

View File

@@ -81,7 +81,7 @@ const inlineStyle = {
const mapStateToProps = state => {
return {
RSSModalOpen: state.RSSModalOpen,
};
}
}
const mapDispatchToProps = dispatch => {

View File

@@ -58,6 +58,9 @@ export default class addTorrentPopup extends React.Component {
}
console.log("Sending magnet link: ", magnetLinkMessage);
ws.send(JSON.stringify(magnetLinkMessage));
this.setState({magnetLinkValue: ""})
this.setState({storageValue: ``})
console.log("Magnet Link", this.state.magnetLinkValue)
}
setMagnetLinkValue = (event) => {

View File

@@ -11,25 +11,31 @@ import { ToastContainer, toast } from 'react-toastify';
class Notifications extends React.Component {
constructor(props){
super(props);
this.state = { serverMessage: ["info", "A props message"]}
}
componentWillReceiveProps(nextprops) {
if (nextprops.serverMessage != this.state.serverMessage) {
toast(this.state.serverMessage[1])
if (nextprops.serverPushMessage != this.props.serverPushMessage) {
toast(nextprops.serverPushMessage[1], {
type: nextprops.serverPushMessage[0]
})
console.log("Server Push Message", nextprops.serverPushMessage)
}
if (nextprops.webSocketState != this.props.webSocketState){
if (nextprops.webSocketState == true){
toast.success("Websocket Connection Open!")
} else {
toast("Websocket Connection Closed!", {
type: "error",
autoClose: false,
})
}
}
}
componentDidMount(){
toast("Testing toast custom settings")
}
render() {
return (
<div>
<ToastContainer type={this.state.serverMessage[0]} position={toast.POSITION.TOP_RIGHT} autoClose={8000} />
<ToastContainer position={toast.POSITION.TOP_RIGHT} autoClose={8000} />
</div>
);
}
@@ -39,7 +45,8 @@ class Notifications extends React.Component {
const mapStateToProps = state => {
return {
//serverMessage: state.serverMessage,
serverPushMessage: state.serverPushMessage,
webSocketState: state.webSocketState,
};
}

View File

@@ -11,4 +11,5 @@ export const CHANGE_FILE_SELECTION = 'CHANGE_FILE_SELECTION';
export const NEW_RSS_FEED_STORE = 'NEW_RSS_FEED_STORE';
export const RSS_MODAL_OPEN_STATE = 'RSS_MODAL_OPEN_STATE';
export const RSS_TORRENT_LIST = 'RSS_TORRENT_LIST';
export const SERVER_MESSAGE = 'SERVER_MESSAGE';
export const SERVER_MESSAGE = 'SERVER_MESSAGE';
export const WEBSOCKET_STATE = 'WEBSOCKET_STATE';

View File

@@ -18,7 +18,8 @@ const initialState = {
RSSList: [],
RSSTorrentList: [],
RSSModalOpen: false,
serverMessage: [],
serverPushMessage: [],
webSocketState: false
}
@@ -26,6 +27,12 @@ const initialState = {
const reducer = (state = initialState, action) => {
switch(action.type){
case actionTypes.WEBSOCKET_STATE:
console.log("Websocket closed...")
return {
...state,
webSocketState: action.webSocketState,
}
case actionTypes.CHANGE_SELECTION:
console.log("Change Selection", action.selection)
@@ -100,10 +107,10 @@ const reducer = (state = initialState, action) => {
}
case actionTypes.SERVER_MESSAGE:
console.log("New server push message", action.serverMessage)
console.log("New server push message", action.serverPushMessage)
return {
...state,
serverMessage: action.serverMessage
serverPushMessage: action.serverPushMessage
}
case actionTypes.SET_BUTTON_STATE:

96
main.go
View File

@@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
)
//SingleRSSFeedMessage will most likley be deprecated as this is the only way I could get it working currently
//SingleRSSFeedMessage will most likely be deprecated as this is the only way I could get it working currently
type SingleRSSFeedMessage struct { //TODO had issues with getting this to work with Storage or Engine
MessageType string
URL string //the URL of the individual RSS feed
@@ -34,11 +34,9 @@ type SingleRSSFeedMessage struct { //TODO had issues with getting this to work w
}
var (
baseTmpl string = "templates/base.tmpl"
//Logger does logging for the entire project
Logger = logrus.New()
APP_ID = os.Getenv("APP_ID")
APP_SECRET = os.Getenv("APP_SECRET")
Logger = logrus.New()
APP_ID = os.Getenv("APP_ID")
)
var upgrader = websocket.Upgrader{
@@ -51,10 +49,6 @@ func serveHome(w http.ResponseWriter, r *http.Request) {
s1.ExecuteTemplate(w, "base", map[string]string{"APP_ID": APP_ID})
}
func updateClient(torrentstats []Engine.ClientDB, conn *websocket.Conn) { //get the torrent client and the websocket connection to write msg
conn.WriteJSON(torrentstats) //converting to JSON and writing to the client
}
func main() {
Engine.Logger = Logger //Injecting the logger into all the packages
Storage.Logger = Logger
@@ -83,8 +77,8 @@ func main() {
Logger.SetLevel(Config.LoggingLevel)
httpAddr := Config.HTTPAddr
os.Mkdir(Config.TFileUploadFolder, 0755) //creating a directory to store uploaded torrent files
os.Mkdir(Config.TorrentWatchFolder, 0755) //creating a directory to watch for added .torrent files
os.MkdirAll(Config.TFileUploadFolder, 0755) //creating a directory to store uploaded torrent files
os.MkdirAll(Config.TorrentWatchFolder, 0755) //creating a directory to watch for added .torrent files
Logger.WithFields(logrus.Fields{"Config": Config}).Info("Torrent Client Config has been generated...")
tclient, err := torrent.NewClient(&Config.TorrentConfig) //pulling out the torrent specific config to use
@@ -115,7 +109,6 @@ func main() {
} else {
Logger.Info("Database is empty, no torrents loaded")
}
Engine.CheckTorrentWatchFolder(cronEngine, db, tclient, torrentLocalStorage, Config)
Engine.RefreshRSSCron(cronEngine, db, tclient, torrentLocalStorage, Config) // Refresing the RSS feeds on an hourly basis to add torrents that show up in the RSS feed
@@ -133,7 +126,6 @@ func main() {
torrentlistArrayJSON, _ := json.Marshal(torrentlistArray)
w.Header().Set("Content-Type", "application/json")
w.Write(torrentlistArrayJSON)
//updateClient(RunningTorrentArray, conn) // sending the client update information over the websocket
})
http.HandleFunc("/websocket", func(w http.ResponseWriter, r *http.Request) { //websocket is the main data pipe to the frontend
conn, err := upgrader.Upgrade(w, r, nil)
@@ -142,19 +134,20 @@ func main() {
Logger.WithFields(logrus.Fields{"error": err}).Fatal("Unable to create websocket!")
return
}
MessageLoop: //Tagging this so we can break out of it with any errors we encounter that are failing
Engine.Conn = conn //Injecting the conn variable into the other packages
Storage.Conn = conn
MessageLoop: //Tagging this so we can continue out of it with any errors we encounter that are failing
for {
runningTorrents := tclient.Torrents() //getting running torrents here since multiple cases ask for the running torrents
msg := Engine.Message{}
err := conn.ReadJSON(&msg)
if err != nil {
Logger.WithFields(logrus.Fields{"error": err, "message": msg}).Error("Unable to read JSON client message")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Malformed JSON request made to server.. ignoring"}, conn)
break MessageLoop
}
Logger.WithFields(logrus.Fields{"message": msg}).Debug("Message From Client")
switch msg.MessageType { //first handling data requests
case "torrentListRequest":
Logger.WithFields(logrus.Fields{"message": msg}).Debug("Client Requested TorrentList Update")
TorrentLocalArray = Storage.FetchAllStoredTorrents(db) //Required to re-read th database since we write to the DB and this will pull the changes from it
@@ -167,11 +160,10 @@ func main() {
torrentlistArray.Totaltorrents = len(RunningTorrentArray)
Logger.WithFields(logrus.Fields{"torrentList": torrentlistArray, "previousTorrentList": PreviousTorrentArray}).Debug("Previous and Current Torrent Lists for sending to client")
conn.WriteJSON(torrentlistArray)
//updateClient(RunningTorrentArray, conn) // sending the client update information over the websocket
case "torrentFileListRequest": //client requested a filelist update
Logger.WithFields(logrus.Fields{"message": msg}).Debug("Client Requested FileList Update")
FileListArray := Engine.CreateFileListArray(tclient, msg.Payload[0])
FileListArray := Engine.CreateFileListArray(tclient, msg.Payload[0], db)
conn.WriteJSON(FileListArray) //writing the JSON to the client
case "torrentDetailedInfo":
@@ -185,6 +177,15 @@ func main() {
torrentPeerList := Engine.CreatePeerListArray(tclient, msg.Payload[0])
conn.WriteJSON(torrentPeerList)
case "settingsFileRequest":
Logger.WithFields(logrus.Fields{"message": msg}).Debug("Client Requested Settings File")
clientSettingsFile, err := json.Marshal(Config)
if err != nil {
Logger.WithFields(logrus.Fields{"message": msg}).Error("Unable to Marshal Setting file into JSON!")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to marshal config into JSON!"}, conn)
}
conn.WriteJSON(clientSettingsFile)
case "rssFeedRequest":
Logger.WithFields(logrus.Fields{"message": msg}).Debug("Client Requested RSS Update")
@@ -196,7 +197,6 @@ func main() {
RSSsingleFeed.RSSFeedURL = singleFeed.URL
RSSJSONFeed.RSSFeeds = append(RSSJSONFeed.RSSFeeds, RSSsingleFeed)
}
conn.WriteJSON(RSSJSONFeed)
case "addRSSFeed":
@@ -207,21 +207,24 @@ func main() {
for _, singleFeed := range fullRSSFeeds.RSSFeeds {
if newRSSFeed == singleFeed.URL || newRSSFeed == "" {
Logger.WithFields(logrus.Fields{"RSSFeed": newRSSFeed}).Warn("Empty URL or Duplicate RSS URL to one already in database! Rejecting submission")
break MessageLoop
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Empty URL or Duplicate RSS URL to one already in database!"}, conn)
continue MessageLoop
}
}
fp := gofeed.NewParser()
feed, err := fp.ParseURL(newRSSFeed)
if err != nil {
Logger.WithFields(logrus.Fields{"RSSFeed": newRSSFeed}).Warn("Unable to parse the URL as valid RSS.. cannot add RSS...")
break MessageLoop
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to parse the URL as valid RSS.. cannot add RSS..."}, conn)
continue MessageLoop
}
Logger.WithFields(logrus.Fields{"RSSFeedTitle": feed.Title}).Info("Have feed from URL...")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "success", Payload: "Added RSS Feed"}, conn)
newRSSFeedFull := Storage.SingleRSSFeed{}
newRSSFeedFull.Name = feed.Title
newRSSFeedFull.URL = msg.Payload[0]
fullRSSFeeds.RSSFeeds = append(fullRSSFeeds.RSSFeeds, newRSSFeedFull) // add the new RSS feed to the stack
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Adding RSS feed..."}, conn)
Engine.ForceRSSRefresh(db, fullRSSFeeds)
//forcing an RSS refresh to fully populate all rss feeds TODO maybe just push the update of the new RSS feed and leave cron to update? But user would most likely expect and immediate update
@@ -230,6 +233,7 @@ func main() {
removingRSSFeed := msg.Payload[0]
Storage.DeleteRSSFeed(db, removingRSSFeed)
fullRSSFeeds := Storage.FetchRSSFeeds(db)
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Deleting RSS feed..."}, conn)
Engine.ForceRSSRefresh(db, fullRSSFeeds)
case "rssTorrentsRequest":
@@ -245,12 +249,13 @@ func main() {
if storageValue == "" {
storageValue, err = filepath.Abs(filepath.ToSlash(Config.DefaultMoveFolder))
if err != nil {
Logger.WithFields(logrus.Fields{"err": err, "MagnetLink": Config.DefaultMoveFolder}).Error("Unable to add Storage Path")
Logger.WithFields(logrus.Fields{"err": err, "MagnetLink": Config.DefaultMoveFolder}).Error("Unable to add default Storage Path")
}
} else {
storageValue, err = filepath.Abs(filepath.ToSlash(storageValue))
if err != nil {
Logger.WithFields(logrus.Fields{"err": err, "MagnetLink": storageValue}).Error("Unable to add Storage Path")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to add Storage path..."}, conn)
storageValue, _ = filepath.Abs(filepath.ToSlash(Config.DefaultMoveFolder))
}
}
@@ -258,9 +263,11 @@ func main() {
clientTorrent, err := tclient.AddMagnet(magnetLink) //reading the payload into the torrent client
if err != nil {
Logger.WithFields(logrus.Fields{"err": err, "MagnetLink": magnetLink}).Error("Unable to add magnetlink to client!")
break MessageLoop //break out of the loop entirely for this message since we hit an error
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to add magnetlink to client!"}, conn)
continue MessageLoop //continue out of the loop entirely for this message since we hit an error
}
Logger.WithFields(logrus.Fields{"clientTorrent": clientTorrent, "magnetLink": magnetLink}).Info("Adding torrent to client!")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Received MagnetLink"}, conn)
Engine.StartTorrent(clientTorrent, torrentLocalStorage, db, Config.TorrentConfig.DataDir, "magnet", "", storageValue) //starting the torrent and creating local DB entry
}
@@ -271,6 +278,7 @@ func main() {
file, err := base64.StdEncoding.DecodeString(base64file[1]) //grabbing the second half of the string after the split
if err != nil {
Logger.WithFields(logrus.Fields{"Error": err, "file": file}).Info("Unable to decode base64 string to file")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to decode base64 string to file"}, conn)
}
FileName := msg.MessageDetail
storageValue := msg.MessageDetailTwo
@@ -278,30 +286,35 @@ func main() {
storageValue, err = filepath.Abs(filepath.ToSlash(Config.DefaultMoveFolder))
if err != nil {
Logger.WithFields(logrus.Fields{"err": err, "MagnetLink": Config.DefaultMoveFolder}).Error("Unable to add Storage Path")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to add default Storage Path"}, conn)
}
} else {
storageValue, err = filepath.Abs(filepath.ToSlash(storageValue))
if err != nil {
Logger.WithFields(logrus.Fields{"err": err, "MagnetLink": storageValue}).Error("Unable to add Storage Path")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to add Storage Path"}, conn)
storageValue, _ = filepath.Abs(filepath.ToSlash(Config.DefaultMoveFolder))
}
}
filePath := filepath.Join(Config.TFileUploadFolder, FileName) //creating a full filepath to store the .torrent files
err = ioutil.WriteFile(filePath, file, 0755) //Dumping our recieved file into the filename
err = ioutil.WriteFile(filePath, file, 0755) //Dumping our received file into the filename
if err != nil {
Logger.WithFields(logrus.Fields{"filepath": filePath, "Error": err}).Error("Unable to write torrent data to file")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to write torrent data to file"}, conn)
}
clientTorrent, err := tclient.AddTorrentFromFile(filePath)
if err != nil {
Logger.WithFields(logrus.Fields{"filepath": filePath, "Error": err}).Error("Unable to add Torrent to torrent server")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "error", Payload: "Unable to add Torrent to torrent server"}, conn)
}
Logger.WithFields(logrus.Fields{"clienttorrent": clientTorrent.Name(), "filename": filePath}).Info("Added torrent")
Engine.StartTorrent(clientTorrent, torrentLocalStorage, db, Config.TorrentConfig.DataDir, "file", filePath, storageValue)
case "stopTorrents":
TorrentListCommands := msg.Payload
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Received Stop Request"}, conn)
for _, singleTorrent := range runningTorrents {
for _, singleSelection := range TorrentListCommands {
@@ -319,7 +332,7 @@ func main() {
case "deleteTorrents":
withData := msg.MessageDetail //Checking if torrents should be deleted with data
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Received Delete Request"}, conn)
Logger.WithFields(logrus.Fields{"deleteTorrentsPayload": msg.Payload, "torrentlist": msg.Payload, "deleteWithData?": withData}).Info("message for deleting torrents")
for _, singleTorrent := range runningTorrents {
for _, singleSelection := range msg.Payload {
@@ -339,8 +352,8 @@ func main() {
case "startTorrents":
Logger.WithFields(logrus.Fields{"selection": msg.Payload}).Info("Matched for starting torrents")
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Received Start Request"}, conn)
for _, singleTorrent := range runningTorrents {
for _, singleSelection := range msg.Payload {
if singleTorrent.InfoHash().String() == singleSelection {
Logger.WithFields(logrus.Fields{"infoHash": singleTorrent.InfoHash().String()}).Debug("Found matching torrent to start")
@@ -355,22 +368,25 @@ func main() {
}
}
case "setFilePriority":
case "setFilePriority": //TODO disable if the file is already at 100%?
Logger.WithFields(logrus.Fields{"selection": msg.Payload}).Info("Matched for setting file priority")
priorityRequested := msg.Payload[1] //storing the priority requested
infoHash := msg.Payload[0] //storing our infohash
fileList := append(msg.Payload[:0], msg.Payload[2:]...) //removing the filehash and priority from the array leaving just the filepath
Engine.CreateServerPushMessage(Engine.ServerPushMessage{MessageType: "serverPushMessage", MessageLevel: "info", Payload: "Received Set Priority Request"}, conn)
priorityRequested := msg.MessageDetail //storing the priority requested
infoHash := msg.MessageDetailTwo //storing our infohash
fileList := msg.Payload //filelist contains the ABSOLUTE paths to all of the files
Logger.WithFields(logrus.Fields{"filelist": fileList}).Debug("Full filelist for setting file priority")
for _, singleTorrent := range runningTorrents {
if singleTorrent.InfoHash().String() == infoHash {
Logger.WithFields(logrus.Fields{"singleTorrent": singleTorrent}).Debug("Matched for changing file prio torrents")
for _, file := range singleTorrent.Files() {
for _, sentFile := range fileList {
if file.Path() == sentFile {
absFilePath, err := filepath.Abs(file.Path())
if err != nil {
Logger.WithFields(logrus.Fields{"singleTorrent": singleTorrent}).Error("Cannot create absolute file path for file")
}
if absFilePath == sentFile {
if priorityRequested == "High" {
fileRead := singleTorrent.NewReader()
fileRead.Seek(file.Offset(), 0)
fileRead.SetReadahead(file.Length())
file.SetPriority(torrent.PiecePriorityHigh)
Logger.WithFields(logrus.Fields{"singleTorrent": file.DisplayPath()}).Debug("Setting priority for HIGH")
activeTorrentStruct := Storage.FetchTorrentFromStorage(db, infoHash) //fetching all the data from the db to update certain fields then write it all back
for i, specificFile := range activeTorrentStruct.TorrentFilePriority { //searching for that specific file
@@ -378,10 +394,10 @@ func main() {
activeTorrentStruct.TorrentFilePriority[i].TorrentFilePriority = "High" //writing just that field to the current struct
}
}
Storage.UpdateStorageTick(db, activeTorrentStruct) //rewritting essentially that entire struct right back into the database
Storage.UpdateStorageTick(db, activeTorrentStruct) //re-writting essentially that entire struct right back into the database
}
if priorityRequested == "Normal" {
file.Download()
file.SetPriority(torrent.PiecePriorityNormal)
Logger.WithFields(logrus.Fields{"singleTorrent": file.DisplayPath()}).Debug("Setting priority for Normal")
activeTorrentStruct := Storage.FetchTorrentFromStorage(db, infoHash) //fetching all the data from the db to update certain fields then write it all back
for i, specificFile := range activeTorrentStruct.TorrentFilePriority { //searching for that specific file
@@ -389,10 +405,10 @@ func main() {
activeTorrentStruct.TorrentFilePriority[i].TorrentFilePriority = "Normal" //writing just that field to the current struct
}
}
Storage.UpdateStorageTick(db, activeTorrentStruct) //rewritting essentially that entire struct right back into the database
Storage.UpdateStorageTick(db, activeTorrentStruct) //re-writting essentially that entire struct right back into the database
}
if priorityRequested == "Cancel" {
file.Cancel()
file.SetPriority(torrent.PiecePriorityNone)
Logger.WithFields(logrus.Fields{"singleTorrent": file.DisplayPath()}).Debug("Canceling file")
activeTorrentStruct := Storage.FetchTorrentFromStorage(db, infoHash) //fetching all the data from the db to update certain fields then write it all back
for i, specificFile := range activeTorrentStruct.TorrentFilePriority { //searching for that specific file
@@ -400,7 +416,7 @@ func main() {
activeTorrentStruct.TorrentFilePriority[i].TorrentFilePriority = "Canceled" //writing just that field to the current struct
}
}
Storage.UpdateStorageTick(db, activeTorrentStruct) //rewritting essentially that entire struct right back into the database
Storage.UpdateStorageTick(db, activeTorrentStruct) //re-writting essentially that entire struct right back into the database
}
}

View File

@@ -1499,6 +1499,7 @@ var NEW_RSS_FEED_STORE = exports.NEW_RSS_FEED_STORE = 'NEW_RSS_FEED_STORE';
var RSS_MODAL_OPEN_STATE = exports.RSS_MODAL_OPEN_STATE = 'RSS_MODAL_OPEN_STATE';
var RSS_TORRENT_LIST = exports.RSS_TORRENT_LIST = 'RSS_TORRENT_LIST';
var SERVER_MESSAGE = exports.SERVER_MESSAGE = 'SERVER_MESSAGE';
var WEBSOCKET_STATE = exports.WEBSOCKET_STATE = 'WEBSOCKET_STATE';
/***/ }),
/* 25 */
@@ -79006,7 +79007,8 @@ var initialState = {
RSSList: [],
RSSTorrentList: [],
RSSModalOpen: false,
serverMessage: []
serverPushMessage: [],
webSocketState: false
};
var reducer = function reducer() {
@@ -79014,6 +79016,11 @@ var reducer = function reducer() {
var action = arguments[1];
switch (action.type) {
case actionTypes.WEBSOCKET_STATE:
console.log("Websocket closed...");
return _extends({}, state, {
webSocketState: action.webSocketState
});
case actionTypes.CHANGE_SELECTION:
console.log("Change Selection", action.selection);
@@ -79079,9 +79086,9 @@ var reducer = function reducer() {
});
case actionTypes.SERVER_MESSAGE:
console.log("New server push message", action.serverMessage);
console.log("New server push message", action.serverPushMessage);
return _extends({}, state, {
serverMessage: action.serverMessage
serverPushMessage: action.serverPushMessage
});
case actionTypes.SET_BUTTON_STATE:
@@ -87013,6 +87020,9 @@ var addTorrentPopup = function (_React$Component) {
};
console.log("Sending magnet link: ", magnetLinkMessage);
ws.send(JSON.stringify(magnetLinkMessage));
_this.setState({ magnetLinkValue: "" });
_this.setState({ storageValue: '' });
console.log("Magnet Link", _this.state.magnetLinkValue);
}, _this.setMagnetLinkValue = function (event) {
_this.setState({ magnetLinkValue: event.target.value });
}, _this.setStorageValue = function (event) {
@@ -117173,6 +117183,8 @@ var fileList = [];
var RSSList = [];
var RSSTorrentList = [];
var serverMessage = [];
var serverPushMessage = [];
var webSocketState = false;
var torrentListRequest = {
messageType: "torrentListRequest"
@@ -117181,7 +117193,7 @@ var torrentListRequest = {
};ws.onmessage = function (evt) {
//When we recieve a message from the websocket
var serverMessage = JSON.parse(evt.data);
//console.log("message", serverMessage.MessageType)
console.log("message", serverMessage.MessageType);
switch (serverMessage.MessageType) {
case "torrentList":
@@ -117275,10 +117287,11 @@ var torrentListRequest = {
PublishDate: serverMessage.Torrents[i].PubDate
});
}
break;
case "serverPushMessage":
console.log("Server push notification receieved", evt.data);
serverMessage = [serverMessage.Type, serverMessage.body];
this.props.newServerMessage(serverMessage);
console.log("SERVER PUSHED MESSAGE", serverMessage);
serverPushMessage = [serverMessage.MessageLevel, serverMessage.Payload];
break;
}
};
@@ -117357,6 +117370,11 @@ var BackendSocket = function (_React$Component) {
this.timerID = setInterval(function () {
return _this2.tick();
}, 2000);
if (ws.readyState === (ws.CONNECTING || ws.OPEN)) {
//checking to make sure we have a websocket connection
webSocketState = true;
this.props.webSocketStateUpdate(webSocketState);
}
}
}, {
key: 'componentWillUnmount',
@@ -117373,8 +117391,17 @@ var BackendSocket = function (_React$Component) {
if (this.props.RSSTorrentList != RSSTorrentList & this.props.RSSModalOpen == true) {
this.props.RSSTorrentList(RSSTorrentList); //pushing the new RSSTorrentList to Redux
}
if (this.props.serverPushMessage != serverPushMessage & serverPushMessage[0] != null) {
console.log("PROPSSERVER", this.props.serverPushMessage, "SERVERPUSH", serverPushMessage);
this.props.newServerMessage(serverPushMessage);
}
ws.send(JSON.stringify(torrentListRequest)); //talking to the server to get the torrent list
if (ws.readyState === ws.CLOSED) {
//if our websocket gets closed inform the user
webSocketState = false;
this.props.webSocketStateUpdate(webSocketState);
}
//console.log("Torrentlist", torrents)
this.props.setButtonState(this.props.selection); //forcing an update to the buttons
this.props.newTorrentList(torrents); //sending the list of torrents to torrentlist.js
@@ -117403,7 +117430,7 @@ var BackendSocket = function (_React$Component) {
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
console.log("Lenght", nextProps.selectionHashes.length, "value", nextProps.selectionHashes);
console.log("Length", nextProps.selectionHashes.length, "value", nextProps.selectionHashes);
if (nextProps.selectionHashes.length === 1) {
//if we have a selection pass it on for the tabs to verify
this.selectionHandler(nextProps.selectionHashes, nextProps.selectedTab);
@@ -117429,7 +117456,8 @@ var mapStateToProps = function mapStateToProps(state) {
selectedTab: state.selectedTab,
selection: state.selection,
RSSModalOpen: state.RSSModalOpen,
RSSTorrentList: state.RSSTorrentList
RSSTorrentList: state.RSSTorrentList,
serverPushMessage: state.serverPushMessage
};
};
@@ -117453,8 +117481,11 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
RSSTorrentList: function RSSTorrentList(_RSSTorrentList) {
return dispatch({ type: actionTypes.RSS_TORRENT_LIST, RSSTorrentList: _RSSTorrentList });
},
newServerMessage: function newServerMessage(serverMessage) {
return dispatch({ type: actionTypes.SERVER_MESSAGE, serverMessage: serverMessage });
newServerMessage: function newServerMessage(serverPushMessage) {
return dispatch({ type: actionTypes.SERVER_MESSAGE, serverPushMessage: serverPushMessage });
},
webSocketStateUpdate: function webSocketStateUpdate(webSocketState) {
return dispatch({ type: actionTypes.WEBSOCKET_STATE, webSocketState: webSocketState });
}
//changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection}),//forcing an update to the buttons
@@ -129694,35 +129725,38 @@ var FileTab = function (_React$Component) {
}
};
_this.sendPriorityRequest = function (priority, sendfileNames) {
_this.sendPriorityRequest = function (priority, selectionHash) {
var filePaths = [];
_this.state.fileSelection.forEach(function (element) {
console.log("element", element);
sendFileNames.push(element.FilePath);
filePaths.push(element.FilePath);
});
var setFilePriority = {
MessageType: "setFilePriority",
Payload: sendFileNames
MessageDetail: priority,
MessageDetailTwo: selectionHash,
Payload: filePaths
};
console.log(JSON.stringify(setFilePriority));
ws.send(JSON.stringify(setFilePriority));
};
_this.setHighPriority = function () {
var priorty = "High";
var priority = "High";
var selectionHash = _this.props.selectionHashes[0]; //getting the first element (should be the only one)
var sendFileNames = [selectionHash, "High"]; // adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
_this.sendPriorityRequest(priority, selectionHash);
};
_this.setNormalPriority = function () {
var priorty = "Normal";
var priority = "Normal";
var selectionHash = _this.props.selectionHashes[0]; //getting the first element (should be the only one)
var sendFileNames = [selectionHash, "Normal"]; // adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
_this.sendPriorityRequest(priority, selectionHash);
};
_this.setCancelPriority = function () {
var priorty = "Cancel";
var priority = "Cancel";
var selectionHash = _this.props.selectionHashes[0]; //getting the first element (should be the only one)
var sendFileNames = [selectionHash, "Cancel"]; // adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
_this.sendPriorityRequest(priority, selectionHash);
};
_this.state = { //rows are stored in redux they are sent over from the server
@@ -129734,7 +129768,6 @@ var FileTab = function (_React$Component) {
selected: []
};
_this.changeColumnOrder = function (columnOrder) {
return _this.setState({ columnOrder: columnOrder });
};
@@ -129813,9 +129846,7 @@ var mapStateToProps = function mapStateToProps(state) {
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
return {
//changeFileSelection: (fileSelection) => dispatch({type: actionTypes.CHANGE_FILE_SELECTION, fileSelection}),
sendSelectionHashes: function sendSelectionHashes(selectionHashes) {
return dispatch({ type: actionTypes.SELECTION_HASHES, selectionHashes: selectionHashes });
}
@@ -130567,24 +130598,28 @@ var Notifications = function (_React$Component) {
function Notifications(props) {
_classCallCheck(this, Notifications);
var _this = _possibleConstructorReturn(this, (Notifications.__proto__ || Object.getPrototypeOf(Notifications)).call(this, props));
_this.state = { serverMessage: ["info", "A props message"] };
return _this;
return _possibleConstructorReturn(this, (Notifications.__proto__ || Object.getPrototypeOf(Notifications)).call(this, props));
}
_createClass(Notifications, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextprops) {
if (nextprops.serverMessage != this.state.serverMessage) {
(0, _reactToastify.toast)(this.state.serverMessage[1]);
if (nextprops.serverPushMessage != this.props.serverPushMessage) {
(0, _reactToastify.toast)(nextprops.serverPushMessage[1], {
type: nextprops.serverPushMessage[0]
});
console.log("Server Push Message", nextprops.serverPushMessage);
}
if (nextprops.webSocketState != this.props.webSocketState) {
if (nextprops.webSocketState == true) {
_reactToastify.toast.success("Websocket Connection Open!");
} else {
(0, _reactToastify.toast)("Websocket Connection Closed!", {
type: "error",
autoClose: false
});
}
}
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
(0, _reactToastify.toast)("Testing toast custom settings");
}
}, {
key: 'render',
@@ -130592,7 +130627,7 @@ var Notifications = function (_React$Component) {
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(_reactToastify.ToastContainer, { type: this.state.serverMessage[0], position: _reactToastify.toast.POSITION.TOP_RIGHT, autoClose: 8000 })
_react2.default.createElement(_reactToastify.ToastContainer, { position: _reactToastify.toast.POSITION.TOP_RIGHT, autoClose: 8000 })
);
}
}]);
@@ -130602,7 +130637,8 @@ var Notifications = function (_React$Component) {
var mapStateToProps = function mapStateToProps(state) {
return {
//serverMessage: state.serverMessage,
serverPushMessage: state.serverPushMessage,
webSocketState: state.webSocketState
};
};

View File

@@ -5,12 +5,16 @@ import (
"path/filepath"
"github.com/asdine/storm"
"github.com/gorilla/websocket"
"github.com/sirupsen/logrus"
)
//Logger is the global Logger that is used in all packages
var Logger *logrus.Logger
//Conn is the global websocket connection used to push server notification messages
var Conn *websocket.Conn
//RSSFeedStore stores all of our RSS feeds in a slice of gofeed.Feed
type RSSFeedStore struct {
ID int `storm:"id,unique"` //storm requires unique ID (will be 1) to save although there will only be one of these