aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-01 11:08:10 +0100
committerChocobozzz <me@florianbigard.com>2018-02-01 11:08:29 +0100
commitba75d268596bc7b289bacf1cc4cb53493d6ad444 (patch)
treef631ed9a871ce078cd94afb0b4fcfc1e356944ec /server/models/account
parent09c93c2031ce4d7dee15f247b194f21346c7e615 (diff)
downloadPeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.tar.gz
PeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.tar.zst
PeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.zip
Send an email on video abuse report
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/user.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 026a8c9a0..653921907 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -4,7 +4,7 @@ import {
4 Scopes, Table, UpdatedAt 4 Scopes, Table, UpdatedAt
5} from 'sequelize-typescript' 5} from 'sequelize-typescript'
6import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' 6import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared'
7import { User } from '../../../shared/models/users' 7import { User, UserRole } from '../../../shared/models/users'
8import { 8import {
9 isUserAutoPlayVideoValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid, 9 isUserAutoPlayVideoValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid,
10 isUserVideoQuotaValid 10 isUserVideoQuotaValid
@@ -137,6 +137,27 @@ export class UserModel extends Model<UserModel> {
137 }) 137 })
138 } 138 }
139 139
140 static listEmailsWithRight (right: UserRight) {
141 const roles = Object.keys(USER_ROLE_LABELS)
142 .map(k => parseInt(k, 10) as UserRole)
143 .filter(role => hasUserRight(role, right))
144
145 console.log(roles)
146
147 const query = {
148 attribute: [ 'email' ],
149 where: {
150 role: {
151 [Sequelize.Op.in]: roles
152 }
153 }
154 }
155
156 return UserModel.unscoped()
157 .findAll(query)
158 .then(u => u.map(u => u.email))
159 }
160
140 static loadById (id: number) { 161 static loadById (id: number) {
141 return UserModel.findById(id) 162 return UserModel.findById(id)
142 } 163 }