Vulcan-Starter icon indicating copy to clipboard operation
Vulcan-Starter copied to clipboard

Example-forum package: Update parameter cannot have both modifier and non-modifier fields.

Open valgalin opened this issue 7 years ago • 1 comments

In the example-forum package, I set the setting forum.requirePostsApproval to true. But when I try to approved a user's pending post, I get this error message:

Update parameter cannot have both modifier and non-modifier fields.

When I try to set it to other status like "Rejected", or set it back again to "Pending", it works. The "Approved" status is the only one that does not work and outputs the error message.

Maybe it has something to do with onEdit line in this code in schema.js?

status: {
    type: Number,
    optional: true,
    viewableBy: ['guests'],
    insertableBy: ['admins'],
    editableBy: ['admins'],
    control: 'select',
    onInsert: (document, currentUser) => {
      if (!document.status) {
        return getCollection('Posts').getDefaultStatus(currentUser);
      }
    },
    onEdit: (modifier, document, currentUser) => {
      // if for some reason post status has been removed, give it default status
      if (modifier.$unset && modifier.$unset.status) {
        return getCollection('Posts').getDefaultStatus(currentUser);
      }
    },
    form: {
      options: () => getCollection('Posts').statuses,
    },
    group: formGroups.admin
  },

valgalin avatar Feb 09 '18 08:02 valgalin

I found the issue coming from the code in server/posts/callbacks/other.js

function PostsEditRunPostApprovedSyncCallbacks (modifier, post) {
  if (modifier.$set && Posts.isApproved(modifier.$set) && !Posts.isApproved(post)) {
    modifier = runCallbacks('posts.approve.sync', modifier, post);
  }
  return modifier;
}
addCallback('posts.edit.sync', PostsEditRunPostApprovedSyncCallbacks);

Not sure what this piece of code is supposed to do. I commented it out to resolve the issue.

tdameh avatar Aug 01 '18 01:08 tdameh