mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
use a more generic prefix (__) for users settings and adapt Users.methods.setSetting
This commit is contained in:
parent
400b4d8c72
commit
db5605bd2e
36 changed files with 187 additions and 187 deletions
|
@ -21,7 +21,7 @@ class UsersMenu extends Component {
|
|||
<div>{Users.getDisplayName(currentUser)}</div>
|
||||
</Dropdown.Toggle>
|
||||
<Dropdown.Menu>
|
||||
<LinkContainer to={`/users/${currentUser.nova_slug}`}>
|
||||
<LinkContainer to={`/users/${currentUser.__slug}`}>
|
||||
<MenuItem className="dropdown-item" eventKey="1"><FormattedMessage id="users.profile"/></MenuItem>
|
||||
</LinkContainer>
|
||||
<LinkContainer to={`/account`}>
|
||||
|
|
|
@ -16,12 +16,12 @@ const UsersProfile = (props) => {
|
|||
|
||||
return (
|
||||
<div className="page users-profile">
|
||||
<Telescope.components.HeadTags url={Users.getProfileUrl(user, true)} title={Users.getDisplayName(user)} description={user.nova_bio} />
|
||||
<Telescope.components.HeadTags url={Users.getProfileUrl(user, true)} title={Users.getDisplayName(user)} description={user.__bio} />
|
||||
<h2 className="page-title">{Users.getDisplayName(user)}</h2>
|
||||
<p>{user.nova_bio}</p>
|
||||
<p>{user.__bio}</p>
|
||||
<ul>
|
||||
{twitterName ? <li><a href={"http://twitter.com/" + twitterName}>@{twitterName}</a></li> : null }
|
||||
{user.nova_website ? <li><a href={user.nova_website}>{user.nova_website}</a></li> : null }
|
||||
{user.__website ? <li><a href={user.__website}>{user.__website}</a></li> : null }
|
||||
<Telescope.components.CanDo document={user} action="users.edit">
|
||||
<li><Link to={Users.getEditUrl(user)}><FormattedMessage id="users.edit_account"/></Link></li>
|
||||
</Telescope.components.CanDo>
|
||||
|
|
|
@ -35,41 +35,41 @@ const AppContainerWithData = graphql(gql`
|
|||
username
|
||||
createdAt
|
||||
isAdmin
|
||||
nova_bio
|
||||
nova_commentCount
|
||||
nova_displayName
|
||||
nova_downvotedComments {
|
||||
__bio
|
||||
__commentCount
|
||||
__displayName
|
||||
__downvotedComments {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_downvotedPosts {
|
||||
__downvotedPosts {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_email
|
||||
nova_emailHash
|
||||
nova_htmlBio
|
||||
nova_karma
|
||||
nova_postCount
|
||||
nova_slug
|
||||
nova_twitterUsername
|
||||
nova_upvotedComments {
|
||||
__email
|
||||
__emailHash
|
||||
__htmlBio
|
||||
__karma
|
||||
__postCount
|
||||
__slug
|
||||
__twitterUsername
|
||||
__upvotedComments {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_upvotedPosts {
|
||||
__upvotedPosts {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_website
|
||||
nova_groups
|
||||
nova_notifications_users
|
||||
nova_notifications_posts
|
||||
nova_newsletter_subscribeToNewsletter
|
||||
__website
|
||||
__groups
|
||||
__notifications_users
|
||||
__notifications_posts
|
||||
__newsletter_subscribeToNewsletter
|
||||
}
|
||||
}
|
||||
`, {
|
||||
|
|
|
@ -41,8 +41,8 @@ const CommentsListContainerWithData = graphql(gql`
|
|||
postedAt
|
||||
user {
|
||||
_id
|
||||
nova_slug
|
||||
nova_emailHash # used for the avatar
|
||||
__slug
|
||||
__emailHash # used for the avatar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ function CommentsNewOperations (comment) {
|
|||
|
||||
// increment comment count
|
||||
Users.update({_id: userId}, {
|
||||
$inc: {'nova_commentCount': 1}
|
||||
$inc: {'__commentCount': 1}
|
||||
});
|
||||
|
||||
// update post
|
||||
|
|
|
@ -8,7 +8,7 @@ Users.addField([
|
|||
Count of the user's comments
|
||||
*/
|
||||
{
|
||||
fieldName: "nova_commentCount",
|
||||
fieldName: "__commentCount",
|
||||
fieldSchema: {
|
||||
type: Number,
|
||||
optional: true,
|
||||
|
|
|
@ -108,7 +108,7 @@ Meteor.methods({
|
|||
|
||||
// decrement user comment count and remove comment ID from user
|
||||
Users.update({_id: comment.userId}, {
|
||||
$inc: {'nova_commentCount': -1}
|
||||
$inc: {'__commentCount': -1}
|
||||
});
|
||||
|
||||
// note: should we also decrease user's comment karma ?
|
||||
|
|
|
@ -18,8 +18,8 @@ Comments.graphQLQueries = {
|
|||
postedAt
|
||||
user {
|
||||
_id
|
||||
nova_slug
|
||||
nova_emailHash # used for the avatar
|
||||
__slug
|
||||
__emailHash # used for the avatar
|
||||
}
|
||||
`
|
||||
}
|
||||
|
|
|
@ -34,16 +34,16 @@ function updateUser (item, user, collection, operation) {
|
|||
|
||||
switch (operation) {
|
||||
case "upvote":
|
||||
update.$addToSet = {'nova_upvotedPosts': vote};
|
||||
update.$addToSet = {'__upvotedPosts': vote};
|
||||
break;
|
||||
case "downvote":
|
||||
update.$addToSet = {'nova_downvotedPosts': vote};
|
||||
update.$addToSet = {'__downvotedPosts': vote};
|
||||
break;
|
||||
case "cancelUpvote":
|
||||
update.$pull = {'nova_upvotedPosts': {itemId: item._id}};
|
||||
update.$pull = {'__upvotedPosts': {itemId: item._id}};
|
||||
break;
|
||||
case "cancelDownvote":
|
||||
update.$pull = {'nova_downvotedPosts': {itemId: item._id}};
|
||||
update.$pull = {'__downvotedPosts': {itemId: item._id}};
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ function updateKarma (item, user, collection, operation) {
|
|||
|
||||
// only update karma is the operation isn't done by the item's author
|
||||
if (item.userId !== user._id) {
|
||||
Users.update({_id: item.userId}, {$inc: {"nova_karma": karmaAmount}});
|
||||
Users.update({_id: item.userId}, {$inc: {"__karma": karmaAmount}});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import Comments from "meteor/nova:comments";
|
|||
import Users from 'meteor/nova:users';
|
||||
|
||||
Users.addField({
|
||||
fieldName: 'nova_isDummy',
|
||||
fieldName: '__isDummy',
|
||||
fieldSchema: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
|
@ -40,13 +40,13 @@ Comments.addField({
|
|||
});
|
||||
|
||||
/**
|
||||
* @summary Copy over profile.isDummy to nova_isDummy on user creation
|
||||
* @summary Copy over profile.isDummy to __isDummy on user creation
|
||||
* @param {Object} user – the user object being iterated on and returned
|
||||
* @param {Object} options – user options
|
||||
*/
|
||||
function copyDummyProperty (user, options) {
|
||||
if (typeof user.profile.isDummy !== "undefined") {
|
||||
user.nova_isDummy = user.profile.isDummy;
|
||||
user.__isDummy = user.profile.isDummy;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ var createPost = function (slug, postedAt, username, thumbnail) {
|
|||
};
|
||||
|
||||
if (typeof thumbnail !== "undefined")
|
||||
post.thumbnailUrl = "/packages/nova_getting-started/content/images/" + thumbnail;
|
||||
post.thumbnailUrl = "/packages/nova-getting-started/content/images/" + thumbnail;
|
||||
|
||||
newMutation({
|
||||
collection: Posts,
|
||||
|
|
|
@ -61,17 +61,17 @@ Telescope.strings.en = {
|
|||
"users.edit_success": "User “{name}” edited",
|
||||
"users.log_in": "Log In",
|
||||
"users.log_out": "Log Out",
|
||||
"users.nova_bio": "Bio",
|
||||
"users.nova_displayName": "Display Name",
|
||||
"users.nova_email": "Email",
|
||||
"users.nova_twitterUsername": "Twitter Username",
|
||||
"users.nova_website": "Website",
|
||||
"users.nova_groups": "Groups",
|
||||
"users.nova_avatar": "Avatar",
|
||||
"users.__bio": "Bio",
|
||||
"users.__displayName": "Display Name",
|
||||
"users.__email": "Email",
|
||||
"users.__twitterUsername": "Twitter Username",
|
||||
"users.__website": "Website",
|
||||
"users.__groups": "Groups",
|
||||
"users.__avatar": "Avatar",
|
||||
"users.notifications": "Notifications",
|
||||
"users.nova_notifications_users": "New Users Notifications",
|
||||
"users.nova_notifications_posts": "New Posts Notifications",
|
||||
"users.nova_newsletter_subscribeToNewsletter": "Subscribe to newsletter",
|
||||
"users.__notifications_users": "New Users Notifications",
|
||||
"users.__notifications_posts": "New Posts Notifications",
|
||||
"users.__newsletter_subscribeToNewsletter": "Subscribe to newsletter",
|
||||
"users.admin": "Admin",
|
||||
"users.isAdmin": "Admin",
|
||||
"users.posts": "Posts",
|
||||
|
|
|
@ -299,7 +299,7 @@ Telescope.utils.unflatten = function( array, idProperty, parentIdProperty, paren
|
|||
|
||||
Telescope.utils.getFieldLabel = (fieldName, collection) => {
|
||||
const label = collection.simpleSchema()._schema[fieldName].label;
|
||||
const nameWithSpaces = Telescope.utils.camelToSpaces(fieldName.replace("nova_", ""));
|
||||
const nameWithSpaces = Telescope.utils.camelToSpaces(fieldName.replace("__", ""));
|
||||
return label || nameWithSpaces;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Posts.addField({
|
|||
|
||||
Users.addField([
|
||||
{
|
||||
fieldName: 'nova_newsletter_subscribeToNewsletter',
|
||||
fieldName: '__newsletter_subscribeToNewsletter',
|
||||
fieldSchema: {
|
||||
label: 'Subscribe to newsletter',
|
||||
type: Boolean,
|
||||
|
|
|
@ -13,7 +13,7 @@ const canEdit = Users.canEdit;
|
|||
// Add notifications options to user profile settings
|
||||
Users.addField([
|
||||
{
|
||||
fieldName: 'nova_notifications_users',
|
||||
fieldName: '__notifications_users',
|
||||
fieldSchema: {
|
||||
label: 'New users',
|
||||
type: Boolean,
|
||||
|
@ -26,7 +26,7 @@ Users.addField([
|
|||
}
|
||||
},
|
||||
{
|
||||
fieldName: 'nova_notifications_posts',
|
||||
fieldName: '__notifications_posts',
|
||||
fieldSchema: {
|
||||
label: 'New posts',
|
||||
type: Boolean,
|
||||
|
@ -43,7 +43,7 @@ Users.addField([
|
|||
if (typeof Comments !== "undefined") {
|
||||
Users.addField([
|
||||
{
|
||||
fieldName: 'nova_notifications_comments',
|
||||
fieldName: '__notifications_comments',
|
||||
fieldSchema: {
|
||||
label: 'Comments on my posts',
|
||||
type: Boolean,
|
||||
|
@ -55,7 +55,7 @@ if (typeof Comments !== "undefined") {
|
|||
}
|
||||
},
|
||||
{
|
||||
fieldName: 'nova_notifications_replies',
|
||||
fieldName: '__notifications_replies',
|
||||
fieldSchema: {
|
||||
label: 'Replies to my comments',
|
||||
type: Boolean,
|
||||
|
|
|
@ -233,7 +233,7 @@ Telescope.callbacks.add("posts.new.sync", PostsNewSetFuture);
|
|||
*/
|
||||
function PostsNewIncrementPostCount (post) {
|
||||
var userId = post.userId;
|
||||
Users.update({_id: userId}, {$inc: {"nova_postCount": 1}});
|
||||
Users.update({_id: userId}, {$inc: {"__postCount": 1}});
|
||||
}
|
||||
Telescope.callbacks.add("posts.new.async", PostsNewIncrementPostCount);
|
||||
|
||||
|
@ -256,7 +256,7 @@ function PostsNewNotifications (post) {
|
|||
if (typeof Telescope.notifications !== "undefined") {
|
||||
|
||||
var adminIds = _.pluck(Users.adminUsers({fields: {_id:1}}), '_id');
|
||||
var notifiedUserIds = _.pluck(Users.find({'nova_notifications_posts': true}, {fields: {_id:1}}).fetch(), '_id');
|
||||
var notifiedUserIds = _.pluck(Users.find({'__notifications_posts': true}, {fields: {_id:1}}).fetch(), '_id');
|
||||
var notificationData = {
|
||||
post: _.pick(post, '_id', 'userId', 'title', 'url', 'slug')
|
||||
};
|
||||
|
@ -380,7 +380,7 @@ Telescope.callbacks.add("posts.remove.validate", PostsRemoveValidation);
|
|||
// ------------------------------------- posts.remove.sync -------------------------------- //
|
||||
|
||||
function PostsRemoveOperations (post) {
|
||||
Users.update({_id: post.userId}, {$inc: {"nova_postCount": -1}});
|
||||
Users.update({_id: post.userId}, {$inc: {"__postCount": -1}});
|
||||
}
|
||||
Telescope.callbacks.add("posts.remove.sync", PostsRemoveOperations);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Users.addField([
|
|||
Count of the user's posts
|
||||
*/
|
||||
{
|
||||
fieldName: "nova_postCount",
|
||||
fieldName: "__postCount",
|
||||
fieldSchema: {
|
||||
type: Number,
|
||||
optional: true,
|
||||
|
|
|
@ -235,7 +235,7 @@ Meteor.methods({
|
|||
}
|
||||
|
||||
// decrement post count
|
||||
Users.update({_id: post.userId}, {$inc: {"nova_postCount": -1}});
|
||||
Users.update({_id: post.userId}, {$inc: {"__postCount": -1}});
|
||||
|
||||
// delete post
|
||||
Posts.remove(postId);
|
||||
|
|
|
@ -26,9 +26,9 @@ Posts.graphQLQueries = {
|
|||
commentCount
|
||||
commenters {
|
||||
_id
|
||||
nova_displayName
|
||||
nova_emailHash
|
||||
nova_slug
|
||||
__displayName
|
||||
__emailHash
|
||||
__slug
|
||||
}
|
||||
upvoters {
|
||||
_id
|
||||
|
@ -42,9 +42,9 @@ Posts.graphQLQueries = {
|
|||
clickCount # should be asked only for admins?
|
||||
user {
|
||||
_id
|
||||
nova_displayName
|
||||
nova_emailHash
|
||||
nova_slug
|
||||
__displayName
|
||||
__emailHash
|
||||
__slug
|
||||
}
|
||||
`,
|
||||
single: `
|
||||
|
@ -67,9 +67,9 @@ Posts.graphQLQueries = {
|
|||
commentCount
|
||||
commenters {
|
||||
_id
|
||||
nova_displayName
|
||||
nova_emailHash
|
||||
nova_slug
|
||||
__displayName
|
||||
__emailHash
|
||||
__slug
|
||||
}
|
||||
upvoters {
|
||||
_id
|
||||
|
@ -83,9 +83,9 @@ Posts.graphQLQueries = {
|
|||
clickCount # should be asked only for admins?
|
||||
user {
|
||||
_id
|
||||
nova_displayName
|
||||
nova_emailHash
|
||||
nova_slug
|
||||
__displayName
|
||||
__emailHash
|
||||
__slug
|
||||
}
|
||||
`
|
||||
};
|
|
@ -116,7 +116,7 @@ Posts.views.add("userPosts", function (terms) {
|
|||
*/
|
||||
Posts.views.add("userUpvotedPosts", function (terms) {
|
||||
var user = Users.findOne(terms.userId);
|
||||
var postsIds = _.pluck(user.nova_upvotedPosts, "itemId");
|
||||
var postsIds = _.pluck(user.__upvotedPosts, "itemId");
|
||||
return {
|
||||
selector: {_id: {$in: postsIds}, userId: {$ne: terms.userId}}, // exclude own posts
|
||||
options: {limit: 5, sort: {postedAt: -1}}
|
||||
|
@ -128,7 +128,7 @@ Posts.views.add("userUpvotedPosts", function (terms) {
|
|||
*/
|
||||
Posts.views.add("userDownvotedPosts", function (terms) {
|
||||
var user = Users.findOne(terms.userId);
|
||||
var postsIds = _.pluck(user.nova_downvotedPosts, "itemId");
|
||||
var postsIds = _.pluck(user.__downvotedPosts, "itemId");
|
||||
// TODO: sort based on votedAt timestamp and not postedAt, if possible
|
||||
return {
|
||||
selector: {_id: {$in: postsIds}},
|
||||
|
|
|
@ -50,9 +50,9 @@ if (typeof Package['nova:posts'] !== "undefined") {
|
|||
|
||||
const user = Users.findOne({_id: post.userId});
|
||||
|
||||
if (!!user.nova_subscribers && !!user.nova_subscribers.length) {
|
||||
if (!!user.__subscribers && !!user.__subscribers.length) {
|
||||
// remove userIds of users that have already been notified and of post's author
|
||||
let subscriberIdsToNotify = _.difference(user.nova_subscribers, userIdsNotified, [user._id]);
|
||||
let subscriberIdsToNotify = _.difference(user.__subscribers, userIdsNotified, [user._id]);
|
||||
|
||||
Telescope.notifications.create(subscriberIdsToNotify, 'newPost', notificationData);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class SubscribeTo extends Component {
|
|||
this.props.flash(this.context.intl.formatMessage(
|
||||
{id: `${documentType}.${action}d`},
|
||||
// handle usual name properties
|
||||
{name: document.name || document.title || document.nova_displayName}
|
||||
{name: document.name || document.title || document.__displayName}
|
||||
), "success");
|
||||
this.context.events.track(action, {'_id': this.props.document._id});
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import Users from "meteor/nova:users";
|
|||
|
||||
Users.addField([
|
||||
{
|
||||
fieldName: 'nova_subscribedItems',
|
||||
fieldName: '__subscribedItems',
|
||||
fieldSchema: {
|
||||
type: Object,
|
||||
optional: true,
|
||||
|
@ -12,7 +12,7 @@ Users.addField([
|
|||
}
|
||||
},
|
||||
{
|
||||
fieldName: 'nova_subscribers',
|
||||
fieldName: '__subscribers',
|
||||
fieldSchema: {
|
||||
type: [String],
|
||||
optional: true,
|
||||
|
@ -25,7 +25,7 @@ Users.addField([
|
|||
}
|
||||
},
|
||||
{
|
||||
fieldName: 'nova_subscriberCount',
|
||||
fieldName: '__subscriberCount',
|
||||
fieldSchema: {
|
||||
type: Number,
|
||||
optional: true,
|
||||
|
@ -33,7 +33,7 @@ Users.addField([
|
|||
}
|
||||
}
|
||||
]);
|
||||
PublicationUtils.addToFields(Users.publishedFields.list, ["nova_subscribedItems", "nova_subscribers", "nova_subscriberCount"]);
|
||||
PublicationUtils.addToFields(Users.publishedFields.list, ["__subscribedItems", "__subscribers", "__subscriberCount"]);
|
||||
|
||||
// check if nova:posts exists, if yes, add the custom fields to Posts
|
||||
if (typeof Package['nova:posts'] !== "undefined") {
|
||||
|
|
|
@ -36,8 +36,8 @@ const prepareSubscription = (action, collection, itemId, user) => {
|
|||
|
||||
// assign the right fields depending on the collection
|
||||
const fields = {
|
||||
subscribers: collectionName === 'Users' ? 'nova_subscribers' : 'subscribers',
|
||||
subscriberCount: collectionName === 'Users' ? 'nova_subscriberCount' : 'subscriberCount',
|
||||
subscribers: collectionName === 'Users' ? '__subscribers' : 'subscribers',
|
||||
subscriberCount: collectionName === 'Users' ? '__subscriberCount' : 'subscriberCount',
|
||||
};
|
||||
|
||||
// return true if the item has the subscriber's id in its fields
|
||||
|
@ -119,7 +119,7 @@ const performSubscriptionAction = (action, collection, itemId, user) => {
|
|||
Users.update({
|
||||
_id: user._id
|
||||
}, {
|
||||
[updateOperator]: { [`nova_subscribedItems.${collectionName}`]: loggedItem }
|
||||
[updateOperator]: { [`__subscribedItems.${collectionName}`]: loggedItem }
|
||||
});
|
||||
|
||||
return true; // action completed! ✅
|
||||
|
|
|
@ -5,8 +5,8 @@ if (typeof Package['nova:posts'] !== "undefined") {
|
|||
var user = Users.findOne(terms.userId),
|
||||
postsIds = [];
|
||||
|
||||
if (user && user.nova_subscribedItems && user.nova_subscribedItems.Posts) {
|
||||
postsIds = _.pluck(user.nova_subscribedItems.Posts, "itemId");
|
||||
if (user && user.__subscribedItems && user.__subscribedItems.Posts) {
|
||||
postsIds = _.pluck(user.__subscribedItems.Posts, "itemId");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -28,8 +28,8 @@ Users.after.insert(function (userId, user) {
|
|||
*/
|
||||
Users.before.update(function (userId, doc, fieldNames, modifier) {
|
||||
// if bio is being modified, update htmlBio too
|
||||
if (Meteor.isServer && modifier.$set && modifier.$set["nova_bio"]) {
|
||||
modifier.$set["nova_htmlBio"] = Telescope.utils.sanitize(marked(modifier.$set["nova_bio"]));
|
||||
if (Meteor.isServer && modifier.$set && modifier.$set["__bio"]) {
|
||||
modifier.$set["__htmlBio"] = Telescope.utils.sanitize(marked(modifier.$set["__bio"]));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -43,7 +43,7 @@ Users.before.update(function (userId, doc, fieldNames, modifier) {
|
|||
});
|
||||
|
||||
/**
|
||||
* @summary If user.nova_email has changed, check for existing emails and change user.emails and email hash if needed
|
||||
* @summary If user.__email has changed, check for existing emails and change user.emails and email hash if needed
|
||||
*/
|
||||
if (Meteor.isServer) {
|
||||
Users.before.update(function (userId, doc, fieldNames, modifier) {
|
||||
|
@ -51,9 +51,9 @@ Users.before.update(function (userId, doc, fieldNames, modifier) {
|
|||
var user = doc;
|
||||
|
||||
// if email is being modified, update user.emails too
|
||||
if (Meteor.isServer && modifier.$set && modifier.$set["nova_email"]) {
|
||||
if (Meteor.isServer && modifier.$set && modifier.$set["__email"]) {
|
||||
|
||||
var newEmail = modifier.$set["nova_email"];
|
||||
var newEmail = modifier.$set["__email"];
|
||||
|
||||
// check for existing emails and throw error if necessary
|
||||
var userWithSameEmail = Users.findByEmail(newEmail);
|
||||
|
@ -68,7 +68,7 @@ Users.before.update(function (userId, doc, fieldNames, modifier) {
|
|||
}
|
||||
|
||||
// update email hash
|
||||
modifier.$set["nova_emailHash"] = Gravatar.hash(newEmail);
|
||||
modifier.$set["__emailHash"] = Gravatar.hash(newEmail);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -87,57 +87,57 @@ function setupUser (user, options) {
|
|||
// ------------------------------ Properties ------------------------------ //
|
||||
var userProperties = {
|
||||
profile: options.profile || {},
|
||||
nova_karma: 0,
|
||||
nova_isInvited: false,
|
||||
nova_postCount: 0,
|
||||
nova_commentCount: 0,
|
||||
nova_invitedCount: 0,
|
||||
nova_upvotedPosts: [],
|
||||
nova_downvotedPosts: [],
|
||||
nova_upvotedComments: [],
|
||||
nova_downvotedComments: []
|
||||
__karma: 0,
|
||||
__isInvited: false,
|
||||
__postCount: 0,
|
||||
__commentCount: 0,
|
||||
__invitedCount: 0,
|
||||
__upvotedPosts: [],
|
||||
__downvotedPosts: [],
|
||||
__upvotedComments: [],
|
||||
__downvotedComments: []
|
||||
};
|
||||
user = _.extend(user, userProperties);
|
||||
|
||||
// look in a few places for the user email
|
||||
if (options.email) {
|
||||
user.nova_email = options.email;
|
||||
user.__email = options.email;
|
||||
} else if (user.services['meteor-developer'] && user.services['meteor-developer'].emails) {
|
||||
user.nova_email = _.findWhere(user.services['meteor-developer'].emails, { primary: true }).address;
|
||||
user.__email = _.findWhere(user.services['meteor-developer'].emails, { primary: true }).address;
|
||||
} else if (user.services.facebook && user.services.facebook.email) {
|
||||
user.nova_email = user.services.facebook.email;
|
||||
user.__email = user.services.facebook.email;
|
||||
} else if (user.services.github && user.services.github.email) {
|
||||
user.nova_email = user.services.github.email;
|
||||
user.__email = user.services.github.email;
|
||||
} else if (user.services.google && user.services.google.email) {
|
||||
user.nova_email = user.services.google.email;
|
||||
user.__email = user.services.google.email;
|
||||
} else if (user.services.linkedin && user.services.linkedin.emailAddress) {
|
||||
user.nova_email = user.services.linkedin.emailAddress;
|
||||
user.__email = user.services.linkedin.emailAddress;
|
||||
}
|
||||
|
||||
// generate email hash
|
||||
if (!!user.nova_email) {
|
||||
user.nova_emailHash = Gravatar.hash(user.nova_email);
|
||||
if (!!user.__email) {
|
||||
user.__emailHash = Gravatar.hash(user.__email);
|
||||
}
|
||||
|
||||
// look in a few places for the displayName
|
||||
if (user.profile.username) {
|
||||
user.nova_displayName = user.profile.username;
|
||||
user.__displayName = user.profile.username;
|
||||
} else if (user.profile.name) {
|
||||
user.nova_displayName = user.profile.name;
|
||||
user.__displayName = user.profile.name;
|
||||
} else if (user.services.linkedin && user.services.linkedin.firstName) {
|
||||
user.nova_displayName = user.services.linkedin.firstName + " " + user.services.linkedin.lastName;
|
||||
user.__displayName = user.services.linkedin.firstName + " " + user.services.linkedin.lastName;
|
||||
} else {
|
||||
user.nova_displayName = user.username;
|
||||
user.__displayName = user.username;
|
||||
}
|
||||
|
||||
// create a basic slug from display name and then modify it if this slugs already exists;
|
||||
const basicSlug = Telescope.utils.slugify(user.nova_displayName);
|
||||
user.nova_slug = Telescope.utils.getUnusedSlug(Users, basicSlug);
|
||||
const basicSlug = Telescope.utils.slugify(user.__displayName);
|
||||
user.__slug = Telescope.utils.getUnusedSlug(Users, basicSlug);
|
||||
|
||||
// if this is not a dummy account, and is the first user ever, make them an admin
|
||||
user.isAdmin = (!user.profile.isDummy && Users.find({'profile.isDummy': {$ne: true}}).count() === 0) ? true : false;
|
||||
|
||||
Events.track('new user', {username: user.nova_displayName, email: user.nova_email});
|
||||
Events.track('new user', {username: user.__displayName, email: user.__email});
|
||||
|
||||
return user;
|
||||
}
|
||||
|
|
|
@ -91,5 +91,5 @@
|
|||
|
||||
// Avatar.setOptions({
|
||||
// fallbackType: 'initials',
|
||||
// emailHashProperty: 'nova_emailHash'
|
||||
// emailHashProperty: '__emailHash'
|
||||
// });
|
||||
|
|
|
@ -55,8 +55,8 @@ Users.getGroups = user => {
|
|||
|
||||
userGroups = ["default"];
|
||||
|
||||
if (user.nova_groups) { // custom groups
|
||||
userGroups = userGroups.concat(user.nova_groups);
|
||||
if (user.__groups) { // custom groups
|
||||
userGroups = userGroups.concat(user.__groups);
|
||||
}
|
||||
|
||||
if (Users.isAdmin(user)) { // admin
|
||||
|
|
|
@ -56,7 +56,7 @@ Users.getDisplayName = function (user) {
|
|||
if (typeof user === "undefined") {
|
||||
return "";
|
||||
} else {
|
||||
return (user.nova_displayName) ? user.nova_displayName : Users.getUserName(user);
|
||||
return (user.__displayName) ? user.__displayName : Users.getUserName(user);
|
||||
}
|
||||
};
|
||||
Users.helpers({getDisplayName: function () {return Users.getDisplayName(this);}});
|
||||
|
@ -73,8 +73,8 @@ Users.getProfileUrl = function (user, isAbsolute) {
|
|||
}
|
||||
isAbsolute = typeof isAbsolute === "undefined" ? false : isAbsolute; // default to false
|
||||
var prefix = isAbsolute ? Telescope.utils.getSiteUrl().slice(0,-1) : "";
|
||||
if (user.nova_slug) {
|
||||
return `${prefix}/users/${user.nova_slug}`;
|
||||
if (user.__slug) {
|
||||
return `${prefix}/users/${user.__slug}`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
@ -130,8 +130,8 @@ Users.getGitHubNameById = function (userId) {return Users.getGitHubName(Users.fi
|
|||
* @param {Object} user
|
||||
*/
|
||||
Users.getEmail = function (user) {
|
||||
if(user.nova_email){
|
||||
return user.nova_email;
|
||||
if(user.__email){
|
||||
return user.__email;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ Users.getEmailById = function (userId) {return Users.getEmail(Users.findOne(user
|
|||
* @param {Object} user
|
||||
*/
|
||||
Users.getEmailHash = function (user) {
|
||||
return user.nova_emailHash;
|
||||
return user.__emailHash;
|
||||
};
|
||||
Users.helpers({getEmailHash: function () {return Users.getEmailHash(this);}});
|
||||
Users.getEmailHashById = function (userId) {return Users.getEmailHash(Users.findOne(userId));};
|
||||
|
@ -158,8 +158,8 @@ Users.getEmailHashById = function (userId) {return Users.getEmailHash(Users.find
|
|||
Users.getSetting = function (user, settingName, defaultValue) {
|
||||
user = user || Meteor.user();
|
||||
defaultValue = defaultValue || null;
|
||||
// all settings should be prefixed by nova_ to avoid conflict with other meteor packages writing on Meteor.users collection, so add "nova_" if needed
|
||||
settingName = settingName.slice(0,10) === "nova_" ? settingName : "nova_" + settingName;
|
||||
// all settings should be prefixed by __ to avoid conflict with other meteor packages writing on Meteor.users collection, so add "__" if needed
|
||||
settingName = settingName.slice(0,10) === "__" ? settingName : "__" + settingName;
|
||||
if (user) {
|
||||
const settingValue = Users.getProperty(user, settingName);
|
||||
return typeof settingValue === 'undefined' ? defaultValue : settingValue;
|
||||
|
@ -285,6 +285,6 @@ Users.getCurrentUserEmail = function () {
|
|||
};
|
||||
|
||||
Users.findByEmail = function (email) {
|
||||
return Users.findOne({"nova_email": email});
|
||||
return Users.findOne({"__email": email});
|
||||
};
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ Users.methods.edit = (userId, modifier, user) => {
|
|||
}
|
||||
|
||||
Users.methods.setSetting = (userId, settingName, value) => {
|
||||
// all settings should be in the user.nova_ namespace, so add "nova_" if needed
|
||||
var field = settingName.slice(0,10) === "nova_" ? settingName : "nova_" + settingName;
|
||||
// all users settings should begin with the prexi __: user.__setting namespace, so add "__" if needed
|
||||
var field = settingName.slice(0,2) === "__" ? settingName : "__" + settingName;
|
||||
|
||||
var modifier = {$set: {}};
|
||||
modifier.$set[field] = value;
|
||||
|
@ -53,11 +53,11 @@ Users.methods.setSetting = (userId, settingName, value) => {
|
|||
}
|
||||
|
||||
Users.methods.addGroup = (userId, groupName) => {
|
||||
Users.update(userId, {$push: {"nova_groups": groupName}});
|
||||
Users.update(userId, {$push: {"__groups": groupName}});
|
||||
};
|
||||
|
||||
Users.methods.removeGroup = (userId, groupName) => {
|
||||
Users.update(userId, {$pull: {"nova_groups": groupName}});
|
||||
Users.update(userId, {$pull: {"__groups": groupName}});
|
||||
};
|
||||
|
||||
Meteor.methods({
|
||||
|
|
|
@ -13,10 +13,10 @@ Users.publishedFields.public = PublicationsUtils.arrayToFields([
|
|||
'services.twitter.profile_image_url_https',
|
||||
'services.facebook.id',
|
||||
'services.twitter.screenName',
|
||||
'nova_downvotedComments',
|
||||
'nova_downvotedPosts',
|
||||
'nova_upvotedComments',
|
||||
'nova_upvotedPosts'
|
||||
'__downvotedComments',
|
||||
'__downvotedPosts',
|
||||
'__upvotedComments',
|
||||
'__upvotedPosts'
|
||||
]);
|
||||
|
||||
/**
|
||||
|
@ -25,9 +25,9 @@ Users.publishedFields.public = PublicationsUtils.arrayToFields([
|
|||
*/
|
||||
// Users.publishedFields.list = PublicationsUtils.arrayToFields([
|
||||
// '_id',
|
||||
// 'nova_emailHash',
|
||||
// 'nova_slug',
|
||||
// 'nova_displayName',
|
||||
// '__emailHash',
|
||||
// '__slug',
|
||||
// '__displayName',
|
||||
// 'username',
|
||||
// 'profile.username',
|
||||
// 'profile.github',
|
||||
|
|
|
@ -13,40 +13,40 @@ Users.graphQLQueries = {
|
|||
username
|
||||
createdAt
|
||||
isAdmin
|
||||
nova_bio
|
||||
nova_commentCount
|
||||
nova_displayName
|
||||
nova_downvotedComments {
|
||||
__bio
|
||||
__commentCount
|
||||
__displayName
|
||||
__downvotedComments {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_downvotedPosts {
|
||||
__downvotedPosts {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_email
|
||||
nova_emailHash
|
||||
nova_htmlBio
|
||||
nova_karma
|
||||
nova_postCount
|
||||
nova_slug
|
||||
nova_twitterUsername
|
||||
nova_upvotedComments {
|
||||
__email
|
||||
__emailHash
|
||||
__htmlBio
|
||||
__karma
|
||||
__postCount
|
||||
__slug
|
||||
__twitterUsername
|
||||
__upvotedComments {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_upvotedPosts {
|
||||
__upvotedPosts {
|
||||
itemId
|
||||
power
|
||||
votedAt
|
||||
}
|
||||
nova_website
|
||||
nova_groups
|
||||
nova_notifications_users
|
||||
nova_notifications_posts
|
||||
nova_newsletter_subscribeToNewsletter
|
||||
__website
|
||||
__groups
|
||||
__notifications_users
|
||||
__notifications_posts
|
||||
__newsletter_subscribeToNewsletter
|
||||
`
|
||||
};
|
|
@ -4,17 +4,17 @@ import mutations from './mutations.js';
|
|||
const resolvers = {
|
||||
|
||||
User: {
|
||||
nova_downvotedComments(user, args, context) {
|
||||
return user.nova_downvotedComments ? user.nova_downvotedComments : []
|
||||
__downvotedComments(user, args, context) {
|
||||
return user.__downvotedComments ? user.__downvotedComments : []
|
||||
},
|
||||
nova_downvotedPosts(user, args, context) {
|
||||
return user.nova_downvotedPosts ? user.nova_downvotedPosts : []
|
||||
__downvotedPosts(user, args, context) {
|
||||
return user.__downvotedPosts ? user.__downvotedPosts : []
|
||||
},
|
||||
nova_upvotedComments(user, args, context) {
|
||||
return user.nova_upvotedComments ? user.nova_upvotedComments : []
|
||||
__upvotedComments(user, args, context) {
|
||||
return user.__upvotedComments ? user.__upvotedComments : []
|
||||
},
|
||||
nova_upvotedPosts(user, args, context) {
|
||||
return user.nova_upvotedPosts ? user.nova_upvotedPosts : [];
|
||||
__upvotedPosts(user, args, context) {
|
||||
return user.__upvotedPosts ? user.__upvotedPosts : [];
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -28,7 +28,7 @@ const resolvers = {
|
|||
return context.Users.find({}, {limit: 5}).fetch();
|
||||
},
|
||||
user(root, args, context) {
|
||||
return context.Users.findOne({$or: [{_id: args._id}, {'nova_slug': args.slug}]}, { fields: context.getViewableFields(context.currentUser, context.Users) });
|
||||
return context.Users.findOne({$or: [{_id: args._id}, {'__slug': args.slug}]}, { fields: context.getViewableFields(context.currentUser, context.Users) });
|
||||
},
|
||||
currentUser(root, args, context) {
|
||||
return context && context.userId ? context.Users.findOne(context.userId) : null;
|
||||
|
|
|
@ -83,7 +83,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
Bio (Markdown version)
|
||||
*/
|
||||
nova_bio: {
|
||||
__bio: {
|
||||
type: String,
|
||||
optional: true,
|
||||
control: "textarea",
|
||||
|
@ -94,7 +94,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
The name displayed throughout the app. Can contain spaces and special characters, doesn't need to be unique
|
||||
*/
|
||||
nova_displayName: {
|
||||
__displayName: {
|
||||
type: String,
|
||||
optional: true,
|
||||
publish: true,
|
||||
|
@ -107,7 +107,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
The user's email. Modifiable.
|
||||
*/
|
||||
nova_email: {
|
||||
__email: {
|
||||
type: String,
|
||||
optional: true,
|
||||
regEx: SimpleSchema.RegEx.Email,
|
||||
|
@ -121,7 +121,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
A hash of the email, used for Gravatar // TODO: change this when email changes
|
||||
*/
|
||||
nova_emailHash: {
|
||||
__emailHash: {
|
||||
type: String,
|
||||
publish: true,
|
||||
optional: true,
|
||||
|
@ -130,7 +130,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
The HTML version of the bio field
|
||||
*/
|
||||
nova_htmlBio: {
|
||||
__htmlBio: {
|
||||
type: String,
|
||||
publish: true,
|
||||
profile: true,
|
||||
|
@ -140,7 +140,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
The user's karma
|
||||
*/
|
||||
nova_karma: {
|
||||
__karma: {
|
||||
type: Number,
|
||||
decimal: true,
|
||||
publish: true,
|
||||
|
@ -150,7 +150,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
The user's profile URL slug // TODO: change this when displayName changes
|
||||
*/
|
||||
nova_slug: {
|
||||
__slug: {
|
||||
type: String,
|
||||
publish: true,
|
||||
optional: true,
|
||||
|
@ -159,7 +159,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
The user's Twitter username
|
||||
*/
|
||||
nova_twitterUsername: {
|
||||
__twitterUsername: {
|
||||
type: String,
|
||||
optional: true,
|
||||
publish: true,
|
||||
|
@ -173,7 +173,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
A link to the user's homepage
|
||||
*/
|
||||
nova_website: {
|
||||
__website: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Url,
|
||||
publish: true,
|
||||
|
@ -187,7 +187,7 @@ Users.schema = new SimpleSchema({
|
|||
/**
|
||||
Groups
|
||||
*/
|
||||
nova_groups: {
|
||||
__groups: {
|
||||
type: [String],
|
||||
optional: true,
|
||||
control: "checkboxgroup",
|
||||
|
|
|
@ -6,9 +6,9 @@ import Users from '../modules.js';
|
|||
*/
|
||||
Meteor.publish('users.single', function (terms) {
|
||||
|
||||
var idOrSlug = terms._id || terms['nova_slug'];
|
||||
var idOrSlug = terms._id || terms['__slug'];
|
||||
var findById = Users.findOne(idOrSlug);
|
||||
var findBySlug = Users.findOne({"nova_slug": idOrSlug});
|
||||
var findBySlug = Users.findOne({"__slug": idOrSlug});
|
||||
var user = typeof findById !== 'undefined' ? findById : findBySlug;
|
||||
var options = Users.isAdmin(this.userId) ? {} : {fields: Users.publishedFields.public};
|
||||
return user ? Users.find({_id: user._id}, options) : [];
|
||||
|
|
|
@ -10,52 +10,52 @@ Users.addField([
|
|||
An array containing comments upvotes
|
||||
*/
|
||||
{
|
||||
fieldName: 'nova_upvotedComments',
|
||||
fieldName: '__upvotedComments',
|
||||
fieldSchema: {
|
||||
type: [Telescope.schemas.votes],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableIf: alwaysPublic,
|
||||
resolveAs: 'nova_upvotedComments: [Vote]',
|
||||
resolveAs: '__upvotedComments: [Vote]',
|
||||
}
|
||||
},
|
||||
/**
|
||||
An array containing posts upvotes
|
||||
*/
|
||||
{
|
||||
fieldName: 'nova_upvotedPosts',
|
||||
fieldName: '__upvotedPosts',
|
||||
fieldSchema: {
|
||||
type: [Telescope.schemas.votes],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableIf: alwaysPublic,
|
||||
resolveAs: 'nova_upvotedPosts: [Vote]',
|
||||
resolveAs: '__upvotedPosts: [Vote]',
|
||||
}
|
||||
},
|
||||
/**
|
||||
An array containing comment downvotes
|
||||
*/
|
||||
{
|
||||
fieldName: 'nova_downvotedComments',
|
||||
fieldName: '__downvotedComments',
|
||||
fieldSchema: {
|
||||
type: [Telescope.schemas.votes],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableIf: alwaysPublic,
|
||||
resolveAs: 'nova_downvotedComments: [Vote]',
|
||||
resolveAs: '__downvotedComments: [Vote]',
|
||||
}
|
||||
},
|
||||
/**
|
||||
An array containing posts downvotes
|
||||
*/
|
||||
{
|
||||
fieldName: 'nova_downvotedPosts',
|
||||
fieldName: '__downvotedPosts',
|
||||
fieldSchema: {
|
||||
type: [Telescope.schemas.votes],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableIf: alwaysPublic,
|
||||
resolveAs: 'nova_downvotedPosts: [Vote]',
|
||||
resolveAs: '__downvotedPosts: [Vote]',
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
|
Loading…
Add table
Reference in a new issue