Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ npm-container
nemo64:bootstrap
atoy40:accounts-cas

raix:rssfeed
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ [email protected]
[email protected]
[email protected]
percolatestudio:[email protected]
raix:[email protected]
[email protected]
[email protected]
[email protected]
Expand Down
2 changes: 1 addition & 1 deletion client/views/posts/post_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Template.postPage.helpers({
} else if (post.status == "responded") {
return {
title: "Responded",
description: "This petition has recieved an official response."
description: "This petition has received an official response."
};
} else {
if (post.votes >= post.minimumVotes) {
Expand Down
45 changes: 41 additions & 4 deletions collections/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ var validatePost = function validatePost (postAttributes) {
};

Meteor.methods({
updateRSS: function() {
RssFeed.publish('petitions', function(query) {
var self = this; // need to store a reference to this so we can add items in the forEach loop later

self.setValue('title', self.cdata('RPI Petitions'));
self.setValue('description', self.cdata('Create and sign petitions. Receive official responses from the Student Senate.'));
self.setValue('link', 'https://petitions.union.rpi.edu');
self.setValue('lastBuildDate', new Date());
self.setValue('pubDate', new Date());
self.setValue('ttl', 60);

Posts.find(query ? query : {}, {sort: {submitted: -1}, limit: 20}).forEach(function(post) {
var info = undefined;
if (post.response) {
info = "Received a Response";
} else if (post.votes >= post.minimumVotes) {
info = "Reached Vote Threshold";
}

date = new Date();
date.setTime(post.submitted);

self.addItem({
title: (info === undefined) ? post.title : (post.title + " (" + post.info + ")"),
description: post.description,
link: "https://petitions.union.rpi.edu/petitions/" + post._id,
pubDate: date
});
});
});
},

post: function(postAttributes) {

validatePost(postAttributes);
Expand All @@ -70,6 +102,7 @@ Meteor.methods({
var postId = Posts.insert(post);

Singleton.update({}, {$inc: {postsCount: 1}});
Metor.call('updateRSS');

return postId;
},
Expand Down Expand Up @@ -104,6 +137,7 @@ Meteor.methods({
"\n\nThanks, \nRPI Web Technologies Group"
});
}
Meteor.call('updateRSS');
}

},
Expand All @@ -124,6 +158,7 @@ Meteor.methods({
$pull: {upvoters: user._id},
$inc: {votes: -1}
});
Meteor.call('updateRSS');
}

},
Expand Down Expand Up @@ -198,13 +233,15 @@ Meteor.methods({
from: "[email protected]",
subject: "PawPrints - A petition you signed has received a response",
text: "Hello, \n\n" +
"Petition \"" + post.title + "\" by " + oldPost.author + " has recieved a response: \n\n" +
"Petition \"" + post.title + "\" by " + oldPost.author + " has received a response: \n\n" +
Meteor.settings.public.root_url + "/petitions/" + oldPost._id +
"\n\nThanks, \nRIT Student Government"
});
}

Meteor.call('updateRSS');
},

delete: function (postId) {

var user = Meteor.user();
Expand All @@ -215,6 +252,6 @@ Meteor.methods({
Posts.remove(postId);

Singleton.update({}, {$inc: {postsCount: -1}});

Meteor.call('updateRSS');
}
});
});
1 change: 1 addition & 0 deletions server/startup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Meteor.startup(function () {
Singleton.update({}, {$set: { version: "v1.2.2.3" }});
Meteor.call('updateRSS');
process.env.MAIL_URL = Meteor.settings.MAIL_URL;
});