2015-04-25 13:03:04 +09:00
|
|
|
/**
|
2015-04-27 09:55:29 +09:00
|
|
|
* Vote schema
|
2015-04-25 13:03:04 +09:00
|
|
|
* @type {SimpleSchema}
|
|
|
|
*/
|
2015-04-27 09:55:29 +09:00
|
|
|
Telescope.schemas.votes = new SimpleSchema({
|
|
|
|
itemId: {
|
|
|
|
type: String
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
power: {
|
|
|
|
type: Number,
|
|
|
|
optional: true
|
|
|
|
},
|
|
|
|
votedAt: {
|
|
|
|
type: Date,
|
|
|
|
optional: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User Data schema
|
|
|
|
* @type {SimpleSchema}
|
|
|
|
*/
|
|
|
|
Telescope.schemas.userData = new SimpleSchema({
|
|
|
|
bio: {
|
2015-04-25 13:03:04 +09:00
|
|
|
type: String,
|
2015-04-27 09:55:29 +09:00
|
|
|
optional: true,
|
2015-04-28 17:15:53 +09:00
|
|
|
editableBy: ["member", "admin"]
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
commentCount: {
|
|
|
|
type: Number,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
displayName: {
|
2015-04-25 13:03:04 +09:00
|
|
|
type: String,
|
2015-04-27 09:55:29 +09:00
|
|
|
regEx: /^[a-zA-Z-]{2,25}$/,
|
|
|
|
optional: true,
|
2015-04-28 17:15:53 +09:00
|
|
|
editableBy: ["member", "admin"]
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
downvotedComments: {
|
|
|
|
type: [Telescope.schemas.votes],
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
downvotedPosts: {
|
|
|
|
type: [Telescope.schemas.votes],
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
email: {
|
|
|
|
type: String,
|
|
|
|
regEx: /^[a-zA-Z]{2,25}$/,
|
2015-04-25 13:03:04 +09:00
|
|
|
optional: true,
|
2015-04-28 17:15:53 +09:00
|
|
|
editableBy: ["member", "admin"]
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
emailHash: {
|
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
htmlBio: {
|
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-27 09:55:29 +09:00
|
|
|
},
|
|
|
|
inviteCount: {
|
|
|
|
type: Number,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
invitedCount: {
|
|
|
|
type: Number,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
isInvited: {
|
|
|
|
type: Boolean,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
karma: {
|
|
|
|
type: Number,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
postCount: {
|
|
|
|
type: Number,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
slug: {
|
2015-04-25 13:03:04 +09:00
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
twitterUsername: {
|
2015-04-25 13:03:04 +09:00
|
|
|
type: String,
|
|
|
|
optional: true,
|
2015-04-28 17:15:53 +09:00
|
|
|
editableBy: ["member", "admin"]
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
upvotedComments: {
|
|
|
|
type: [Telescope.schemas.votes],
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
upvotedPosts: {
|
|
|
|
type: [Telescope.schemas.votes],
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
website: {
|
|
|
|
type: String,
|
|
|
|
regEx: SimpleSchema.RegEx.Url,
|
2015-04-25 13:03:04 +09:00
|
|
|
optional: true,
|
2015-04-28 17:15:53 +09:00
|
|
|
editableBy: ["member", "admin"]
|
2015-04-27 09:55:29 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Users schema
|
|
|
|
* @type {SimpleSchema}
|
|
|
|
*/
|
|
|
|
Telescope.schemas.users = new SimpleSchema({
|
|
|
|
_id: {
|
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
username: {
|
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
regEx: /^[a-z0-9A-Z_]{3,15}$/
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
emails: {
|
2015-04-27 17:15:16 +09:00
|
|
|
type: [Object]
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
"emails.$.address": {
|
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
regEx: SimpleSchema.RegEx.Email
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
"emails.$.verified": {
|
2015-04-27 17:15:16 +09:00
|
|
|
type: Boolean
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
createdAt: {
|
2015-04-27 17:15:16 +09:00
|
|
|
type: Date
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
isAdmin: {
|
|
|
|
type: Boolean,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
profile: {
|
|
|
|
type: Object,
|
2015-04-25 13:03:04 +09:00
|
|
|
optional: true,
|
2015-04-27 17:15:16 +09:00
|
|
|
blackbox: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-04-27 09:55:29 +09:00
|
|
|
telescope: { // telescope-specific data
|
|
|
|
type: Telescope.schemas.userData,
|
|
|
|
optional: true
|
|
|
|
},
|
|
|
|
services: {
|
|
|
|
type: Object,
|
2015-04-25 13:03:04 +09:00
|
|
|
optional: true,
|
2015-04-27 17:15:16 +09:00
|
|
|
blackbox: true
|
2015-04-25 13:03:04 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-04-27 17:15:16 +09:00
|
|
|
Telescope.schemas.users.internationalize();
|
|
|
|
|
2015-04-25 13:03:04 +09:00
|
|
|
/**
|
|
|
|
* Attach schema to Meteor.users collection
|
|
|
|
*/
|
2015-04-27 09:55:29 +09:00
|
|
|
Meteor.users.attachSchema(Telescope.schemas.users);
|
2015-04-25 13:03:04 +09:00
|
|
|
|
2015-04-22 07:50:11 +09:00
|
|
|
/**
|
|
|
|
* Users collection permissions
|
|
|
|
*/
|
|
|
|
|
|
|
|
Users.allow({
|
2015-04-28 17:15:53 +09:00
|
|
|
update: _.partial(Telescope.allowCheck, Meteor.users),
|
|
|
|
remove: _.partial(Telescope.allowCheck, Meteor.users)
|
|
|
|
});
|