Hold post for moderation but still visible to anon user

I have an app that allows people to post stories. They don’t need to be authenticated and obviously stories need to be moderated. Is there a way I can collect the story and show it in the feed or on the wall of the app only to that user? Here’s my idea, by all means chime in if this sounds rediculous::

  • user submits story
    – At the same time a user account is created on the app using data from the story they send in
    – user is auto-logged in
  • The story is marked as pending moderation or whatever and will be visible only to the author of the story and the admins.

Sort of like an anonymous but unique user setup??

Do I have the right idea here or no?

Why don’t you just create a null collection, and upon creating the story, add a copy of the story to the null collection, from which you can then display it to the user?

//client and server
AcceptedStories = new Mongo.Collection('stories')
//client only
AllStories = new Mongo.Collection(null)

I can’t think of a good way to display a list of same-schema data from two collections (without using fetch) in the same {{#each}} block, other than to run an observer on the client-side AcceptedStories and copy/change/remove those into the null collection.

If you have to persist the story between refreshes, you could use https://github.com/okgrow/meteor-persistent-session/ to store an array of storyId strings. You could then ask the server to serve the pending stories from a PendingStories collection, and then dump those into the AllStories collection on the client via the added/changed/removed publication API.

Or, you could try and have a collection on the server which keeps track of IP activity. I think I’ve heard that this is bad practice with MongoDB though, but I don’t fully understand why. If the data is static enough, I don’t see why it would be a huge problem.

That an interesting thought, thanks @streemo. How would I limit the user to only be able to see stories they’ve written that are still in moderation? I may just end up rolling accounts into it and forcing users to login. doesn’t really seem necessary with my approach above I just wanted to make it as easy as possible but adding one more click to facebook, twitter, etc isn’t adding many steps IMO…

I edited my post, it might answer your initial follow up Q. I think having two collections or a pending: true field in a single collection is the way to go.

You don’t need to login to do it. And yeah I feel ya on that… I personally have not tried integrated login yet at all, so I can only guess that it’s not too hard to setup and get users into.

Consider logging into these forums. It was easy, just a click, because I already had a meteor account “streemo”

When a client calls a method, like insert, this.connection.id is a unique ID available inside the method. It is available in publish functions.

So I think saving that id along with the story and using it to restrict which stories are published would do what you want.

1 Like

What prevents you from creating a key-value pair in your story document that contains a flag with the status of the story?

    {
    authorID: <author userID>,
    approvalStatus: <pending or approved>,
    storyTitle: <title>,
     ...
    }

When the stories are created, they get set to pending approvalStatus and when you publish your collection you can simply return only approved status’ unless the authorID and logged in userID match or unless the logged in user is an administrator.

That’s typically how I would do this but in this case I’m side-stepping the need to use accounts. So a user could be anyone, and when they submit a story only they would see it in the list until it was approved. Not too concerned about keeping session state. If it becomes an issue I will but for now a very rudimentary flow will do fine. The idea of two collections is picking up steam in my brain though. Thanks all for your input!.

just keep in mind tho that it’s harder to display data from two collections in the same list. You’ll have to get into collection merging if you wanna black box it to the user.

Hey,

I am in this situation now as well, and I remembered this post. What I did was create a Proto for pending items.

For example, when the user is creating a post or some content that happens in steps, I’ll fill the Protopost collection gradually using upserts. This lets me keep track of the state of the form.

So, the two-collection road is the one i ended up taking!

1 Like