Add message from service administrator

This commit is contained in:
nztqa 2017-09-28 16:57:04 +09:00
parent eb945f26a3
commit aa1876f94c
10 changed files with 135 additions and 4 deletions

36
models/notices.js Normal file
View file

@ -0,0 +1,36 @@
Notices = new Mongo.Collection('notices');
Notices.attachSchema(new SimpleSchema({
enabled: {
type: Boolean,
defaultValue: false,
},
title: {
type: String,
optional: true,
},
body: {
type: String,
optional: true,
},
sort: {
type: Number,
decimal: true,
},
}));
Notices.allow({
update(userId) {
const user = Users.findOne(userId);
return user && user.isAdmin;
},
});
if (Meteor.isServer) {
Meteor.startup(() => {
const notices = Notices.findOne({});
if(!notices){
Notices.insert({enabled: false, sort: 0});
}
});
}