import { Account } from '@app/shared/account/account.model'
import { AccountService } from '@app/shared/account/account.service'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
-import { ServerService } from '@app/core'
+import { ServerService, AuthService } from '@app/core'
import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { I18n } from '@ngx-translate/i18n-polyfill'
+import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
export interface VideosProvider {
getVideos (parameters: {
constructor (
private authHttp: HttpClient,
+ private authService: AuthService,
+ private userService: UserService,
private restExtractor: RestExtractor,
private restService: RestService,
private serverService: ServerService,
filter?: VideoFilter,
categoryOneOf?: number,
languageOneOf?: string[],
- skipCount?: boolean
+ skipCount?: boolean,
+ nsfw?: boolean
}): Observable<ResultList<Video>> {
- const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount } = parameters
+ const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfw } = parameters
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '')
if (skipCount) params = params.set('skipCount', skipCount + '')
+ if (nsfw) {
+ params = params.set('nsfw', nsfw + '')
+ } else {
+ const nsfwPolicy = this.authService.isLoggedIn()
+ ? this.authService.getUser().nsfwPolicy
+ : this.userService.getAnonymousUser().nsfwPolicy
+ if (this.nsfwPolicyToFilter(nsfwPolicy)) params.set('nsfw', 'false')
+ }
+
if (languageOneOf) {
for (const l of languageOneOf) {
params = params.append('languageOneOf[]', l)
catchError(err => this.restExtractor.handleError(err))
)
}
+
+ private nsfwPolicyToFilter (policy: NSFWPolicyType) {
+ return policy === 'do_not_list'
+ }
}