peerlibrary / meteor-publish-context

Provide DDP._CurrentPublish with access to current publish context

Home Page:https://atmospherejs.com/peerlibrary/publish-context

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It does not work for the automated publications for users

theodorDiaconu opened this issue · comments

I20180109-18:04:02.592(2)? no invoke, CursorDescription {
I20180109-18:04:02.592(2)?   collectionName: 'users',
I20180109-18:04:02.592(2)?   selector: { _id: 'jzsdfPdbjBMdAedPg' },
I20180109-18:04:02.592(2)?   options:
I20180109-18:04:02.592(2)?    { transform: null,
I20180109-18:04:02.592(2)?      fields: { profile: 1, username: 1, emails: 1 } } }```

When that publication entry is created it does not put it inside DDP._CurrentPublish.get()

Any clues why ?
commented

What is "automated publications for users"? Can you share some code?

BTW, in Meteor >= 1.5.1 this package does not do anything anymore because there is official support for this. So it might be interesting to see if your bug also exists in Meter < 1.5.1. Because maybe then putting this feature into core Meteor was not done properly.

But at the moment I do not understand your issue at all. :-)

Sorry for being unclear @mitar . Basically it's related to the fact that Meteor auto publishes email,profile,id,username from the user. Well... that publication context does not contain the connection, so I can extract the id of it! But this happens with their DDP._CurrentPublicationInvocation also, so it's a Meteor issue, or something I don't understand.

commented

Ehm, but that auto publish is an already written code. :-) Where are you extracting that code? When you are monkey patching things?

But I do not see why it would not be set. The order of things how I see it is:

@mitar this is on redis-oplog, I'm basically oxtending Meteor.publish, and I notice that my observers do not have the connection property set, I will have to dig deeper. Thank you for the links you provided, it's a very strange issue.

commented

Are you running them in a new fiber? You should probably then copy all EnvironmentVariables over. But I am not sure what happens if then user logs out, are they all updated? Tricky tricky.

No new fiber is involved when creating the publications, so that shouldn't affect. User logging out calls the subscription methods again so we're fine on that part. Tricky indeed, there are so many factors involved it's easy to get lost, but I'll find a way.

commented

Good luck. I know how it is in those trenches. :-)