ActivityPub-federated video streaming platform using P2P directly in your web browser
Add channels to upload form
Chocobozzzbcd9f81eff05
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.tsindex 7d890e72aa..984470d692 100644--- a/client/src/app/app.component.ts+++ b/client/src/app/app.component.ts@@ -37,7 +37,7 @@ export class AppComponent implements OnInit {if (this.authService.isLoggedIn()) {// The service will automatically redirect to the login page if the token is not valid anymore- this.userService.checkTokenValidity()+ this.authService.refreshUserInformation()}// Load custom data from serverdiff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.tsindex 4155aea192..81bff99a04 100644--- a/client/src/app/core/auth/auth-user.model.ts+++ b/client/src/app/core/auth/auth-user.model.ts@@ -1,6 +1,6 @@// Do not use the barrel (dependency loop)import { UserRole } from '../../../../../shared/models/users/user-role.type'-import { User } from '../../shared/users/user.model'+import { User, UserConstructorHash } from '../../shared/users/user.model'export type TokenOptions = {accessToken: string@@ -100,13 +100,7 @@ export class AuthUser extends User {Tokens.flush()}- constructor (userHash: {- id: number,- username: string,- role: UserRole,- email: string,- displayNSFW: boolean- }, hashTokens: TokenOptions) {+ constructor (userHash: UserConstructorHash, hashTokens: TokenOptions) {super(userHash)this.tokens = new Tokens(hashTokens)}diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.tsindex 4a8814c4e4..9ac9ba7bb1 100644--- a/client/src/app/core/auth/auth.service.ts+++ b/client/src/app/core/auth/auth.service.ts@@ -11,11 +11,17 @@ import { NotificationsService } from 'angular2-notifications'import { AuthStatus } from './auth-status.model'import { AuthUser } from './auth-user.model'-import { OAuthClientLocal, UserRole, UserRefreshToken } from '../../../../../shared'+import {+ OAuthClientLocal,+ UserRole,+ UserRefreshToken,+ VideoChannel,+ User as UserServerModel+} from '../../../../../shared'// Do not use the barrel (dependency loop)import { RestExtractor } from '../../shared/rest'import { UserLogin } from '../../../../../shared/models/users/user-login.model'-import { User } from '../../shared/users/user.model'+import { User, UserConstructorHash } from '../../shared/users/user.model'interface UserLoginWithUsername extends UserLogin {access_token: string@@ -33,6 +39,12 @@ interface UserLoginWithUserInformation extends UserLogin {role: UserRoledisplayNSFW: booleanemail: string+ videoQuota: number+ author: {+ id: number+ uuid: string+ }+ videoChannels: VideoChannel[]}@Injectable()@@ -197,6 +209,8 @@ export class AuthService {res => {this.user.displayNSFW = res.displayNSFWthis.user.role = res.role+ this.user.videoChannels = res.videoChannels+ this.user.author = res.authorthis.user.save()}@@ -207,13 +221,16 @@ export class AuthService {// User is not loaded yet, set manually auth headerconst headers = new HttpHeaders().set('Authorization', `${obj.token_type} ${obj.access_token}`)- return this.http.get<User>(AuthService.BASE_USER_INFORMATION_URL, { headers })+ return this.http.get<UserServerModel>(AuthService.BASE_USER_INFORMATION_URL, { headers }).map(res => {const newProperties = {- id: res.id as number,- role: res.role as UserRole,- displayNSFW: res.displayNSFW as boolean,- email: res.email as string+ id: res.id,+ role: res.role,+ displayNSFW: res.displayNSFW,+ email: res.email,+ videoQuota: res.videoQuota,+ author: res.author,+ videoChannels: res.videoChannels}return Object.assign(obj, newProperties)@@ -222,18 +239,23 @@ export class AuthService {}private handleLogin (obj: UserLoginWithUserInformation) {- const id = obj.id- const username = obj.username- const role = obj.role- const email = obj.email- const displayNSFW = obj.displayNSFW+ const hashUser: UserConstructorHash = {+ id: obj.id,+ username: obj.username,+ role: obj.role,+ email: obj.email,+ displayNSFW: obj.displayNSFW,+ videoQuota: obj.videoQuota,+ videoChannels: obj.videoChannels,+ author: obj.author+ }const hashTokens = {accessToken: obj.access_token,tokenType: obj.token_type,refreshToken: obj.refresh_token}- this.user = new AuthUser({ id, username, role, displayNSFW, email }, hashTokens)+ this.user = new AuthUser(hashUser, hashTokens)this.user.save()this.setStatus(AuthStatus.LoggedIn)diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.tsindex 32b1f1c2eb..213ab15db2 100644--- a/client/src/app/shared/forms/form-validators/video.ts+++ b/client/src/app/shared/forms/form-validators/video.ts@@ -28,6 +28,13 @@ export const VIDEO_LANGUAGE = {MESSAGES: {}}+export const VIDEO_CHANNEL = {+ VALIDATORS: [ Validators.required ],+ MESSAGES: {+ 'required': 'Video channel is required.'+ }+}+export const VIDEO_DESCRIPTION = {VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ],MESSAGES: {diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.tsindex 5c089d221a..6d1017fc9b 100644--- a/client/src/app/shared/users/user.service.ts+++ b/client/src/app/shared/users/user.service.ts@@ -15,13 +15,6 @@ export class UserService {private restExtractor: RestExtractor) {}- checkTokenValidity () {- const url = UserService.BASE_USERS_URL + 'me'-- // AuthHttp will redirect us to the login page if the token is not valid anymore- this.authHttp.get(url).subscribe()- }-changePassword (newPassword: string) {const url = UserService.BASE_USERS_URL + 'me'const body: UserUpdateMe = {diff --git a/client/src/app/videos/+video-edit/video-add.component.html b/client/src/app/videos/+video-edit/video-add.component.htmlindex 698152ff9e..7946c0879d 100644--- a/client/src/app/videos/+video-edit/video-add.component.html+++ b/client/src/app/videos/+video-edit/video-add.component.html@@ -25,6 +25,18 @@></div>+ <div class="form-group">+ <label for="category">Channel</label>+ <select class="form-control" id="channelId" formControlName="channelId">+ <option></option>+ <option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option>+ </select>++ <div *ngIf="formErrors.channelId" class="alert alert-danger">+ {{ formErrors.channelId }}+ </div>+ </div>+<div class="form-group"><label for="category">Category</label><select class="form-control" id="category" formControlName="category">diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.tsindex 8043bb41c8..92b03e8c96 100644--- a/client/src/app/videos/+video-edit/video-add.component.ts+++ b/client/src/app/videos/+video-edit/video-add.component.ts@@ -12,9 +12,10 @@ import {VIDEO_LANGUAGE,VIDEO_DESCRIPTION,VIDEO_TAGS,+ VIDEO_CHANNEL,VIDEO_FILE} from '../../shared'-import { ServerService } from '../../core'+import { AuthService, ServerService } from '../../core'import { VideoService } from '../shared'import { VideoCreate } from '../../../../../shared'import { HttpEventType, HttpResponse } from '@angular/common/http'@@ -33,6 +34,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {videoCategories = []videoLicences = []videoLanguages = []+ userVideoChannels = []tagValidators = VIDEO_TAGS.VALIDATORStagValidatorsMessages = VIDEO_TAGS.MESSAGES@@ -44,6 +46,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {category: '',licence: '',language: '',+ channelId: '',description: '',videofile: ''}@@ -52,6 +55,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {category: VIDEO_CATEGORY.MESSAGES,licence: VIDEO_LICENCE.MESSAGES,language: VIDEO_LANGUAGE.MESSAGES,+ channelId: VIDEO_CHANNEL.MESSAGES,description: VIDEO_DESCRIPTION.MESSAGES,videofile: VIDEO_FILE.MESSAGES}@@ -60,6 +64,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {private formBuilder: FormBuilder,private router: Router,private notificationsService: NotificationsService,+ private authService: AuthService,private serverService: ServerService,private videoService: VideoService) {@@ -77,6 +82,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {category: [ '', VIDEO_CATEGORY.VALIDATORS ],licence: [ '', VIDEO_LICENCE.VALIDATORS ],language: [ '', VIDEO_LANGUAGE.VALIDATORS ],+ channelId: [ this.userVideoChannels[0].id, VIDEO_CHANNEL.VALIDATORS ],description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],videofile: [ '', VIDEO_FILE.VALIDATORS ],tags: [ '' ]@@ -90,6 +96,9 @@ export class VideoAddComponent extends FormReactive implements OnInit {this.videoLicences = this.serverService.getVideoLicences()this.videoLanguages = this.serverService.getVideoLanguages()+ const user = this.authService.getUser()+ this.userVideoChannels = user.videoChannels.map(v => ({ id: v.id, label: v.name }))+this.buildForm()}@@ -122,6 +131,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {const category = formValue.categoryconst licence = formValue.licenceconst language = formValue.language+ const channelId = formValue.channelIdconst description = formValue.descriptionconst tags = formValue.tagsconst videofile = this.videofileInput.nativeElement.files[0]@@ -131,6 +141,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {formData.append('category', '' + category)formData.append('nsfw', '' + nsfw)formData.append('licence', '' + licence)+ formData.append('channelId', '' + channelId)formData.append('videofile', videofile)// Language is optionaldiff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.tsindex 4714ce01eb..d2f0ae0450 100644--- a/client/src/app/videos/video-list/video-list.component.ts+++ b/client/src/app/videos/video-list/video-list.component.ts@@ -1,4 +1,4 @@-import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'+import { Component, OnDestroy, OnInit } from '@angular/core'import { ActivatedRoute, Router } from '@angular/router'import { Subscription } from 'rxjs/Subscription'import { BehaviorSubject } from 'rxjs/BehaviorSubject'@@ -11,7 +11,6 @@ import {VideoService,VideoPagination} from '../shared'-import { AuthService, AuthUser } from '../../core'import { Search, SearchField, SearchService } from '../../shared'@Component({@@ -27,7 +26,6 @@ export class VideoListComponent implements OnInit, OnDestroy {totalItems: null}sort: SortField- user: AuthUser = nullvideos: Video[] = []private search: Search@@ -36,8 +34,6 @@ export class VideoListComponent implements OnInit, OnDestroy {constructor (private notificationsService: NotificationsService,- private authService: AuthService,- private changeDetector: ChangeDetectorRef,private router: Router,private route: ActivatedRoute,private videoService: VideoService,@@ -45,10 +41,6 @@ export class VideoListComponent implements OnInit, OnDestroy {) {}ngOnInit () {- if (this.authService.isLoggedIn()) {- this.user = AuthUser.load()- }-// Subscribe to route changesthis.subActivatedRoute = this.route.params.subscribe(routeParams => {this.loadRouteParams(routeParams)diff --git a/server/tests/api/friends-advanced.ts b/server/tests/api/friends-advanced.tsindex fbfdf227e3..139019398f 100644--- a/server/tests/api/friends-advanced.ts+++ b/server/tests/api/friends-advanced.ts@@ -221,11 +221,11 @@ describe('Test advanced friends', function () {// Pod 4 is friend with : 2 3// Pod 6 is friend with : 2 3it('Should make friends between pod 1, 2, 3 and 6 and exchange their videos', async function () {- this.timeout(20000)+ this.timeout(30000)await makeFriendsWrapper(1)- await wait(11000)+ await wait(22000)const res = await getVideosWrapper(1)const videos = res.body.data