MUserWithNotificationSetting,
MVideoWithRights
} from '@server/types/models'
-import { AttributesOnly } from '@shared/core-utils'
+import { AttributesOnly } from '@shared/typescript-utils'
import { hasUserRight, USER_ROLE_LABELS } from '../../../shared/core-utils/users'
import { AbuseState, MyUser, UserRight, VideoPlaylistType, VideoPrivacy } from '../../../shared/models'
import { User, UserRole } from '../../../shared/models/users'
isUserEmailVerifiedValid,
isUserNoModal,
isUserNSFWPolicyValid,
+ isUserP2PEnabledValid,
isUserPasswordValid,
isUserRoleValid,
isUserUsernameValid,
isUserVideoLanguages,
isUserVideoQuotaDailyValid,
isUserVideoQuotaValid,
- isUserVideosHistoryEnabledValid,
- isUserWebTorrentEnabledValid
+ isUserVideosHistoryEnabledValid
} from '../../helpers/custom-validators/users'
import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto'
import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants'
include: [
{
model: ActorImageModel,
- as: 'Banner',
+ as: 'Banners',
required: false
}
]
nsfwPolicy: NSFWPolicyType
@AllowNull(false)
- @Default(true)
- @Is('UserWebTorrentEnabled', value => throwIfNotValid(value, isUserWebTorrentEnabledValid, 'WebTorrent enabled'))
+ @Is('p2pEnabled', value => throwIfNotValid(value, isUserP2PEnabledValid, 'P2P enabled'))
@Column
- webTorrentEnabled: boolean
+ p2pEnabled: boolean
@AllowNull(false)
@Default(true)
')'
),
'videoQuotaUsed'
- ] as any // FIXME: typings
+ ]
]
},
offset: start,
where
}
- return UserModel.findAndCountAll(query)
- .then(({ rows, count }) => {
- return {
- data: rows,
- total: count
- }
- })
+ return Promise.all([
+ UserModel.unscoped().count(query),
+ UserModel.findAll(query)
+ ]).then(([ total, data ]) => ({ total, data }))
}
static listWithRight (right: UserRight): Promise<MUserDefault[]> {
const query = {
where: {
[Op.or]: [
- where(fn('lower', col('username')), fn('lower', username)),
+ where(fn('lower', col('username')), fn('lower', username) as any),
{ email }
]
emailVerified: this.emailVerified,
nsfwPolicy: this.nsfwPolicy,
- webTorrentEnabled: this.webTorrentEnabled,
+
+ // FIXME: deprecated in 4.1
+ webTorrentEnabled: this.p2pEnabled,
+ p2pEnabled: this.p2pEnabled,
+
videosHistoryEnabled: this.videosHistoryEnabled,
autoPlayVideo: this.autoPlayVideo,
autoPlayNextVideo: this.autoPlayNextVideo,