|
|
|
|
@ -14,22 +14,27 @@ declare module '@rocket.chat/ddp-client' { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const permissionsGetMethod = async ( |
|
|
|
|
updatedAt?: Date, |
|
|
|
|
): Promise<IPermission[] | { update: IPermission[]; remove: WithId<RocketChatRecordDeleted<IPermission>>[] }> => { |
|
|
|
|
const records = await Permissions.find(updatedAt && { _updatedAt: { $gt: updatedAt } }).toArray(); |
|
|
|
|
|
|
|
|
|
if (updatedAt instanceof Date) { |
|
|
|
|
return { |
|
|
|
|
update: records, |
|
|
|
|
remove: await Permissions.trashFindDeletedAfter(updatedAt, {}, { projection: { _id: 1, _deletedAt: 1 } }).toArray(), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return records; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Meteor.methods<ServerMethods>({ |
|
|
|
|
async 'permissions/get'(updatedAt?: Date) { |
|
|
|
|
check(updatedAt, Match.Maybe(Date)); |
|
|
|
|
|
|
|
|
|
// TODO: should we return this for non logged users?
|
|
|
|
|
// TODO: we could cache this collection
|
|
|
|
|
|
|
|
|
|
const records = await Permissions.find(updatedAt && { _updatedAt: { $gt: updatedAt } }).toArray(); |
|
|
|
|
|
|
|
|
|
if (updatedAt instanceof Date) { |
|
|
|
|
return { |
|
|
|
|
update: records, |
|
|
|
|
remove: await Permissions.trashFindDeletedAfter(updatedAt, {}, { projection: { _id: 1, _deletedAt: 1 } }).toArray(), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return records; |
|
|
|
|
return permissionsGetMethod(updatedAt); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|