Skip to content

Commit 3c6d022

Browse files
committed
Step 15.6: Update users publication to handle addressbook contacts
1 parent 4685740 commit 3c6d022

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api/server/publications.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { Chats } from './collections/chats';
55
import { Pictures } from './collections/pictures';
66

77
Meteor.publishComposite('users', function(
8-
pattern: string
8+
pattern: string,
9+
contacts: string[]
910
): PublishCompositeConfig<User> {
1011
if (!this.userId) {
1112
return;
@@ -15,8 +16,11 @@ Meteor.publishComposite('users', function(
1516

1617
if (pattern) {
1718
selector = {
18-
'profile.name': { $regex: pattern, $options: 'i' }
19+
'profile.name': { $regex: pattern, $options: 'i' },
20+
'phone.number': {$in: contacts}
1921
};
22+
} else {
23+
selector = {'phone.number': {$in: contacts}}
2024
}
2125

2226
return {

0 commit comments

Comments
 (0)