Added Patreon notification badge for new patreon posts

This commit is contained in:
Stefan Zermatten
2019-02-21 11:51:46 +02:00
parent 2253672f43
commit 3fbb006783
8 changed files with 80 additions and 17 deletions

View File

@@ -0,0 +1,26 @@
PatreonPosts = new Mongo.Collection("patreonPosts");
Schemas.PatreonPosts = new SimpleSchema({
link: {
type: String,
},
dateAdded: {
type: Date,
autoValue(){
return new Date();
},
},
});
PatreonPosts.attachSchema(Schemas.PatreonPosts);
PatreonPosts.allow({
insert: function(userId, doc) {
var user = Meteor.users.findOne(userId);
if (user) return _.contains(user.roles, "admin");
},
remove: function(userId, doc) {
var user = Meteor.users.findOne(userId);
if (user) return _.contains(user.roles, "admin");
},
});

View File

@@ -70,6 +70,10 @@ Schemas.User = new SimpleSchema({
index: 1,
optional: true,
},
lastPatreonPostClicked: {
type: String,
optional: true,
},
});
Meteor.users.attachSchema(Schemas.User);
@@ -107,3 +111,11 @@ if (Meteor.isServer) Meteor.methods({
Meteor.users.update(this.userId, {$set: {apiKey}});
},
});
Meteor.methods({
clickPatreonPost(link) {
Meteor.users.update(this.userId, {$set: {
lastPatreonPostClicked: link
}});
},
});