Keeps a mapping of which users blocked who, and provides methods to filter out blocked users.
Both client and server exposes a single Blocker
object, which includes methods specific to each environment.
You can import the Blocker
object using:
import Blocker from 'meteor/brewhk:accounts-block';
N.B. Client-side methods only work when the appropriate subscription has been made.
Makes a call to the server to block a user.
blockee*
String - The_id
of the user to be blockedcb
Function - A callback, passed with two arguments -error
andresponse
None
Makes a call to the server to unblock a user.
blockee*
String - The_id
of the user to be unblockedcb
Function - A callback, passed with two arguments -error
andresponse
None
N.B. Client-side methods only work when the appropriate subscription has been made.
Gets a cursor to the account block mapping for the user. Reading the actual code here might be more informative.
Blocker.getMappingForBlockedUsers = function (userId) {
return Collection.find({
blocker: userId,
});
};
For example, this method was used in our publications.
userId*
String - The_id
of the user to retrieve mapping for
cursor
Cursor - a cursor to the account block mapping for the user
Get an array of id
s belonging to users who have been blocked by the user specified.
For example, to see a list of users blocked by the user with _id
8qb2e86qqw
, you would run Blocker.getBlockedUserIds('8qb2e86qqw')
userId*
String - The user specified
userIds
[String] - a list of_id
s of users that was blocked
Get the number of users who have been blocked by the user specified.
userId*
String - The user specified
count
Number - the number of users who have been blocked by the user specified
Check whether a user has blocked another user
blockee*
String - The user that would be blockedblocker*
String - The user that is blocking the blockee
isBlocked
Boolean - Whether the blocking relationship exists or not
Blocks a user.
blockee*
String - The_id
of the user to be blockedblocker*
String - The_id
of the user blocking the blockee
res
Object - Object containing the keysnumberAffected
andinsertedId
Unblocks a user.
blockee*
String - The_id
of the user being blockedblocker*
String - The_id
of the user blocking the blockee
count
Number - The number of documents affected. Should be equal to1
Filters a list of users' id
s, removing
users, userId
Gets a cursor to the account block mapping affecting the user. Reading the actual code here might be more informative.
Blocker.getMappingOfUsersBlockingAUser = function(userId) {
return Collection.find({
blockee: userId,
});
};
userId*
String - The_id
of the user to retrieve mapping for
cursor
Cursor - a cursor to the account block mapping for the user
Get an array of id
s belonging to users who have blocked the user specified.
For example, to see a list of users who blocked the user with _id
8qb2e86qqw
, you would run Blocker.getUserIdsOfUsersBlockingAUser('8qb2e86qqw')
userId*
String - The user specified
userIds
[String] - a list of_id
s of users that was blocked
Get the number of users who have blocked the user specified.
userId*
String - The user specified
count
Number - the number of users who have blocked the user specified
Get the user objects of users who are blocking the user specified.
userId*
String - The user specified
cursor
Cursor - cursor fromMeteor.users
representing the users who are blocking the user specified
All methods have been namespaced with brewhk:accounts-block/
Blocks a user.
blockee*
String - The_id
of the user to be blocked
res
Object - Object containing the keysnumberAffected
andinsertedId
Unblocks a user.
blockee*
String - The_id
of the user to be blocked
count
Number - The number of documents affected. Should be equal to1
Get a list of (restricted) user objects of users that current user has blocked.
None
users
[Object] - An array of user objects representing users the currently-logged in user has blocked. The restricted user object contains the following fields (if the fields actually exists in the document):username
profile.firstName
profile.lastName
settings.profile.firstName
settings.profile.lastName
settings.account.firstName
settings.account.lastName
All publications have been namespaced with brewhk:accounts-block/
Returns a cursor to the account block mapping for the user. Simply calls Blocker.getMappingForBlockedUsers
with the currently-logged in user's id
.