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({
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
Bio (Markdown version)
|
|
|
|
*/
|
2015-04-27 09:55:29 +09:00
|
|
|
bio: {
|
2015-04-25 13:03:04 +09:00
|
|
|
type: String,
|
2015-04-27 09:55:29 +09:00
|
|
|
optional: true,
|
2015-05-06 12:56:59 +09:00
|
|
|
editableBy: ["member", "admin"],
|
|
|
|
autoform: {
|
|
|
|
rows: 5
|
|
|
|
}
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
Total comment count
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The name displayed throughout the app. Can contain spaces and special characters, doesn't need to be unique
|
|
|
|
*/
|
|
|
|
displayName: {
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
An array containing comment downvotes
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
An array containing posts downvotes
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The user's email. Modifiable. // TODO: enforce uniqueness and use for login
|
|
|
|
*/
|
2015-04-27 09:55:29 +09:00
|
|
|
email: {
|
|
|
|
type: String,
|
2015-04-25 13:03:04 +09:00
|
|
|
optional: true,
|
2015-05-06 12:56:59 +09:00
|
|
|
required: true,
|
2015-04-28 17:15:53 +09:00
|
|
|
editableBy: ["member", "admin"]
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
A hash of the email, used for Gravatar // TODO: change this when email changes
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The HTML version of the bio field
|
|
|
|
*/
|
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
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
A count of the user's remaining invites
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
A count of how many users have been invited by the user
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
Whether the user is invited or not
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The user's karma
|
|
|
|
*/
|
2015-04-27 09:55:29 +09:00
|
|
|
karma: {
|
|
|
|
type: Number,
|
2015-05-11 11:09:26 +09:00
|
|
|
decimal: true,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true
|
2015-04-25 13:03:04 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
Total post count
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
A blackbox modifiable object to store the user's settings
|
|
|
|
*/
|
2015-05-11 11:09:26 +09:00
|
|
|
settings: {
|
|
|
|
type: Object,
|
|
|
|
optional: true,
|
|
|
|
editableBy: ["member", "admin"],
|
|
|
|
blackbox: true
|
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The user's profile URL slug // TODO: change this when displayName changes
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The user's Twitter username
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
An array containing comments upvotes
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
An array containing posts upvotes
|
|
|
|
*/
|
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-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
A link to the user's homepage
|
|
|
|
*/
|
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}
|
|
|
|
*/
|
2015-05-11 12:15:10 +09:00
|
|
|
Users.schema = new SimpleSchema({
|
2015-04-27 09:55:29 +09:00
|
|
|
_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-05-11 12:15:10 +09:00
|
|
|
Users.schema.internationalize();
|
2015-04-27 17:15:16 +09:00
|
|
|
|
2015-04-25 13:03:04 +09:00
|
|
|
/**
|
|
|
|
* Attach schema to Meteor.users collection
|
|
|
|
*/
|
2015-05-11 12:15:10 +09:00
|
|
|
Users.attachSchema(Users.schema);
|
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)
|
2015-05-03 13:09:57 -04:00
|
|
|
});
|