+ static listEmailsWithRight (right: UserRight) {
+ const roles = Object.keys(USER_ROLE_LABELS)
+ .map(k => parseInt(k, 10) as UserRole)
+ .filter(role => hasUserRight(role, right))
+
+ console.log(roles)
+
+ const query = {
+ attribute: [ 'email' ],
+ where: {
+ role: {
+ [Sequelize.Op.in]: roles
+ }
+ }
+ }
+
+ return UserModel.unscoped()
+ .findAll(query)
+ .then(u => u.map(u => u.email))
+ }
+