Skip to content

Commit

Permalink
Merge pull request #278 from rigrassm/master
Browse files Browse the repository at this point in the history
Add pushbullet channels; Add auto-migrate database feature; #218
  • Loading branch information
mikhailbot committed Feb 27, 2016
2 parents f77effe + 7d4ea07 commit 986ac3d
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 35 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ lokenx:couchpotatowrapper
lokenx:sickragewrapper
lokenx:sonarrwrapper
meteorhacks:npm
davidyaha:collection2-migrations
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
davidyaha:[email protected]
dburles:[email protected]
[email protected]
[email protected]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* [CouchPotato](https://couchpota.to/) integration for automatic downloads of Movies
* [SickRage](https://github.com/SickRage/SickRage) and [Sonarr](https://sonarr.tv/) integrationed for automatic TV Series downloads
* [Pushbullet](https://www.pushbullet.com/), [Pushover](https://pushover.net/) and [Slack](https://slack.com/) notifications to keep up to date with requests
* You can now push notifications to a custom channel to easily notify others whenever new content is requested and added. Users only need to
subscribe to the channel to start recieving notifications. Visit the [Channel Creation Page](https://www.pushbullet.com/my-channel) to learn more about how to create and distribute your own channel.

## Installation
Installation is straightforward: please update to Meteor 1.2.1, clone the repo, `cd` into the directory, and run `meteor`. For Windows users check out this [blog post](http://8bits.ca/posts/2015/installing-plex-requests-on-windows/) for installation instructions using Git!
Expand Down
6 changes: 5 additions & 1 deletion client/templates/admin/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,15 @@ <h1>Admin</h1>
{{> afQuickField name='pushbulletAPI' size="40"}}
<p class="text-muted">Enter your API from Pushbullet. It can be found in Pushbullet Settings -> Access Token.</p>
<br>
{{> afQuickField name='pushbulletChannel' size="40"}}
<p class="text-muted"> Push Notifications to a channel. Must be the owner of the channel, click <a href="https://www.pushbullet.com/my-channel"> here </a> to create a new channel.</p>
<br>

<p><button class="btn btn-secondary-outline" id="pushbulletTest">Test Pushbullet</button></p>
<p class="text-muted">Test your Pushbullet settings. Remember to save your settings first!</p>
<br>
{{> afQuickField name='pushoverENABLED'}}
<p class="text-muted">Enabled Pushover to receive alerts.</p>
<p class="text-muted">Enabled Pushover to receive alerts.</p>
<br>
{{> afQuickField name='pushoverAPI' size="40"}}
<p class="text-muted">Enter your API from Pushover.</p>
Expand Down
32 changes: 25 additions & 7 deletions lib/collections/collections.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Define Mongodb Collections

Movies = new Mongo.Collection("movies");
TV = new Mongo.Collection("tv");
Settings = new Mongo.Collection("settings");

// DB Schemas
// Movies Collection Schema

Movies.attachSchema(new SimpleSchema (
var movies = new SimpleSchema (
{
title: {
type: String,
Expand Down Expand Up @@ -54,9 +56,11 @@ Movies.attachSchema(new SimpleSchema (
label: "Reported issues",
optional: true
}
}));
});

// TV Collection Schema

TV.attachSchema(new SimpleSchema (
var tv = new SimpleSchema (
{
title: {
type: String,
Expand Down Expand Up @@ -115,9 +119,11 @@ TV.attachSchema(new SimpleSchema (
label: "Whether to download all or new episodes only",
optional: true
}
}));
});

Settings.attachSchema(new SimpleSchema ({
// Settings Collection Schema

var settings = new SimpleSchema ({
/**
* GENERAL
*/
Expand Down Expand Up @@ -321,6 +327,12 @@ Settings.attachSchema(new SimpleSchema ({
defaultValue: "abcd1234",
optional: true
},
pushbulletChannel: {
type: String,
label: "Pushbullet Channel Tag",
defaultValue: "channel-tag",
optional: true
},
pushbulletENABLED: {
type: Boolean,
label: "Enable Pushbullet notifications",
Expand Down Expand Up @@ -377,4 +389,10 @@ Settings.attachSchema(new SimpleSchema ({
defaultValue: false,
optional: true
}
}));
});

// Set Collection Schemas

TV.attachSchema(tv);
Movies.attachSchema(movies);
Settings.attachSchema(settings);
2 changes: 1 addition & 1 deletion server/methods/admin/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Meteor.methods({
return "master";
},
getVersion: function () {
return "1.6.2";
return "1.7.0";
},
checkForUpdate : function () {
var branch = Meteor.call('getBranch');
Expand Down
75 changes: 50 additions & 25 deletions server/methods/notifications/pushbulletNotification.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,53 @@
Meteor.methods({
"sendPushbulletNotification": function (settings, title, body) {
var access_token = settings.pushbulletAPI;
var pushbullet_url = 'https://api.pushbullet.com/v2/pushes';
"sendPushbulletNotification": function(settings, title, body) {

try {
HTTP.post(
pushbullet_url,
{
headers: {
'Access-Token': access_token
},
params: {
type: 'note',
title: title,
body: body
},
timeout: 4000
}
);
return true;
} catch (error) {
var err = error.response.data.error.message;
logger.error("Pushbullet notification error: " + err);
throw err;
}
//////// Function Constants

var access_token = settings.pushbulletAPI;
var channel_tag = settings.pushbulletChannel;
var pushbullet_url = 'https://api.pushbullet.com/v2/pushes';

//////// Create JSON object of http.post Parameters
if(typeof channel_tag === 'undefined' ) {
var payload = {
headers: {
'Access-Token': access_token
},
params: {
type: 'note',
title: title,
body: body
},
timeout: 4000
};
logger.debug('Empty Channel');
} else {
var payload = {
headers: {
'Access-Token': access_token
},
params: {
type: 'note',
title: title,
body: body,
channel_tag: channel_tag
},
timeout: 4000
};
logger.debug('channel_tag: ' + channel_tag);
}

////// Attempt to send notification with HTTP.post()

try {
HTTP.post(pushbullet_url, payload);
return true;
}

catch (error) {
var err = error.response.data.error.message;
logger.error("Pushbullet notification error: " + err);
throw err;
}
}
});
});
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.2
1.7.0

0 comments on commit 986ac3d

Please sign in to comment.