2

I've adapted server.js from the Parties example.

Instead of having "directory" publish all the users I want it to publish only those users that:

  • own a party the current user is invited to
  • are invited to a party the current user is invited to
  • are invited to a party the current user owns

See here: https://github.com/dimfisch/meteor-dependency/blob/master/parties/server/server.js

The problem is that when the current user invites a new user (new in the sense that they haven't been party-related previously) or gets invited by a new user, the "directory" subscription doesn't update, since the reactivity is on the cursor returned, which doesn't change in these cases.

Here are the steps to reproduce this situation:

  1. open two different clients, say Joe and Kate
  2. Joe creates a new private party and invites Kate
  3. Kate sees that new party, but doesn't get any info about Joe in Meteor.users
  4. I want Joe to show up in Kate's client

So the question is, how can that be achieved? One potential route is to make the "parties" cursor observeChanges, in the "directory" publish function. But I'm not sure this would actually work and I'm wondering if there's a more straightforward solution.

4

1 回答 1

0

似乎您可以在客户端使用 observeChanges 。每当parties集合更改时,停止并重新启动users订阅,这会强制发布功能重新运行。

parties发布功能只会发送当前用户有权访问的参与方信息。users发布功能将为有权访问同一方的任何用户发送适当的用户信息。

在服务器端,您可能可以做同样的事情,但它会做更多的工作......parties正常发布,但仅手动发布users与用户共享的内容。不确定删除案例如何工作。似乎这会很痛苦,而且可能效率不高。

于 2013-03-22T03:51:20.627 回答